From d98b6e310adf151a9bee6eaf152fdd80e8c00475 Mon Sep 17 00:00:00 2001 From: chunzhimoe <60135925+chunzhimoe@users.noreply.github.com> Date: Sun, 12 Apr 2026 17:30:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20SSH=20=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E7=A9=BA=E7=8A=B6=E6=80=81=E6=8F=90=E7=A4=BA=E4=B8=8E?= =?UTF-8?q?=E6=97=A7=E5=BA=94=E7=94=A8=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/page.tsx | 7 ++++++- src/components/Dashboard.tsx | 22 ++++++++++++++-------- src/lib/cloudflare.ts | 3 +++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 606c99b..28e6f18 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -7,10 +7,15 @@ export const revalidate = 60; export default async function Home() { let apps: SshApp[] = []; let error: string | null = null; + let emptyStateHint = "当前还没有 SSH 主机,先去创建一台。"; try { const allApps = await listAccessApps(); apps = filterSshApps(allApps); + if (apps.length === 0 && allApps.some((app) => app.type === "self_hosted")) { + emptyStateHint = + "当前账号下没有由 SSH Console 管理的主机;仅显示由本控制台创建或带识别标签的 SSH Access 应用。"; + } } catch (e) { error = e instanceof Error ? e.message : "未知错误"; apps = []; @@ -30,5 +35,5 @@ export default async function Home() { ); } - return ; + return ; } diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 90d84b2..702ee40 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -44,7 +44,13 @@ function timeAgo(dateStr: string | null): string { return `${months} 个月前`; } -export default function Dashboard({ apps }: { apps: SshAppData[] }) { +export default function Dashboard({ + apps, + emptyStateHint = "当前还没有 SSH 主机,先去创建一台。", +}: { + apps: SshAppData[]; + emptyStateHint?: string; +}) { const [search, setSearch] = useState(""); const [selectedTag, setSelectedTag] = useState(null); @@ -173,13 +179,13 @@ export default function Dashboard({ apps }: { apps: SshAppData[] }) {

未找到主机

-

- {search || selectedTag - ? "请调整搜索条件或过滤器" - : "请确认 API Token 具备 Access: Apps and Policies Read 权限"} -

- - )} +

+ {search || selectedTag + ? "请调整搜索条件或过滤器" + : emptyStateHint} +

+ + )} {/* Host cards */}
diff --git a/src/lib/cloudflare.ts b/src/lib/cloudflare.ts index 10df226..8c0a248 100644 --- a/src/lib/cloudflare.ts +++ b/src/lib/cloudflare.ts @@ -172,6 +172,7 @@ export async function listAccessApps(): Promise { /** Tag added to every Access app created by this console */ export const SSH_CONSOLE_TAG = "managed:ssh-console"; +const LEGACY_SSH_APP_NAME_PREFIX = "SSH · "; /** * Identifies apps managed by this SSH console. @@ -185,6 +186,8 @@ function isSshConsoleApp(app: AccessApp): boolean { // Legacy apps created before the tag was introduced: has a metrics: tag // (only this console sets that pattern) if (tags.some((t) => t.startsWith("metrics:"))) return true; + // Older apps created by this console used a stable name prefix. + if ((app.name ?? "").startsWith(LEGACY_SSH_APP_NAME_PREFIX)) return true; return false; }