feat(desktop): 工业化升级 B —— 真桌面集成(Wails Go 桥 + 原生能力)
让它真正像桌面 App 而非套壳网页:启用闲置的 Wails Go 桥,接原生文件框/系统打开/ 通知/无边框标题栏,且全部对浏览器预览(make web)优雅降级。 - app.go:SaveReportAs(原生"另存为"框 + 下载落盘)、OpenReport(下到临时目录 + 系统默认应用打开 docx)、Notify(macOS osascript 通知)、download/openInSystem 跨平台 - main.go:macOS TitleBarHiddenInset —— 隐藏标题栏、内容铺满到顶、保留红绿灯交通灯 - lib/desktop.ts:window.go.main.App 运行时桥 + isDesktop/isMacDesktop 探测; saveReportAs/openReport/notify 在无 Wails(浏览器)时分别降级为 <a download>/新标签/Toast - ReportView:桌面端「另存为 Word」(原生框) +「用系统打开」+ 完成弹系统通知; 浏览器端保持「下载 Word」 - KbView:拖拽文件入库(HTML5 dataTransfer,两种模式通用)+ 拖拽高亮 +「选择文件」按钮 - TopBar:顶栏设为 Wails 可拖拽区(--wails-draggable),控件标 no-drag; macOS 桌面端左留白让位交通灯 验证:GOWORK=off wails build 打出 .app(绑定生成 + mac 标题栏);启动真实原生窗口 截图确认无边框标题栏 + 交通灯内嵌 + 顶栏可拖拽(见会话截图);浏览器(Preview)确认 window.go 不存在时降级正确(下载链路 + 拖拽占位)。tsc + vite build 通过。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import type { CSSProperties } from "react";
|
||||
import { User, ChevronDown } from "lucide-react";
|
||||
import type { Identity } from "../lib/api";
|
||||
import { useHealth } from "../lib/health";
|
||||
import { isMacDesktop } from "../lib/desktop";
|
||||
import { cn } from "../ui";
|
||||
|
||||
// Wails 拖拽区/控件 CSS 变量(浏览器忽略,桌面端生效)。
|
||||
const DRAG = { "--wails-draggable": "drag" } as CSSProperties;
|
||||
const NODRAG = { "--wails-draggable": "no-drag" } as CSSProperties;
|
||||
|
||||
function Light({ on, label, unknown }: { on?: boolean; label: string; unknown?: boolean }) {
|
||||
const dot = unknown ? "bg-slate-600" : on ? "bg-success shadow-[0_0_8px_rgba(52,211,153,0.7)]" : "bg-danger";
|
||||
return (
|
||||
@@ -17,14 +23,17 @@ function Light({ on, label, unknown }: { on?: boolean; label: string; unknown?:
|
||||
export function TopBar({ identity, setIdentity }: { identity: Identity; setIdentity: (id: Identity) => void }) {
|
||||
const h = useHealth();
|
||||
return (
|
||||
<header className="flex h-12 shrink-0 items-center gap-3 border-b border-line bg-ink-900/80 px-3 backdrop-blur">
|
||||
<header
|
||||
style={DRAG}
|
||||
className={cn("flex h-12 shrink-0 items-center gap-3 border-b border-line bg-ink-900/80 pr-3 backdrop-blur", isMacDesktop() ? "pl-20" : "pl-3")}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex h-6 w-6 items-center justify-center rounded-md bg-gradient-to-br from-brand to-accent text-xs font-bold text-white">
|
||||
S
|
||||
</div>
|
||||
<span className="brand-gradient text-sm font-semibold">sundynix-agentix</span>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<div className="relative" style={NODRAG}>
|
||||
<select
|
||||
className="appearance-none rounded-md border border-line bg-ink-800 py-1 pl-2.5 pr-7 text-xs text-slate-300 focus:border-brand focus:outline-none"
|
||||
defaultValue="通用版"
|
||||
@@ -42,7 +51,7 @@ export function TopBar({ identity, setIdentity }: { identity: Identity; setIdent
|
||||
<Light unknown label="Milvus" />
|
||||
<Light unknown label="Neo4j" />
|
||||
</div>
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
<div className="ml-auto flex items-center gap-2" style={NODRAG}>
|
||||
<div className="relative">
|
||||
<User className="pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-500" />
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user