Wave 0.5: 4K 布局与空态修复(老板验收 15 条,视觉规范 v1.3)

This commit is contained in:
AgentDock 施工员
2026-08-25 01:04:14 +08:00
parent 7208586850
commit c47494180b
15 changed files with 560 additions and 206 deletions
+9 -4
View File
@@ -1,17 +1,22 @@
import { Archive } from "lucide-react";
/** 备份与迁移(PRD §7):创建备份、查看内容、恢复。Wave 0 占位。 */
/** 备份与迁移(PRD §7):创建备份、查看内容、恢复。空态按 v1.3 §3.7。 */
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>
<h2 className="placeholder-title">还没有可备份的内容</h2>
<p className="placeholder-desc">
备份功能在 Wave 4 落地。备份将明确标注是否包含敏感信息,密钥永不进备份。
安装 CLI 并完成配置后,可以在这里创建备份与迁移。密钥永不进备份。
</p>
<button type="button" className="btn btn-secondary" disabled>
<button
type="button"
className="btn btn-secondary"
disabled
title="安装 CLI 后才能创建备份"
>
创建备份
</button>
</div>
+2 -4
View File
@@ -2,7 +2,6 @@ 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";
@@ -90,17 +89,16 @@ export function CatalogPage() {
{filtered.map((entry) => (
<article className="catalog-card" key={entry.id}>
<div className="catalog-card-top">
<CliMonogram name={entry.name} size={40} />
<CliMonogram id={entry.id} 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>
<p className="catalog-card-desc">官方渠道安装 · 全平台支持</p>
<div className="catalog-card-bottom">
<StatusBadge kind="uninstalled" label="未安装" />
<span className="catalog-platforms">Windows · Linux</span>
<MonoChip>v1</MonoChip>
</div>
</article>
))}
+6 -5
View File
@@ -1,17 +1,18 @@
import { SlidersHorizontal } from "lucide-react";
import type { PageKey } from "../components/Sidebar";
/** 配置中心(PRD §7):按 CLI 展示中文配置表单。Wave 0 占位。 */
export function ConfigCenterPage() {
/** 配置中心(PRD §7):按 CLI 展示中文配置表单。空态按 v1.3 §3.7。 */
export function ConfigCenterPage({ onNavigate }: { onNavigate: (p: PageKey) => void }) {
return (
<div className="placeholder-page">
<div className="placeholder-icon">
<SlidersHorizontal size={40} strokeWidth={1.5} aria-hidden="true" />
</div>
<h2 className="placeholder-title">配置中心</h2>
<h2 className="placeholder-title">还没有可配置的 CLI</h2>
<p className="placeholder-desc">
中文配置表单在 Wave 2 落地。敏感字段将使用密码输入与系统密钥库。
安装 CLI 后,在这里用中文表单管理配置。敏感字段会用密码输入并存入系统密钥库。
</p>
<button type="button" className="btn btn-secondary" disabled>
<button type="button" className="btn btn-secondary" onClick={() => onNavigate("catalog")}>
选择 CLI 开始配置
</button>
</div>
+6 -5
View File
@@ -1,17 +1,18 @@
import { SquareTerminal } from "lucide-react";
import type { PageKey } from "../components/Sidebar";
/** 我的 CLI(PRD §7):版本 / 路径 / 授权状态。Wave 0 尚无已安装 CLI,展示空态。 */
export function MyCliPage() {
/** 我的 CLI(PRD §7):版本 / 路径 / 授权状态。空态按 v1.3 §3.7。 */
export function MyCliPage({ onNavigate }: { onNavigate: (p: PageKey) => void }) {
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>
<h2 className="placeholder-title">还没有安装任何 CLI</h2>
<p className="placeholder-desc">
安装功能在 Wave 1 开放。届时这里会展示每个 CLI 的版本、路径与授权状态。
安装后,这里会展示每个 CLI 的版本、路径与授权状态。
</p>
<button type="button" className="btn btn-primary" disabled>
<button type="button" className="btn btn-primary" onClick={() => onNavigate("catalog")}>
去 CLI 目录看看
</button>
</div>
+236 -94
View File
@@ -1,12 +1,13 @@
import { useState } from "react";
import { Activity, Archive, ChevronRight, Lock, Plus } from "lucide-react";
import { Activity, Archive, Lock, Plus, ScanSearch } 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";
import type { PlatformEnv, RuntimeInfo, RuntimeStatus, CatalogEntry } from "../ipc/types";
import type { PageKey } from "../components/Sidebar";
/** 平台相关运行时集合(Windows 不看 apt,Linux 不看 winget) */
const WINDOWS_RUNTIMES = ["node", "npm", "python", "uv", "git", "winget"] as const;
@@ -24,42 +25,61 @@ function runtimeProblems(env: PlatformEnv): { name: string; info: RuntimeInfo }[
return problems;
}
function runtimeStatusText(status: string): string {
/** 本机环境运行时项四元组(v1.3 §3.1.6):状态点 + 名称 + 版本位 + 行动位 */
function runtimeMeta(status: RuntimeStatus): {
dot: string;
missingText: string | null;
needsGuide: boolean;
} {
switch (status) {
case "not_in_path":
return "不在 PATH";
case "installed":
return { dot: "status-dot ok", missingText: null, needsGuide: false };
case "not_installed":
return "未安装";
return { dot: "status-dot unknown", missingText: "未检测到", needsGuide: true };
case "not_in_path":
return { dot: "status-dot warn breathe", missingText: "不在 PATH", needsGuide: false };
case "permission_denied":
return { dot: "status-dot warn breathe", missingText: "无访问权限", needsGuide: false };
case "exec_failed":
return "执行失败";
return { dot: "status-dot warn breathe", missingText: "执行失败", needsGuide: false };
case "version_unparseable":
return "版本未知";
return { dot: "status-dot warn breathe", missingText: "版本未知", needsGuide: false };
default:
return "未知";
return { dot: "status-dot unknown", missingText: "未知", needsGuide: false };
}
}
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";
function RuntimeItem({
name,
info,
onNavigate,
}: {
name: string;
info: RuntimeInfo;
onNavigate: (p: PageKey) => void;
}) {
const meta = runtimeMeta(info.status);
return (
<div className="runtime-item">
<span className={dotClass} aria-hidden="true" />
<span className={meta.dot} aria-hidden="true" />
<span className="runtime-name">{name}</span>
{info.version ? (
<MonoChip>{info.version}</MonoChip>
<span className="runtime-version">
<MonoChip>{info.version}</MonoChip>
</span>
) : (
<span className="runtime-missing">{runtimeStatusText(info.status)}</span>
<span className="runtime-missing">{meta.missingText}</span>
)}
{meta.needsGuide && (
<button type="button" className="link-btn runtime-action" onClick={() => onNavigate("catalog")}>
安装指引
</button>
)}
</div>
);
}
function EnvPanel() {
function EnvPanel({ onNavigate }: { onNavigate: (p: PageKey) => void }) {
const { env, loading, error } = useEnv();
const [showAllPath, setShowAllPath] = useState(false);
@@ -122,7 +142,7 @@ function EnvPanel() {
(key) => {
const info = env.runtimes[key];
if (!info) return null;
return <RuntimeItem key={key} name={key} info={info} />;
return <RuntimeItem key={key} name={key} info={info} onNavigate={onNavigate} />;
},
)}
</div>
@@ -155,100 +175,222 @@ function EnvPanel() {
);
}
/** 总览页(视觉规范 §3.1 + PRD §7):KPI + 最近诊断/快速操作 + CLI 状态网格 + 本机环境 */
export function OverviewPage() {
/** 首跑空态引导插画(v1.3 §7:等距线框终端 + 集装箱 Dock,1px 线,霓虹点缀) */
function OnboardingArt() {
return (
<svg width="200" height="150" viewBox="0 0 200 150" fill="none" aria-hidden="true">
<rect x="24" y="18" width="120" height="86" rx="8" stroke="currentColor" strokeWidth="1" />
<line x1="24" y1="40" x2="144" y2="40" stroke="currentColor" strokeWidth="1" />
<circle cx="36" cy="29" r="2" style={{ fill: "var(--ad-primary)" }} />
<circle cx="46" cy="29" r="2" fill="currentColor" opacity="0.55" />
<circle cx="56" cy="29" r="2" fill="currentColor" opacity="0.55" />
<rect x="36" y="52" width="58" height="6" rx="3" fill="currentColor" opacity="0.5" />
<rect x="36" y="66" width="84" height="6" rx="3" fill="currentColor" opacity="0.32" />
<rect x="36" y="80" width="46" height="6" rx="3" style={{ fill: "var(--ad-accent)" }} opacity="0.8" />
<rect x="24" y="116" width="36" height="26" rx="4" stroke="currentColor" strokeWidth="1" />
<rect x="66" y="116" width="36" height="26" rx="4" stroke="currentColor" strokeWidth="1" />
<rect x="108" y="116" width="36" height="26" rx="4" stroke="currentColor" strokeWidth="1" />
<line x1="24" y1="142" x2="144" y2="142" stroke="currentColor" strokeWidth="1" opacity="0.4" />
</svg>
);
}
/** 首跑引导区(v1.3 §3.1.5:插画 + 三句式文案 + 主行动按钮) */
function Onboarding({ onNavigate }: { onNavigate: (p: PageKey) => void }) {
return (
<div className="panel onboarding">
<div className="onboarding-art">
<OnboardingArt />
</div>
<div className="onboarding-copy">
<h2 className="onboarding-title">你的工具箱还是空的</h2>
<p className="onboarding-desc">
从目录安装第一个 Agent CLI,安装、配置、授权、诊断都帮你盯好。
</p>
<div className="onboarding-actions">
<button type="button" className="btn btn-primary" onClick={() => onNavigate("catalog")}>
浏览 CLI 目录
</button>
<button type="button" className="btn btn-secondary">
先诊断本机环境
</button>
</div>
</div>
</div>
);
}
/** 最近诊断卡(v1.3 §3.1.2:无记录时展示空态,不渲染占位行与「查看全部」) */
function DiagPanel() {
// Wave 0.5 尚无诊断引擎数据,恒为空态(语义按 §3.7,不虚构记录)
const records: { cli: string; text: string; time: string }[] = [];
return (
<div className="panel diag-panel">
<div className="panel-head">
<h2 className="panel-title">最近诊断</h2>
</div>
{records.length === 0 ? (
<div className="diag-empty">
<span className="diag-empty-text">暂无诊断记录</span>
<button type="button" className="btn btn-secondary">
<ScanSearch size={16} strokeWidth={1.5} aria-hidden="true" /> 立即诊断
</button>
</div>
) : (
<ul className="diag-list">
{records.map((r) => (
<li className="diag-row" key={r.cli}>
<span className="status-dot ok" aria-hidden="true" />
<span className="diag-cli">{r.cli}</span>
<span className="diag-text">{r.text}</span>
<span className="diag-time">{r.time}</span>
</li>
))}
</ul>
)}
</div>
);
}
/** 快速操作卡(v1.3 §3.1.3:三按钮竖向操作组,创建备份依赖数据置灰) */
function QuickActions({
firstRun,
onNavigate,
}: {
firstRun: boolean;
onNavigate: (p: PageKey) => void;
}) {
return (
<div className="panel quick-card">
<h2 className="panel-title">快速操作</h2>
<button type="button" className="btn btn-primary" onClick={() => onNavigate("catalog")}>
<Plus size={16} strokeWidth={1.5} aria-hidden="true" /> 添加 CLI
</button>
<button type="button" className="btn btn-secondary">
<Activity size={16} strokeWidth={1.5} aria-hidden="true" /> 立即诊断
</button>
<button
type="button"
className="btn btn-secondary"
disabled
title={firstRun ? "安装 CLI 后才能创建备份" : "暂无内容可备份"}
>
<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>
);
}
/** CLI 状态网格块(v1.3 §3.1.4;首跑精简为两行 + 安装入口,§3.1.5) */
function CliBlock({
entry,
compact,
onNavigate,
}: {
entry: CatalogEntry;
compact: boolean;
onNavigate: (p: PageKey) => void;
}) {
const installed = entry.status === "installed";
return (
<div className="cli-block">
<div className="cli-block-top">
<CliMonogram id={entry.id} name={entry.name} size={32} />
<span className="cli-block-name">{entry.name_zh}</span>
<StatusBadge kind={installed ? "installed" : "uninstalled"} label={installed ? "已安装" : "未安装"} />
</div>
<div className="cli-block-version">
{installed ? null : <span className="version-missing">未安装</span>}
</div>
{!compact && (
<div className="cli-block-auth">
{installed ? (
<>
<span className="status-dot ok" aria-hidden="true" />
<span>已安装</span>
</>
) : (
<>
<span className="status-dot unknown" aria-hidden="true" />
<span>未检测 · 安装后自动检测</span>
</>
)}
</div>
)}
{compact && (
<div className="cli-block-install">
<button type="button" className="link-btn" onClick={() => onNavigate("catalog")}>
安装
</button>
</div>
)}
</div>
);
}
interface OverviewProps {
onNavigate: (p: PageKey) => void;
}
/** 总览页(视觉规范 §3.1 + PRD §7):首跑空态 / KPI + 诊断/快速操作 + CLI 状态网格 + 本机环境 */
export function OverviewPage({ onNavigate }: OverviewProps) {
const { env } = useEnv();
const { entries } = useCatalog();
const installedCount = entries.filter((e) => e.status === "installed").length;
const firstRun = installedCount === 0; // 无安装且无诊断记录(当前无诊断引擎)
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>
{/* ① KPI 一排 4 张(首跑空态隐藏,v1.3 §3.1.5) */}
{!firstRun && (
<section className="kpi-grid" aria-label="概览指标">
<KpiCard label="已安装" value={installedCount} tone="primary" subtitle="暂无安装" action={{ label: "去目录看看", onClick: () => onNavigate("catalog") }} />
<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 快速操作 */}
{/* ② 中段:诊断/引导 + 快速操作(超宽三栏见 global.css) */}
<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>
{firstRun ? <Onboarding onNavigate={onNavigate} /> : <DiagPanel />}
<QuickActions firstRun={firstRun} onNavigate={onNavigate} />
</section>
{/* ③ 下段:CLI 状态网格通栏 */}
{/* ③ 下段: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>
<h2 className="panel-title">
{firstRun ? `可安装的 CLI(${entries.length})` : "CLI 状态"}
</h2>
{/* 「管理全部 N 个」入口:仅当未全量展示时才渲染(v1.3 §3.1.4),本页恒全量展示,故不渲染 */}
</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>
<CliBlock key={entry.id} entry={entry} compact={firstRun} onNavigate={onNavigate} />
))}
</div>
</section>
{/* ④ 本机环境(真实检测结果,架构 §5) */}
<EnvPanel />
{/* ④ 本机环境(真实检测结果,架构 §5;超宽断点上提为第三栏) */}
<EnvPanel onNavigate={onNavigate} />
</div>
);
}
+3 -3
View File
@@ -9,14 +9,14 @@ export function SettingsPage() {
<div className="setting-row">
<div className="setting-info">
<div className="setting-label">下载源策略</div>
<div className="setting-hint">选择 CLI 安装时的首选下载渠道(Wave 1 生效)</div>
<div className="setting-hint">选择 CLI 安装时的首选下载渠道</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 className="setting-hint">启动时检查 AgentDock 自身与 CLI 的更新</div>
</div>
<span className="setting-value">开</span>
</div>
@@ -30,7 +30,7 @@ export function SettingsPage() {
<div className="setting-row">
<div className="setting-info">
<div className="setting-label">日志与隐私</div>
<div className="setting-hint">日志本地保存,敏感值自动脱敏(Wave 1 生效)</div>
<div className="setting-hint">日志本地保存,敏感值自动脱敏</div>
</div>
<span className="setting-value">默认</span>
</div>