feat(desktop): 命令面板 ⌘K —— 键盘优先工作站入口

Pillar ① 交互骨架升级第一步:全局命令面板。

- components/CommandPalette.tsx:⌘K/Ctrl+K 唤起,搜索 + 多词子串过滤 + 分组(页面/动作)
  + 键盘上下选择 + Enter 执行 + Esc 关闭 + 选中项滚动入视野,纯前端两模式通用。
- App:全局 keydown 监听切换面板;命令清单(8 个页面跳转 + 生成报告/入库知识/新建编排动作)。
- TopBar:加「搜索与命令 ⌘K」触发 pill。

验证(Preview):⌘K/点 pill 唤起 → 输入“报告”过滤出 2 条 → 点「前往·报告生成」自动跳转
报告页并关闭面板。tsc + vite build 通过;重建 .app 重启原生窗口。

注:OS 级全局唤起(⌥Space 后台常驻 + 系统托盘)受 Wails v2 主线程模型限制(与
golang.design/x/hotkey 抢主线程冲突),留作 Wails v3 / cgo 助手的后续,不在本次。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-06-13 14:32:36 +08:00
parent 72e008bfe8
commit 84efa0a11c
3 changed files with 156 additions and 4 deletions
+12 -2
View File
@@ -1,5 +1,5 @@
import type { CSSProperties } from "react";
import { User, ChevronDown } from "lucide-react";
import { User, ChevronDown, Search as SearchIcon } from "lucide-react";
import type { Identity } from "../lib/api";
import { useHealth } from "../lib/health";
import { isMacDesktop } from "../lib/desktop";
@@ -20,7 +20,7 @@ function Light({ on, label }: { on: boolean; label: string }) {
}
// 顶栏:品牌 · 垂直切换 · 健康灯 · 身份/会话(深色 + 毛玻璃)。
export function TopBar({ identity, setIdentity }: { identity: Identity; setIdentity: (id: Identity) => void }) {
export function TopBar({ identity, setIdentity, onCommand }: { identity: Identity; setIdentity: (id: Identity) => void; onCommand?: () => void }) {
const h = useHealth();
return (
<header
@@ -44,6 +44,16 @@ export function TopBar({ identity, setIdentity }: { identity: Identity; setIdent
</select>
<ChevronDown className="pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-500" />
</div>
<button
onClick={onCommand}
style={NODRAG}
className="flex items-center gap-2 rounded-md border border-line bg-ink-800 px-2.5 py-1 text-xs text-slate-400 transition hover:border-ink-600 hover:text-slate-200"
title="命令面板"
>
<SearchIcon className="h-3.5 w-3.5" />
<kbd className="rounded border border-line px-1 font-mono text-[10px] text-slate-500">K</kbd>
</button>
<div className="ml-2 flex items-center gap-3">
<Light on={h.gateway} label="Gateway" />
<Light on={h.db} label="DB" />