# v2.1 — Wails Server Control Panel 設計規格
> 本章對應 R5-1 / R5-2 / R5-3 / R5-4 / R5-5 / R5-5a / **R5-D1 / R5-D3 / R5-E**(v2.1 補丁)
> 上層索引:`../design-spec-v2.md`
> 版本:**v2.1** · 更新日期:2026-04-14
> 相關:`v2/startup-progress.md`(R5-E 階段化啟動進度面板,Starting state 時顯示)
---
## 1. 定位與職責
Wails Server Control Panel(以下稱「控制台」)是 visionA-local 雙擊開啟後看到的**第一個畫面**,也是使用者**唯一可以關 server** 的地方。它的職責:
- Server lifecycle 管理:Start / Stop / Restart
- 即時 log 顯示、過濾、複製、匯出
- 一鍵開啟瀏覽器 Web UI
- 顯示 server 狀態(port、PID、uptime、version)
- 錯誤狀態的視覺呈現與自助排除入口
**控制台不做的事**(與 v1 清單一致、R5 複核):
- 不管 device、model、inference(那是 Web UI 的事)
- 不顯示 Mock 模式切換(R5-5:拿掉 Mock 切換)
- 不提供語言切換(跟隨系統 locale,見 §9)
- 不提供 Dark Mode 切換(跟隨系統)
---
## 2. 視窗規格
| 項目 | 值 | 說明 |
|------|----|------|
| 預設寬度 | `720 px` | log 一行約 90-100 字元可顯示 |
| 預設高度 | `560 px` | log 區塊可顯示 18-20 行 |
| 最小寬度 | `560 px` | 防止 primary controls 擠壞 |
| 最小高度 | `420 px` | log 區最少 6 行 |
| 可調整大小 | 是 | 拖角落縮放 |
| 最大化 | 保留 | |
| 最小化 | 保留 | |
| 置頂 | 否 | |
| Title bar | 原生 | 不做自訂 title bar |
| 視窗標題 | `visionA-local · Server Control` | |
| 視窗 icon | 沿用 `frontend/icon.png` | |
| 初始位置 | 螢幕中央(首次)/上次位置(後續) | 記憶寫到 `~/Library/Application Support/visiona-local/control-panel.json` |
---
## 3. 佈局 Wireframe(最終版)
```
┌───────────────────────────────────────────────────────────────────┐
│ ● visionA-local · Server Control [ − ][ □ ][ × ]│ ← Title bar(原生)
├───────────────────────────────────────────────────────────────────┤
│ │
│ ┌────┐ visionA-local v0.1.0 │
│ │LOGO│ ● Running · Browser opened │ ← Header
│ └────┘ Port: 3721 Uptime: 00:12:43 PID: 45821 │
│ │
├───────────────────────────────────────────────────────────────────┤
│ │
│ [ 🌐 Open in Browser ] [ Start ] [ ⋯ Manage ▾ ] │ ← Primary controls
│ │
│ ☑ Follow tail ☑ Show timestamps 🔍 [ Filter ... ] │ ← Log controls
│ │
├───────────────────────────────────────────────────────────────────┤
│ 10:23:41 INFO HTTP server listening on 127.0.0.1:3721 │
│ 10:23:41 INFO wails ipc ready │
│ 10:23:42 INFO device scan: found 1 Kneron KL520 │
│ 10:23:43 INFO GET /api/devices 200 (4ms) │ ← Log panel
│ 10:23:45 INFO GET /api/models 200 (2ms) │ (等寬字體
│ 10:23:58 WARN python sidecar restart (attempt 1) │ 可捲動
│ 10:23:59 INFO python sidecar ready │ 等級著色)
│ 10:24:12 INFO inference session start: classification │
│ ... │
│ │
│ │
├───────────────────────────────────────────────────────────────────┤
│ [ Clear ] [ Copy ] [ Export log ] [ Open log folder ] │ ← Log actions
│ │
│ Lines: 142 / 2000 ⚠ Closing this window will stop │ ← Footer
│ the server. │
└───────────────────────────────────────────────────────────────────┘
```
**和 v1 分析稿(`design-analysis-round2-refactor.md` §B2)的差異**:
- 拿掉 log 控制列上方「Mock 模式切換」區(v1 分析稿其實沒有這個,只是 `controlPanelSection` 清單有——R5-5a 確認砍)
- Primary controls 從 4 顆精簡為 3 顆(`Start` / `Stop` / `Restart` 三顆合併為 `Start` + overflow menu)
- Header 狀態列文字擴充,加入 "Browser opened"(首次 auto-open 後的視覺回饋,見 §5)
- Footer 新增「關閉視窗會停止 server」持久提示(R5-2 明確決策,用持久文字取代每次彈對話框)
---
## 4. 元件清單
### 4.1 Header(高度 80 px)
| 元素 | 類型 | 尺寸 / 位置 | 狀態 | 備註 |
|------|------|------------|------|------|
| Brand logo | `
` | 40×40 px,左側 padding 16 | static | 沿用 `frontend/icon.png` |
| Product name | `
` | 16 px / SemiBold | static | 文字:`visionA-local` |
| Version tag | `` | 12 px / muted-foreground | static | 文字:`v{major}.{minor}.{patch}`,右上角 |
| Status indicator | `` + `