3 Commits
Author SHA1 Message Date
刘嘉伟 cfbbf31543 chore: bump version to 0.1.5. 2026-03-26 16:07:18 +08:00
刘嘉伟 3a1ad7ce65 feat(proxies): enhance clipboard compatibility and remote port display
- Improve clipboard copy functionality with fallback for older browsers
- Change remote port display logic to show empty string instead of "-" for missing values
- Maintain consistent copy feedback behavior across all browser environments
2026-03-26 15:28:21 +08:00
刘嘉伟 01c3a70d2b 🐛 Fix proxy list pagination. 2026-03-26 15:12:05 +08:00
6 changed files with 208 additions and 15 deletions

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@ package buildinfo
// AppVersion is the single source of truth for the application version.
// Update this value to release a new version.
const AppVersion = "0.1.4"
const AppVersion = "0.1.5"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "podux-web",
"private": true,
"version": "0.1.4",
"version": "0.1.5",
"type": "module",
"scripts": {
"dev": "vite",
+100 -4
View File
@@ -21,6 +21,11 @@ interface ProxiesViewProps {
onDeleteProxy: (id: string) => Promise<void>;
onToggleStatus: (proxy: Proxy) => Promise<void>;
refreshProxies: () => void;
page: number;
setPage: (page: number) => void;
totalPages: number;
search: string;
setSearch: (value: string) => void;
}
export function ProxiesView({
@@ -31,6 +36,11 @@ export function ProxiesView({
onDeleteProxy,
onToggleStatus,
refreshProxies,
page,
setPage,
totalPages,
search,
setSearch,
}: ProxiesViewProps) {
const { t } = useTranslation();
const navigate = useNavigate();
@@ -40,10 +50,23 @@ export function ProxiesView({
const [togglingId, setTogglingId] = useState<string | null>(null);
const handleCopy = (text: string, id: string) => {
navigator.clipboard.writeText(text).then(() => {
const done = () => {
setCopiedId(id);
setTimeout(() => setCopiedId(null), 1500);
});
};
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(done);
} else {
const el = document.createElement("textarea");
el.value = text;
el.style.position = "fixed";
el.style.opacity = "0";
document.body.appendChild(el);
el.select();
document.execCommand("copy");
document.body.removeChild(el);
done();
}
};
useEffect(() => {
@@ -121,10 +144,21 @@ export function ProxiesView({
size="2"
placeholder={t("proxy.searchProxies")}
className="min-w-32 flex-1"
value={search}
onChange={(e) => setSearch(e.target.value)}
>
<TextField.Slot>
<Icon icon="lucide:search" width="16" height="16" />
</TextField.Slot>
{search && (
<TextField.Slot
pr="2"
onClick={() => setSearch("")}
style={{ cursor: "pointer" }}
>
<Icon icon="lucide:x" width="16" height="16" />
</TextField.Slot>
)}
</TextField.Root>
<Button variant="soft" onClick={refreshProxies} disabled={refreshing}>
<Icon
@@ -155,6 +189,7 @@ export function ProxiesView({
onAction={() => navigate("/proxies/new")}
/>
) : (
<>
<div className="overflow-x-auto">
<Table.Root>
<Table.Header>
@@ -172,6 +207,7 @@ export function ProxiesView({
</Table.Header>
<Table.Body>
{proxies.map((proxy) => (
<Table.Row key={proxy.id}>
<Table.Cell>
<Text weight="medium">{proxy.name || <Text color="gray">-</Text>}</Text>
@@ -278,8 +314,8 @@ export function ProxiesView({
</Flex>
);
}
const displayText = proxy.remotePort || "-";
if (displayText === "-")
const displayText = proxy.remotePort ? String(proxy.remotePort) : "";
if (!displayText)
return <Text size="2" color="gray">-</Text>;
const copyKey = `${proxy.id}-port`;
const isCopied = copiedId === copyKey;
@@ -379,6 +415,66 @@ export function ProxiesView({
</Table.Body>
</Table.Root>
</div>
{totalPages > 1 && (
<Flex justify="between" align="center" pt="4" px="1">
<Text size="2" color="gray">
{page} / {totalPages}
</Text>
<Flex align="center" style={{ border: "1px solid var(--gray-6)", borderRadius: "var(--radius-3)", overflow: "hidden" }}>
<button
disabled={page === 1}
onClick={() => setPage(page - 1)}
style={{
padding: "6px 10px",
background: "none",
border: "none",
borderRight: "1px solid var(--gray-6)",
cursor: page === 1 ? "not-allowed" : "pointer",
opacity: page === 1 ? 0.4 : 1,
display: "flex",
alignItems: "center",
}}
>
<Icon icon="lucide:chevron-left" width="14" height="14" />
</button>
{Array.from({ length: totalPages }, (_, i) => i + 1).map((p) => (
<button
key={p}
onClick={() => setPage(p)}
style={{
padding: "6px 12px",
background: p === page ? "var(--accent-9)" : "none",
color: p === page ? "white" : "inherit",
border: "none",
borderRight: p === totalPages ? "none" : "1px solid var(--gray-6)",
cursor: "pointer",
fontSize: "var(--font-size-2)",
fontWeight: p === page ? 600 : 400,
}}
>
{p}
</button>
))}
<button
disabled={page === totalPages}
onClick={() => setPage(page + 1)}
style={{
padding: "6px 10px",
background: "none",
border: "none",
borderLeft: "1px solid var(--gray-6)",
cursor: page === totalPages ? "not-allowed" : "pointer",
opacity: page === totalPages ? 0.4 : 1,
display: "flex",
alignItems: "center",
}}
>
<Icon icon="lucide:chevron-right" width="14" height="14" />
</button>
</Flex>
</Flex>
)}
</>
)}
</Card>
</motion.div>
+6 -1
View File
@@ -2,7 +2,7 @@ import { useProxies } from "./useProxies";
import { ProxiesView } from "./ProxiesPage.view";
export function ProxiesPage() {
const { proxies, loading, refreshing, stats, deleteProxy, toggleStatus, refreshProxies } = useProxies();
const { proxies, loading, refreshing, stats, deleteProxy, toggleStatus, refreshProxies, page, setPage, totalPages, search, setSearch } = useProxies();
return (
<ProxiesView
@@ -13,6 +13,11 @@ export function ProxiesPage() {
onDeleteProxy={deleteProxy}
onToggleStatus={toggleStatus}
refreshProxies={refreshProxies}
page={page}
setPage={setPage}
totalPages={totalPages}
search={search}
setSearch={setSearch}
/>
);
}
+35 -8
View File
@@ -29,8 +29,21 @@ export function useProxies() {
const [page, setPage] = useState(1);
const [totalPages, setTotalPages] = useState(1);
const [totalItems, setTotalItems] = useState(0);
const [onlineCount, setOnlineCount] = useState(0);
const [search, setSearch] = useState("");
const [debouncedSearch, setDebouncedSearch] = useState("");
const PER_PAGE = 10;
useEffect(() => {
const timer = setTimeout(() => setDebouncedSearch(search), 300);
return () => clearTimeout(timer);
}, [search]);
useEffect(() => {
setPage(1);
}, [debouncedSearch]);
const fetchProxies = useCallback(
async (isRefresh = false) => {
try {
@@ -40,12 +53,24 @@ export function useProxies() {
setRefreshing(true);
}
const result = await pb.collection("fh_proxies").getList<Proxy>(page, PER_PAGE, {
sort: "-created",
expand: "serverId",
});
const searchFilter = debouncedSearch
? `name ~ "${debouncedSearch}" || localIP ~ "${debouncedSearch}" || remotePort ~ "${debouncedSearch}"`
: "";
const [result, onlineResult] = await Promise.all([
pb.collection("fh_proxies").getList<Proxy>(page, PER_PAGE, {
sort: "-created",
expand: "serverId",
filter: searchFilter,
}),
pb.collection("fh_proxies").getList(1, 1, {
filter: 'bootStatus = "online"',
}),
]);
setProxies(result.items);
setTotalPages(result.totalPages);
setTotalItems(result.totalItems);
setOnlineCount(onlineResult.totalItems);
initializedRef.current = true;
} catch (err) {
if ((err as Record<string, unknown>)?.isAbort) return;
@@ -55,7 +80,7 @@ export function useProxies() {
setRefreshing(false);
}
},
[page]
[page, debouncedSearch]
);
useEffect(() => {
@@ -104,9 +129,9 @@ export function useProxies() {
};
const stats = {
total: proxies.length,
online: proxies.filter((p) => p.bootStatus === "online").length,
offline: proxies.filter((p) => p.bootStatus === "offline").length,
total: totalItems,
online: onlineCount,
offline: totalItems - onlineCount,
};
const isEmpty = !loading && proxies.length === 0;
@@ -122,6 +147,8 @@ export function useProxies() {
setPage,
totalPages,
stats,
search,
setSearch,
refreshProxies: () => fetchProxies(true),
};
}
@@ -33,6 +33,9 @@ interface ServersViewProps {
search: string;
setSearch: (value: string) => void;
refreshServers: () => void;
page: number;
setPage: (page: number) => void;
totalPages: number;
}
export function ServersView({
@@ -45,6 +48,9 @@ export function ServersView({
search,
setSearch,
refreshServers,
page,
setPage,
totalPages,
}: ServersViewProps) {
const { t } = useTranslation();
const navigate = useNavigate();
@@ -411,6 +417,65 @@ export function ServersView({
</Table.Body>
</Table.Root>
</div>
{totalPages > 1 && (
<Flex justify="between" align="center" pt="4" px="1">
<Text size="2" color="gray">
{page} / {totalPages}
</Text>
<Flex align="center" style={{ border: "1px solid var(--gray-6)", borderRadius: "var(--radius-3)", overflow: "hidden" }}>
<button
disabled={page === 1}
onClick={() => setPage(page - 1)}
style={{
padding: "6px 10px",
background: "none",
border: "none",
borderRight: "1px solid var(--gray-6)",
cursor: page === 1 ? "not-allowed" : "pointer",
opacity: page === 1 ? 0.4 : 1,
display: "flex",
alignItems: "center",
}}
>
<Icon icon="lucide:chevron-left" width="14" height="14" />
</button>
{Array.from({ length: totalPages }, (_, i) => i + 1).map((p) => (
<button
key={p}
onClick={() => setPage(p)}
style={{
padding: "6px 12px",
background: p === page ? "var(--accent-9)" : "none",
color: p === page ? "white" : "inherit",
border: "none",
borderRight: p === totalPages ? "none" : "1px solid var(--gray-6)",
cursor: "pointer",
fontSize: "var(--font-size-2)",
fontWeight: p === page ? 600 : 400,
}}
>
{p}
</button>
))}
<button
disabled={page === totalPages}
onClick={() => setPage(page + 1)}
style={{
padding: "6px 10px",
background: "none",
border: "none",
borderLeft: "1px solid var(--gray-6)",
cursor: page === totalPages ? "not-allowed" : "pointer",
opacity: page === totalPages ? 0.4 : 1,
display: "flex",
alignItems: "center",
}}
>
<Icon icon="lucide:chevron-right" width="14" height="14" />
</button>
</Flex>
</Flex>
)}
</motion.div>
)}
</AnimatePresence>