chore: wave-0 baseline (Tauri2+React shell, platform detect, fake catalog)
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Sidebar, type PageKey, PAGE_META } from "./components/Sidebar";
|
||||
import { Header } from "./components/Header";
|
||||
import { OverviewPage } from "./pages/Overview";
|
||||
import { CatalogPage } from "./pages/Catalog";
|
||||
import { MyCliPage } from "./pages/MyCli";
|
||||
import { ConfigCenterPage } from "./pages/ConfigCenter";
|
||||
import { BackupPage } from "./pages/Backup";
|
||||
import { SettingsPage } from "./pages/Settings";
|
||||
import { useEnv } from "./hooks/useEnv";
|
||||
import type { PlatformEnv, RuntimeInfo } from "./ipc/types";
|
||||
|
||||
/** 平台相关运行时集合(Windows 不看 apt,Linux 不看 winget) */
|
||||
const WIN_RUNTIMES = ["node", "npm", "python", "uv", "git", "winget"] as const;
|
||||
const LINUX_RUNTIMES = ["node", "npm", "python", "uv", "git", "apt"] as const;
|
||||
|
||||
function envWarningCount(env: PlatformEnv | null): number {
|
||||
if (!env) return 0;
|
||||
const keys = env.os === "windows" ? WIN_RUNTIMES : LINUX_RUNTIMES;
|
||||
let n = 0;
|
||||
for (const k of keys) {
|
||||
const info = env.runtimes[k] as RuntimeInfo | null | undefined;
|
||||
if (info && info.status !== "installed") n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const [page, setPage] = useState<PageKey>("overview");
|
||||
const { env } = useEnv();
|
||||
const warningCount = envWarningCount(env);
|
||||
|
||||
const content = useMemo(() => {
|
||||
switch (page) {
|
||||
case "overview":
|
||||
return <OverviewPage />;
|
||||
case "catalog":
|
||||
return <CatalogPage />;
|
||||
case "my-cli":
|
||||
return <MyCliPage />;
|
||||
case "config":
|
||||
return <ConfigCenterPage />;
|
||||
case "backup":
|
||||
return <BackupPage />;
|
||||
case "settings":
|
||||
return <SettingsPage />;
|
||||
}
|
||||
}, [page]);
|
||||
|
||||
return (
|
||||
<div className="app-shell">
|
||||
<div className="bg-grid grid-drift" aria-hidden="true" />
|
||||
<Sidebar current={page} onNavigate={setPage} />
|
||||
<div className="app-main">
|
||||
<Header title={PAGE_META[page].title} warningCount={warningCount} />
|
||||
<main className="app-content">
|
||||
{/* key=page 触发 §4.2 页面切换动效:translateY(8px)+淡入 */}
|
||||
<div key={page} className="page-enter">
|
||||
{content}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user