chore: wave-0 baseline (Tauri2+React shell, platform detect, fake catalog)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Archive } from "lucide-react";
|
||||
|
||||
/** 备份与迁移(PRD §7):创建备份、查看内容、恢复。Wave 0 占位。 */
|
||||
export function BackupPage() {
|
||||
return (
|
||||
<div className="placeholder-page">
|
||||
<div className="placeholder-icon">
|
||||
<Archive size={40} strokeWidth={1.5} aria-hidden="true" />
|
||||
</div>
|
||||
<h2 className="placeholder-title">备份与迁移</h2>
|
||||
<p className="placeholder-desc">
|
||||
备份功能在 Wave 4 落地。备份将明确标注是否包含敏感信息,密钥永不进备份。
|
||||
</p>
|
||||
<button type="button" className="btn btn-secondary" disabled>
|
||||
创建备份
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Search } from "lucide-react";
|
||||
import { useCatalog } from "../hooks/useCatalog";
|
||||
import { StatusBadge } from "../components/StatusBadge";
|
||||
import { MonoChip } from "../components/MonoChip";
|
||||
import { CliMonogram } from "../components/CliMonogram";
|
||||
|
||||
type StatusFilter = "all" | "installed" | "uninstalled" | "update";
|
||||
type PlatformFilter = "all" | "windows" | "linux";
|
||||
|
||||
const STATUS_FILTERS: { key: StatusFilter; label: string }[] = [
|
||||
{ key: "all", label: "全部" },
|
||||
{ key: "installed", label: "已安装" },
|
||||
{ key: "uninstalled", label: "未安装" },
|
||||
{ key: "update", label: "可更新" },
|
||||
];
|
||||
|
||||
const PLATFORM_FILTERS: { key: PlatformFilter; label: string }[] = [
|
||||
{ key: "all", label: "全部平台" },
|
||||
{ key: "windows", label: "Windows" },
|
||||
{ key: "linux", label: "Linux" },
|
||||
];
|
||||
|
||||
/** CLI 目录页(视觉规范 §3.2 + PRD §7):搜索 + 筛选 + 14 张卡片(数据来自 catalog.yaml) */
|
||||
export function CatalogPage() {
|
||||
const { entries, loading, error } = useCatalog();
|
||||
const [query, setQuery] = useState("");
|
||||
const [status, setStatus] = useState<StatusFilter>("all");
|
||||
const [platform, setPlatform] = useState<PlatformFilter>("all");
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const q = query.trim().toLowerCase();
|
||||
return entries.filter((e) => {
|
||||
if (q) {
|
||||
const haystack = `${e.name_zh} ${e.name} ${e.vendor} ${e.id}`.toLowerCase();
|
||||
if (!haystack.includes(q)) return false;
|
||||
}
|
||||
// Wave 0:14 个均为未安装;已安装/可更新筛选结果为空(诚实占位)
|
||||
if (status === "installed") return false;
|
||||
if (status === "update") return false;
|
||||
// 平台:全部 14 个均支持 Windows + Ubuntu(调研底稿结论),筛选不改变集合
|
||||
if (platform === "windows" || platform === "linux") return true;
|
||||
return true;
|
||||
});
|
||||
}, [entries, query, status, platform]);
|
||||
|
||||
return (
|
||||
<div className="catalog">
|
||||
<div className="catalog-toolbar">
|
||||
<div className="search-box">
|
||||
<Search size={16} strokeWidth={1.5} className="search-icon" aria-hidden="true" />
|
||||
<input
|
||||
type="search"
|
||||
placeholder="搜索 CLI…"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
aria-label="搜索 CLI"
|
||||
/>
|
||||
</div>
|
||||
<div className="filter-group" role="group" aria-label="状态筛选">
|
||||
{STATUS_FILTERS.map((f) => (
|
||||
<button
|
||||
key={f.key}
|
||||
type="button"
|
||||
className={status === f.key ? "pill active" : "pill"}
|
||||
onClick={() => setStatus(f.key)}
|
||||
>
|
||||
{f.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="filter-group" role="group" aria-label="平台筛选">
|
||||
{PLATFORM_FILTERS.map((f) => (
|
||||
<button
|
||||
key={f.key}
|
||||
type="button"
|
||||
className={platform === f.key ? "pill active" : "pill"}
|
||||
onClick={() => setPlatform(f.key)}
|
||||
>
|
||||
{f.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && <p className="panel-empty">目录加载失败:{error}</p>}
|
||||
{loading && !error && <p className="panel-empty">目录加载中…</p>}
|
||||
|
||||
<div className="catalog-grid">
|
||||
{filtered.map((entry) => (
|
||||
<article className="catalog-card" key={entry.id}>
|
||||
<div className="catalog-card-top">
|
||||
<CliMonogram name={entry.name} size={40} />
|
||||
<div className="catalog-card-head">
|
||||
<div className="catalog-card-name">{entry.name_zh}</div>
|
||||
<div className="catalog-card-vendor">{entry.vendor}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p className="catalog-card-desc">官方渠道安装 · 适配器随 Wave 1 落地</p>
|
||||
<div className="catalog-card-bottom">
|
||||
<StatusBadge kind="uninstalled" label="未安装" />
|
||||
<span className="catalog-platforms">Windows · Linux</span>
|
||||
<MonoChip>v1</MonoChip>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
{!loading && filtered.length === 0 && (
|
||||
<p className="panel-empty catalog-empty">没有符合条件的 CLI</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { SlidersHorizontal } from "lucide-react";
|
||||
|
||||
/** 配置中心(PRD §7):按 CLI 展示中文配置表单。Wave 0 占位。 */
|
||||
export function ConfigCenterPage() {
|
||||
return (
|
||||
<div className="placeholder-page">
|
||||
<div className="placeholder-icon">
|
||||
<SlidersHorizontal size={40} strokeWidth={1.5} aria-hidden="true" />
|
||||
</div>
|
||||
<h2 className="placeholder-title">配置中心</h2>
|
||||
<p className="placeholder-desc">
|
||||
中文配置表单在 Wave 2 落地。敏感字段将使用密码输入与系统密钥库。
|
||||
</p>
|
||||
<button type="button" className="btn btn-secondary" disabled>
|
||||
选择 CLI 开始配置
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { SquareTerminal } from "lucide-react";
|
||||
|
||||
/** 我的 CLI(PRD §7):版本 / 路径 / 授权状态。Wave 0 尚无已安装 CLI,展示空态。 */
|
||||
export function MyCliPage() {
|
||||
return (
|
||||
<div className="placeholder-page">
|
||||
<div className="placeholder-icon">
|
||||
<SquareTerminal size={40} strokeWidth={1.5} aria-hidden="true" />
|
||||
</div>
|
||||
<h2 className="placeholder-title">暂无已安装 CLI</h2>
|
||||
<p className="placeholder-desc">
|
||||
安装功能在 Wave 1 开放。届时这里会展示每个 CLI 的版本、路径与授权状态。
|
||||
</p>
|
||||
<button type="button" className="btn btn-primary" disabled>
|
||||
去 CLI 目录看看
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
import { useState } from "react";
|
||||
import { Activity, Archive, ChevronRight, Lock, Plus } from "lucide-react";
|
||||
import { useEnv } from "../hooks/useEnv";
|
||||
import { useCatalog } from "../hooks/useCatalog";
|
||||
import { KpiCard } from "../components/KpiCard";
|
||||
import { MonoChip } from "../components/MonoChip";
|
||||
import { StatusBadge } from "../components/StatusBadge";
|
||||
import { CliMonogram } from "../components/CliMonogram";
|
||||
import type { PlatformEnv, RuntimeInfo } from "../ipc/types";
|
||||
|
||||
/** 平台相关运行时集合(Windows 不看 apt,Linux 不看 winget) */
|
||||
const WINDOWS_RUNTIMES = ["node", "npm", "python", "uv", "git", "winget"] as const;
|
||||
const LINUX_RUNTIMES = ["node", "npm", "python", "uv", "git", "apt"] as const;
|
||||
|
||||
function runtimeProblems(env: PlatformEnv): { name: string; info: RuntimeInfo }[] {
|
||||
const keys = env.os === "windows" ? WINDOWS_RUNTIMES : LINUX_RUNTIMES;
|
||||
const problems: { name: string; info: RuntimeInfo }[] = [];
|
||||
for (const key of keys) {
|
||||
const info = env.runtimes[key];
|
||||
if (info && info.status !== "installed") {
|
||||
problems.push({ name: key, info });
|
||||
}
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
|
||||
function runtimeStatusText(status: string): string {
|
||||
switch (status) {
|
||||
case "not_in_path":
|
||||
return "不在 PATH";
|
||||
case "not_installed":
|
||||
return "未安装";
|
||||
case "exec_failed":
|
||||
return "执行失败";
|
||||
case "version_unparseable":
|
||||
return "版本未知";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
function RuntimeItem({ name, info }: { name: string; info: RuntimeInfo }) {
|
||||
const dotClass =
|
||||
info.status === "installed"
|
||||
? "status-dot ok"
|
||||
: info.status === "exec_failed"
|
||||
? "status-dot error"
|
||||
: "status-dot warn";
|
||||
return (
|
||||
<div className="runtime-item">
|
||||
<span className={dotClass} aria-hidden="true" />
|
||||
<span className="runtime-name">{name}</span>
|
||||
{info.version ? (
|
||||
<MonoChip>{info.version}</MonoChip>
|
||||
) : (
|
||||
<span className="runtime-missing">{runtimeStatusText(info.status)}</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EnvPanel() {
|
||||
const { env, loading, error } = useEnv();
|
||||
const [showAllPath, setShowAllPath] = useState(false);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<section className="panel env-panel">
|
||||
<div className="panel-head">
|
||||
<h2 className="panel-title">本机环境</h2>
|
||||
</div>
|
||||
<p className="panel-empty">环境检测失败:{error}</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const pathPreview = env ? env.path_entries.slice(0, 8) : [];
|
||||
|
||||
return (
|
||||
<section className="panel env-panel">
|
||||
<div className="panel-head">
|
||||
<h2 className="panel-title">本机环境</h2>
|
||||
{loading && <span className="panel-hint">检测中…</span>}
|
||||
</div>
|
||||
{env && (
|
||||
<>
|
||||
<div className="env-grid">
|
||||
<div className="env-basic">
|
||||
<div className="env-row">
|
||||
<span className="env-key">系统</span>
|
||||
<span className="env-val">{env.os_version}</span>
|
||||
</div>
|
||||
<div className="env-row">
|
||||
<span className="env-key">架构</span>
|
||||
<span className="env-val">{env.arch}</span>
|
||||
</div>
|
||||
<div className="env-row">
|
||||
<span className="env-key">Shell</span>
|
||||
<span className="env-val">
|
||||
{env.shells.powershell_version ? (
|
||||
<>PowerShell <MonoChip>{env.shells.powershell_version}</MonoChip></>
|
||||
) : null}
|
||||
{env.shells.pwsh_version ? (
|
||||
<> · pwsh <MonoChip>{env.shells.pwsh_version}</MonoChip></>
|
||||
) : null}
|
||||
{env.shells.bash_available ? " · Bash ✓" : ""}
|
||||
</span>
|
||||
</div>
|
||||
<div className="env-row">
|
||||
<span className="env-key">密钥库</span>
|
||||
<span className="env-val">
|
||||
{env.capabilities.keyring === "ok" ? "Credential Manager ✓" : "密钥库缺失"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="env-row">
|
||||
<span className="env-key">提权</span>
|
||||
<span className="env-val">{env.capabilities.can_elevate ? "可用" : "不可用"}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="runtime-grid">
|
||||
{(["node", "npm", "python", "uv", "git", "winget", "apt"] as const).map(
|
||||
(key) => {
|
||||
const info = env.runtimes[key];
|
||||
if (!info) return null;
|
||||
return <RuntimeItem key={key} name={key} info={info} />;
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="path-block">
|
||||
<div className="path-head">
|
||||
<span className="path-title">
|
||||
PATH({env.path_entries.length} 条)
|
||||
<MonoChip>{env.path_entries.length}</MonoChip>
|
||||
</span>
|
||||
{env.path_entries.length > pathPreview.length && (
|
||||
<button
|
||||
type="button"
|
||||
className="link-btn"
|
||||
onClick={() => setShowAllPath((v) => !v)}
|
||||
>
|
||||
{showAllPath ? "收起" : "展开全部"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{(showAllPath ? env.path_entries : pathPreview).map((entry, idx) => (
|
||||
<div key={idx} className="path-entry">
|
||||
{entry}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/** 总览页(视觉规范 §3.1 + PRD §7):KPI + 最近诊断/快速操作 + CLI 状态网格 + 本机环境 */
|
||||
export function OverviewPage() {
|
||||
const { env } = useEnv();
|
||||
const { entries } = useCatalog();
|
||||
|
||||
const warningCount = env ? runtimeProblems(env).length : 0;
|
||||
const warningNames = env ? runtimeProblems(env).map((p) => p.name) : [];
|
||||
|
||||
return (
|
||||
<div className="overview">
|
||||
{/* ① KPI 一排 4 张 */}
|
||||
<section className="kpi-grid" aria-label="概览指标">
|
||||
<KpiCard label="已安装" value={0} tone="primary" subtitle="暂无已安装 CLI" />
|
||||
<KpiCard label="待授权" value={0} tone="attention" subtitle="暂无待授权项" />
|
||||
<KpiCard label="可更新" value={0} tone="accent" subtitle="暂无可用更新" />
|
||||
<KpiCard
|
||||
label="环境异常"
|
||||
value={warningCount}
|
||||
tone="warning"
|
||||
subtitle={warningCount > 0 ? warningNames.join(" · ") : "环境正常"}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{/* ② 中段:左 2/3 最近诊断 + 右 1/3 快速操作 */}
|
||||
<section className="overview-mid">
|
||||
<div className="panel diag-panel">
|
||||
<div className="panel-head">
|
||||
<h2 className="panel-title">最近诊断</h2>
|
||||
<button type="button" className="link-btn">
|
||||
查看全部 <ChevronRight size={14} strokeWidth={1.5} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
<ul className="diag-list">
|
||||
<li className="diag-row">
|
||||
<span className="status-dot ok" aria-hidden="true" />
|
||||
<span className="diag-cli">检测引擎</span>
|
||||
<span className="diag-text">诊断功能将在 Wave 1 接入</span>
|
||||
<span className="diag-time">刚刚</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="panel quick-card">
|
||||
<h2 className="panel-title">快速操作</h2>
|
||||
<button type="button" className="btn btn-primary" disabled>
|
||||
<Plus size={16} strokeWidth={1.5} aria-hidden="true" /> 添加 CLI
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" disabled>
|
||||
<Activity size={16} strokeWidth={1.5} aria-hidden="true" /> 立即诊断
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" disabled>
|
||||
<Archive size={16} strokeWidth={1.5} aria-hidden="true" /> 创建备份
|
||||
</button>
|
||||
<div className="recent-installs">
|
||||
<div className="group-label">最近安装</div>
|
||||
<p className="group-empty">暂无记录</p>
|
||||
</div>
|
||||
<p className="safety-note">
|
||||
<Lock size={12} strokeWidth={1.5} aria-hidden="true" />
|
||||
所有操作在本地完成,密钥只存系统保险柜,不上传。
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* ③ 下段:CLI 状态网格通栏 */}
|
||||
<section className="panel cli-status-panel">
|
||||
<div className="panel-head">
|
||||
<h2 className="panel-title">CLI 状态</h2>
|
||||
<button type="button" className="link-btn">
|
||||
管理全部 {entries.length} 个
|
||||
<ChevronRight size={14} strokeWidth={1.5} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="cli-status-grid">
|
||||
{entries.map((entry) => (
|
||||
<div className="cli-block" key={entry.id}>
|
||||
<div className="cli-block-top">
|
||||
<CliMonogram name={entry.name} size={32} />
|
||||
<span className="cli-block-name">{entry.name_zh}</span>
|
||||
<StatusBadge kind="uninstalled" label="未安装" />
|
||||
</div>
|
||||
<div className="cli-block-version">
|
||||
<MonoChip>—</MonoChip>
|
||||
</div>
|
||||
<div className="cli-block-auth">
|
||||
<span className="status-dot unknown" aria-hidden="true" />
|
||||
<span>未检测 · 可一键安装</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* ④ 本机环境(真实检测结果,架构 §5) */}
|
||||
<EnvPanel />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Settings } from "lucide-react";
|
||||
|
||||
/** 设置(PRD §7):下载源策略 / 自动检查更新 / 语言 / 日志与隐私。Wave 0 静态占位。 */
|
||||
export function SettingsPage() {
|
||||
return (
|
||||
<div className="settings-page">
|
||||
<h2 className="panel-title">常规</h2>
|
||||
<div className="settings-group">
|
||||
<div className="setting-row">
|
||||
<div className="setting-info">
|
||||
<div className="setting-label">下载源策略</div>
|
||||
<div className="setting-hint">选择 CLI 安装时的首选下载渠道(Wave 1 生效)</div>
|
||||
</div>
|
||||
<span className="setting-value">官方渠道</span>
|
||||
</div>
|
||||
<div className="setting-row">
|
||||
<div className="setting-info">
|
||||
<div className="setting-label">自动检查更新</div>
|
||||
<div className="setting-hint">启动时检查 AgentDock 自身与 CLI 的更新(Wave 4 生效)</div>
|
||||
</div>
|
||||
<span className="setting-value">开</span>
|
||||
</div>
|
||||
<div className="setting-row">
|
||||
<div className="setting-info">
|
||||
<div className="setting-label">语言</div>
|
||||
<div className="setting-hint">第一版仅提供简体中文</div>
|
||||
</div>
|
||||
<span className="setting-value">简体中文</span>
|
||||
</div>
|
||||
<div className="setting-row">
|
||||
<div className="setting-info">
|
||||
<div className="setting-label">日志与隐私</div>
|
||||
<div className="setting-hint">日志本地保存,敏感值自动脱敏(Wave 1 生效)</div>
|
||||
</div>
|
||||
<span className="setting-value">默认</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings-page-foot">
|
||||
<Settings size={14} strokeWidth={1.5} aria-hidden="true" />
|
||||
AgentDock v0.1.0 · 本地运行 · 不上传任何数据
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user