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; }