2026-07-20 12:34:56 +08:00
|
|
|
|
import { invoke } from "@tauri-apps/api/core";
|
2026-07-20 16:28:42 +08:00
|
|
|
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
2026-07-18 20:34:47 +08:00
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
|
|
|
|
|
2026-07-20 11:31:41 +08:00
|
|
|
|
import { ChatPanel } from "./features/chat/ChatPanel";
|
|
|
|
|
|
import { StatusBubble } from "./features/chat/StatusBubble";
|
2026-07-18 23:36:59 +08:00
|
|
|
|
import { ProfileManager } from "./features/profiles/ProfileManager";
|
2026-07-20 12:36:20 +08:00
|
|
|
|
import { PetPackImporter } from "./features/pet/PetPackImporter";
|
2026-07-18 22:17:29 +08:00
|
|
|
|
import { bootstrapStatusSchema, type BootstrapStatus } from "./types/bootstrap";
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
type PageKey = "chat" | "connections" | "desktop" | "pet" | "diagnostics";
|
|
|
|
|
|
type ChatLayout = "single" | "focus-companion" | "focus-operations";
|
|
|
|
|
|
type ChatSlot = "companion" | "operations";
|
|
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
const initialStatus: BootstrapStatus = {
|
|
|
|
|
|
appVersion: "unknown",
|
|
|
|
|
|
platform: "unknown",
|
|
|
|
|
|
rustCore: "pending",
|
|
|
|
|
|
protocolVersion: "desktop-v1alpha1",
|
2026-07-20 11:31:41 +08:00
|
|
|
|
databaseSchemaVersion: 4,
|
2026-07-18 20:34:47 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const navigation: Array<{ key: PageKey; label: string; description: string }> =
|
|
|
|
|
|
[
|
|
|
|
|
|
{ key: "chat", label: "聊天", description: "陪伴与运维对话" },
|
|
|
|
|
|
{ key: "connections", label: "连接", description: "实例与槽位管理" },
|
|
|
|
|
|
{ key: "desktop", label: "桌面行为", description: "快速聊天与状态气泡" },
|
|
|
|
|
|
{ key: "pet", label: "桌宠", description: "形象与活动范围" },
|
|
|
|
|
|
{
|
|
|
|
|
|
key: "diagnostics",
|
|
|
|
|
|
label: "诊断与设置",
|
|
|
|
|
|
description: "运行状态与安全边界",
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
export function App() {
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
|
|
const view = params.get("view");
|
2026-07-20 11:31:41 +08:00
|
|
|
|
const isQuickView = view === "quick";
|
|
|
|
|
|
const isBubbleView = view === "bubble";
|
2026-07-20 16:28:42 +08:00
|
|
|
|
const isPetView = view === "pet";
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const quickSlot = params.get("slot");
|
|
|
|
|
|
const [page, setPage] = useState<PageKey>("chat");
|
2026-07-18 20:34:47 +08:00
|
|
|
|
const [status, setStatus] = useState(initialStatus);
|
|
|
|
|
|
const [error, setError] = useState<string | null>(null);
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const [chatLayout, setChatLayout] = useState<ChatLayout>("single");
|
|
|
|
|
|
const [quickTarget, setQuickTarget] = useState<ChatSlot>(() =>
|
|
|
|
|
|
localStorage.getItem("astrbot.quickTarget") === "operations"
|
|
|
|
|
|
? "operations"
|
|
|
|
|
|
: "companion",
|
2026-07-20 12:34:56 +08:00
|
|
|
|
);
|
|
|
|
|
|
const [bubbleTarget, setBubbleTarget] = useState<"main" | "quick">(() =>
|
|
|
|
|
|
localStorage.getItem("astrbot.bubbleTarget") === "quick" ? "quick" : "main",
|
|
|
|
|
|
);
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
|
|
|
|
|
const refreshStatus = useCallback(async () => {
|
|
|
|
|
|
try {
|
2026-07-18 22:17:29 +08:00
|
|
|
|
const result = await invoke<unknown>("bootstrap_status");
|
|
|
|
|
|
setStatus(bootstrapStatusSchema.parse(result));
|
2026-07-18 20:34:47 +08:00
|
|
|
|
setError(null);
|
|
|
|
|
|
} catch (reason) {
|
|
|
|
|
|
setError(reason instanceof Error ? reason.message : String(reason));
|
|
|
|
|
|
}
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
void refreshStatus();
|
|
|
|
|
|
}, [refreshStatus]);
|
|
|
|
|
|
|
2026-07-20 11:31:41 +08:00
|
|
|
|
if (isBubbleView) return <StatusBubble />;
|
2026-07-20 16:28:42 +08:00
|
|
|
|
if (isPetView) return <DesktopPetView />;
|
2026-07-20 12:58:42 +08:00
|
|
|
|
if (isQuickView) {
|
2026-07-20 11:31:41 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<main className="quick-app-shell">
|
2026-07-20 12:34:56 +08:00
|
|
|
|
<ChatPanel
|
|
|
|
|
|
fixedSlot={
|
|
|
|
|
|
quickSlot === "operations"
|
|
|
|
|
|
? "operations"
|
|
|
|
|
|
: quickSlot === "companion"
|
|
|
|
|
|
? "companion"
|
|
|
|
|
|
: undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-07-20 11:31:41 +08:00
|
|
|
|
</main>
|
|
|
|
|
|
);
|
2026-07-20 12:58:42 +08:00
|
|
|
|
}
|
2026-07-20 11:31:41 +08:00
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<main className="app-shell">
|
2026-07-20 12:58:42 +08:00
|
|
|
|
<aside className="app-sidebar">
|
|
|
|
|
|
<div className="brand-lockup">
|
|
|
|
|
|
<div className="brand-mark">A</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<strong>AstrBot Desktop</strong>
|
|
|
|
|
|
<span>Companion workspace</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<nav className="primary-nav" aria-label="主导航">
|
|
|
|
|
|
{navigation.map((item) => (
|
|
|
|
|
|
<button
|
|
|
|
|
|
key={item.key}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
className={page === item.key ? "nav-item active" : "nav-item"}
|
|
|
|
|
|
onClick={() => setPage(item.key)}
|
|
|
|
|
|
>
|
|
|
|
|
|
<span className="nav-item-icon">{navIcon(item.key)}</span>
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<strong>{item.label}</strong>
|
|
|
|
|
|
<small>{item.description}</small>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
<div className="sidebar-footer">
|
|
|
|
|
|
<span className="connection-dot" />
|
|
|
|
|
|
<span>本地客户端已启动</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</aside>
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
<section className="app-content">
|
|
|
|
|
|
<PageHeader page={page} />
|
|
|
|
|
|
{error ? <p className="error-banner">IPC 暂不可用:{error}</p> : null}
|
|
|
|
|
|
{page === "chat" ? (
|
|
|
|
|
|
<ChatPage
|
|
|
|
|
|
chatLayout={chatLayout}
|
|
|
|
|
|
quickTarget={quickTarget}
|
|
|
|
|
|
onLayoutChange={setChatLayout}
|
|
|
|
|
|
onOpenQuickChat={() =>
|
|
|
|
|
|
void invoke("open_quick_chat_window", { slot: quickTarget })
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : null}
|
|
|
|
|
|
{page === "connections" ? <ProfileManager /> : null}
|
|
|
|
|
|
{page === "desktop" ? (
|
|
|
|
|
|
<DesktopBehaviorPage
|
|
|
|
|
|
bubbleTarget={bubbleTarget}
|
|
|
|
|
|
quickTarget={quickTarget}
|
|
|
|
|
|
onBubbleTargetChange={(value) => {
|
|
|
|
|
|
setBubbleTarget(value);
|
|
|
|
|
|
localStorage.setItem("astrbot.bubbleTarget", value);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onQuickTargetChange={(value) => {
|
|
|
|
|
|
setQuickTarget(value);
|
|
|
|
|
|
localStorage.setItem("astrbot.quickTarget", value);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onOpenQuickChat={() =>
|
|
|
|
|
|
void invoke("open_quick_chat_window", { slot: quickTarget })
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : null}
|
|
|
|
|
|
{page === "pet" ? <PetPage /> : null}
|
|
|
|
|
|
{page === "diagnostics" ? (
|
|
|
|
|
|
<DiagnosticsPage
|
|
|
|
|
|
status={status}
|
|
|
|
|
|
onRefresh={() => void refreshStatus()}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : null}
|
2026-07-18 20:34:47 +08:00
|
|
|
|
</section>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</main>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function navIcon(page: PageKey) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
chat: "⌁",
|
|
|
|
|
|
connections: "◎",
|
|
|
|
|
|
desktop: "◈",
|
|
|
|
|
|
pet: "✦",
|
|
|
|
|
|
diagnostics: "⚙",
|
|
|
|
|
|
}[page];
|
|
|
|
|
|
}
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function PageHeader({ page }: { page: PageKey }) {
|
|
|
|
|
|
const current = navigation.find((item) => item.key === page) ?? navigation[0];
|
|
|
|
|
|
return (
|
|
|
|
|
|
<header className="page-header">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<p className="eyebrow">AstrBot Desktop</p>
|
|
|
|
|
|
<h1>{current.label}</h1>
|
|
|
|
|
|
<p className="subtitle">
|
|
|
|
|
|
{current.description},所有本机能力都经过客户端权限边界。
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="header-status-pill">
|
|
|
|
|
|
<span className="connection-dot" />
|
|
|
|
|
|
双槽位架构
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ChatPage({
|
|
|
|
|
|
chatLayout,
|
|
|
|
|
|
quickTarget,
|
|
|
|
|
|
onLayoutChange,
|
|
|
|
|
|
onOpenQuickChat,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
chatLayout: ChatLayout;
|
|
|
|
|
|
quickTarget: ChatSlot;
|
|
|
|
|
|
onLayoutChange: (layout: ChatLayout) => void;
|
|
|
|
|
|
onOpenQuickChat: () => void;
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="page-stack">
|
|
|
|
|
|
<section className="welcome-card">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span className="section-kicker">Conversation hub</span>
|
|
|
|
|
|
<h2>今天想和哪个实例聊天?</h2>
|
|
|
|
|
|
<p>陪伴实例适合日常交流,运维实例用于经过确认的本机诊断提案。</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button type="button" onClick={onOpenQuickChat}>
|
2026-07-20 11:31:41 +08:00
|
|
|
|
打开快速聊天
|
|
|
|
|
|
</button>
|
2026-07-20 12:34:56 +08:00
|
|
|
|
</section>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
<section className="chat-workspace" aria-label="聊天工作区">
|
|
|
|
|
|
<div className="workspace-toolbar">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span className="section-kicker">Workspace view</span>
|
|
|
|
|
|
<strong>对话布局</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="segmented-control">
|
|
|
|
|
|
<LayoutButton
|
|
|
|
|
|
active={chatLayout === "single"}
|
|
|
|
|
|
onClick={() => onLayoutChange("single")}
|
|
|
|
|
|
>
|
|
|
|
|
|
单面板
|
|
|
|
|
|
</LayoutButton>
|
|
|
|
|
|
<LayoutButton
|
|
|
|
|
|
active={chatLayout === "focus-companion"}
|
|
|
|
|
|
onClick={() => onLayoutChange("focus-companion")}
|
|
|
|
|
|
>
|
|
|
|
|
|
聚焦陪伴
|
|
|
|
|
|
</LayoutButton>
|
|
|
|
|
|
<LayoutButton
|
|
|
|
|
|
active={chatLayout === "focus-operations"}
|
|
|
|
|
|
onClick={() => onLayoutChange("focus-operations")}
|
|
|
|
|
|
>
|
|
|
|
|
|
聚焦运维
|
|
|
|
|
|
</LayoutButton>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span className="toolbar-note">
|
|
|
|
|
|
快速聊天目标:{slotLabel(quickTarget)}
|
|
|
|
|
|
</span>
|
2026-07-20 12:30:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<ChatPanel
|
|
|
|
|
|
fixedSlot={
|
|
|
|
|
|
chatLayout === "focus-companion"
|
|
|
|
|
|
? "companion"
|
|
|
|
|
|
: chatLayout === "focus-operations"
|
|
|
|
|
|
? "operations"
|
|
|
|
|
|
: undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</section>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function LayoutButton({
|
|
|
|
|
|
active,
|
|
|
|
|
|
children,
|
|
|
|
|
|
onClick,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
active: boolean;
|
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
|
onClick: () => void;
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
className={active ? "segment active" : "segment"}
|
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
|
>
|
|
|
|
|
|
{children}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function DesktopBehaviorPage({
|
|
|
|
|
|
bubbleTarget,
|
|
|
|
|
|
quickTarget,
|
|
|
|
|
|
onBubbleTargetChange,
|
|
|
|
|
|
onQuickTargetChange,
|
|
|
|
|
|
onOpenQuickChat,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
bubbleTarget: "main" | "quick";
|
|
|
|
|
|
quickTarget: ChatSlot;
|
|
|
|
|
|
onBubbleTargetChange: (value: "main" | "quick") => void;
|
|
|
|
|
|
onQuickTargetChange: (value: ChatSlot) => void;
|
|
|
|
|
|
onOpenQuickChat: () => void;
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="page-stack">
|
|
|
|
|
|
<section className="settings-grid">
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="快速聊天"
|
|
|
|
|
|
description="设置气泡或快捷入口打开哪个实例。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<label>
|
|
|
|
|
|
<span>默认目标槽位</span>
|
|
|
|
|
|
<select
|
|
|
|
|
|
value={quickTarget}
|
|
|
|
|
|
onChange={(event) =>
|
|
|
|
|
|
onQuickTargetChange(event.target.value as ChatSlot)
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<option value="companion">陪伴实例</option>
|
|
|
|
|
|
<option value="operations">运维实例</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<button type="button" onClick={onOpenQuickChat}>
|
|
|
|
|
|
立即打开快速聊天
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</SettingCard>
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="状态气泡"
|
|
|
|
|
|
description="气泡显示连接状态,并根据这里的设置响应点击。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<label>
|
|
|
|
|
|
<span>点击气泡时</span>
|
|
|
|
|
|
<select
|
|
|
|
|
|
value={bubbleTarget}
|
|
|
|
|
|
onChange={(event) =>
|
|
|
|
|
|
onBubbleTargetChange(event.target.value as "main" | "quick")
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<option value="main">打开主界面</option>
|
|
|
|
|
|
<option value="quick">打开快速聊天</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<div className="status-preview">
|
|
|
|
|
|
<span className="connection-dot" />
|
|
|
|
|
|
气泡状态显示已预留
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</SettingCard>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
<section className="info-card">
|
|
|
|
|
|
<span className="section-kicker">Desktop companion</span>
|
|
|
|
|
|
<h2>后续桌面能力</h2>
|
|
|
|
|
|
<div className="feature-list">
|
|
|
|
|
|
<span>托盘与单实例</span>
|
|
|
|
|
|
<span>窗口置顶开关</span>
|
|
|
|
|
|
<span>多显示器策略</span>
|
|
|
|
|
|
<span>游戏模式靠边活动</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
这些能力先保留为独立设置区,后续接入 Rust
|
|
|
|
|
|
本机能力层,不会与聊天状态混在一起。
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function PetPage() {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="page-stack">
|
2026-07-20 12:36:20 +08:00
|
|
|
|
<PetPackImporter />
|
2026-07-20 12:58:42 +08:00
|
|
|
|
<section className="settings-grid">
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="显示范围"
|
|
|
|
|
|
description="决定桌宠只在应用内显示,还是允许在整个桌面活动。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<select defaultValue="app">
|
|
|
|
|
|
<option value="app">仅应用 UI 内</option>
|
|
|
|
|
|
<option value="desktop">整个桌面</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</SettingCard>
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="活动策略"
|
|
|
|
|
|
description="为后续游戏模式和双屏行为预留配置入口。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<select defaultValue="smart">
|
|
|
|
|
|
<option value="smart">智能选择显示器</option>
|
|
|
|
|
|
<option value="primary">固定主屏</option>
|
|
|
|
|
|
<option value="secondary">优先副屏</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</SettingCard>
|
2026-07-20 16:28:42 +08:00
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="运行桌宠"
|
|
|
|
|
|
description="桌宠窗口使用透明无边框模式,不创建任务栏按钮;关闭窗口后继续驻留托盘。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<button type="button" onClick={() => void invoke("open_pet_window")}>
|
|
|
|
|
|
打开桌宠
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</SettingCard>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</section>
|
|
|
|
|
|
</div>
|
2026-07-20 16:28:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function DesktopPetView() {
|
|
|
|
|
|
const [state, setState] = useState<"idle" | "working" | "resting" | "speaking">("idle");
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const states: Array<typeof state> = ["idle", "working", "resting", "speaking"];
|
|
|
|
|
|
const timer = window.setInterval(() => {
|
|
|
|
|
|
setState((current) => states[(states.indexOf(current) + 1) % states.length]);
|
|
|
|
|
|
}, 4200);
|
|
|
|
|
|
return () => window.clearInterval(timer);
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<main className={`pet-window pet-window-${state}`} aria-label="AstrBot 桌宠">
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
className="pet-window-close"
|
|
|
|
|
|
aria-label="隐藏桌宠"
|
|
|
|
|
|
onClick={() => void getCurrentWindow().close()}
|
|
|
|
|
|
>
|
|
|
|
|
|
×
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<div className="paper-pet" role="img" aria-label={`桌宠状态:${state}`}>
|
|
|
|
|
|
<div className="paper-pet-shadow" />
|
|
|
|
|
|
<div className="paper-pet-head">
|
|
|
|
|
|
<span className="paper-pet-ear left" />
|
|
|
|
|
|
<span className="paper-pet-ear right" />
|
|
|
|
|
|
<span className="paper-pet-eye left" />
|
|
|
|
|
|
<span className="paper-pet-eye right" />
|
|
|
|
|
|
<span className="paper-pet-mouth" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="paper-pet-body">
|
|
|
|
|
|
<span className="paper-pet-book" />
|
|
|
|
|
|
<span className="paper-pet-arm left" />
|
|
|
|
|
|
<span className="paper-pet-arm right" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span className="pet-window-status">{state === "working" ? "正在写写画画" : state === "resting" ? "休息中" : state === "speaking" ? "正在回应" : "陪伴中"}</span>
|
|
|
|
|
|
</main>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function DiagnosticsPage({
|
|
|
|
|
|
status,
|
|
|
|
|
|
onRefresh,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
status: BootstrapStatus;
|
|
|
|
|
|
onRefresh: () => void;
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="page-stack">
|
|
|
|
|
|
<section className="status-grid" aria-label="bootstrap status">
|
|
|
|
|
|
<StatusCard label="Rust Core" value={status.rustCore} />
|
|
|
|
|
|
<StatusCard label="Platform" value={status.platform} />
|
|
|
|
|
|
<StatusCard label="App Version" value={status.appVersion} />
|
|
|
|
|
|
<StatusCard label="Protocol" value={status.protocolVersion} />
|
|
|
|
|
|
<StatusCard
|
|
|
|
|
|
label="Database Schema"
|
|
|
|
|
|
value={String(status.databaseSchemaVersion)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
<section className="boundaries">
|
|
|
|
|
|
<span className="section-kicker">Security boundary</span>
|
|
|
|
|
|
<h2>本机能力保持可审计</h2>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
<li>凭据只在 Rust 与 Windows 安全存储之间流动。</li>
|
|
|
|
|
|
<li>两个 REST/SSE 槽位保持独立状态、会话、消息与未读数。</li>
|
|
|
|
|
|
<li>本机操作必须经过白名单、角色、路径和用户授权。</li>
|
|
|
|
|
|
<li>文件事务默认保留源文件,不静默覆盖目标。</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
<button type="button" onClick={onRefresh}>
|
|
|
|
|
|
刷新 IPC 状态
|
2026-07-18 20:34:47 +08:00
|
|
|
|
</button>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</div>
|
2026-07-18 20:34:47 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function SettingCard({
|
|
|
|
|
|
title,
|
|
|
|
|
|
description,
|
|
|
|
|
|
children,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
title: string;
|
|
|
|
|
|
description: string;
|
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<section className="setting-card">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span className="section-kicker">Settings</span>
|
|
|
|
|
|
<h2>{title}</h2>
|
|
|
|
|
|
<p>{description}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="setting-card-controls">{children}</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function slotLabel(slot: ChatSlot) {
|
|
|
|
|
|
return slot === "companion" ? "陪伴实例" : "运维实例";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
interface StatusCardProps {
|
|
|
|
|
|
label: string;
|
|
|
|
|
|
value: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
function StatusCard({ label, value }: StatusCardProps) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<article className="status-card">
|
|
|
|
|
|
<span>{label}</span>
|
|
|
|
|
|
<strong>{value}</strong>
|
|
|
|
|
|
</article>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|