mirror of
https://github.com/luckjiawei/podux.git
synced 2026-11-30 01:26:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0736130769 | ||
|
|
1bdd35a234 | ||
|
|
e37661c6e9 | ||
|
|
1578832510 | ||
|
|
cfbbf31543 | ||
|
|
3a1ad7ce65 | ||
|
|
01c3a70d2b |
No files matched your search
@@ -62,6 +62,12 @@
|
||||
- 2026-03-12: Released v0.1.2
|
||||
- 2026-03-16: Released v0.1.3
|
||||
- 2026-03-25: Released v0.1.4
|
||||
- 2026-03-26: Released v0.1.5
|
||||
- 2026-03-31: Released v0.1.6
|
||||
|
||||
## License
|
||||
|
||||
[Apache 2.0](LICENSE)
|
||||
|
||||
## Star History
|
||||
|
||||
|
||||
@@ -62,6 +62,12 @@
|
||||
- 2026-03-14: 发布 v0.1.2
|
||||
- 2026-03-16: 发布 v0.1.3
|
||||
- 2026-03-25: 发布 v0.1.4
|
||||
- 2026-03-26: 发布 v0.1.5
|
||||
- 2026-03-31: 发布 v0.1.6
|
||||
|
||||
## License
|
||||
|
||||
[Apache 2.0](LICENSE)
|
||||
|
||||
## Star 历史
|
||||
|
||||
|
||||
@@ -170,6 +170,8 @@ func (fs *Service) genProxyCfgs(serverId *string) ([]v1.ProxyConfigurer, error)
|
||||
if proxyMap.ProxyType == "http" || proxyMap.ProxyType == "https" {
|
||||
delete(proxyData, "remotePort")
|
||||
}
|
||||
proxyData["type"] = proxyMap.ProxyType
|
||||
delete(proxyData, "proxyType")
|
||||
proxyData["name"] = proxyMap.Name + "-" + proxyMap.Id
|
||||
|
||||
// Remove empty plugin map so frp doesn't try to parse a typeless plugin
|
||||
|
||||
@@ -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.6"
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "podux-web",
|
||||
"private": true,
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.6",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user