diff --git a/cmd/arcrun-app/build/trayicon.ico b/cmd/arcrun-app/build/trayicon.ico index 88fd04f..824f963 100644 Binary files a/cmd/arcrun-app/build/trayicon.ico and b/cmd/arcrun-app/build/trayicon.ico differ diff --git a/cmd/arcrun-app/build/windows/icon.ico b/cmd/arcrun-app/build/windows/icon.ico index f334798..b06a367 100644 Binary files a/cmd/arcrun-app/build/windows/icon.ico and b/cmd/arcrun-app/build/windows/icon.ico differ diff --git a/cmd/arcrun-app/gen-icons.py b/cmd/arcrun-app/gen-icons.py new file mode 100644 index 0000000..155d807 --- /dev/null +++ b/cmd/arcrun-app/gen-icons.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""gen-icons.py — 從 build/appicon.png 產生 Windows 用的 .ico(2026-08-06) + +🔴 為什麼要有這支: + leo 08-06 封測回報「托盤及視窗 icon 是『W』,不是 CIS 的 chevron 標誌(a>>)」。 + 真兇=`build/windows/icon.ico` 是 `wails init` 生成後**從沒被換過的 Wails 預設圖**; + 換 CIS logo 那次只換了 `build/appicon.png`,Windows 這顆沒人動。 + 而 `tray_windows.go` 又 embed 同一顆 ⇒ 視窗與托盤兩處都是 W。 + + 根治不是「這次手動換一顆」——是**讓它不可能再漂移**: + icon.ico/trayicon.ico 一律由 appicon.png 現場產生, + build-win.sh 每次都跑這支,check-cis.sh 驗「committed == 重新產生的」。 + +用法: + python3 gen-icons.py # 產生(覆寫) + python3 gen-icons.py --check # 只驗證,不寫檔;不一致回傳 1 +""" +import hashlib +import io +import sys +from pathlib import Path + +from PIL import Image + +HERE = Path(__file__).resolve().parent +SRC = HERE / "build" / "appicon.png" +APP_ICO = HERE / "build" / "windows" / "icon.ico" +TRAY_ICO = HERE / "build" / "trayicon.ico" + +# 視窗/工作列/檔案總管會用到的完整尺寸階梯。 +APP_SIZES = [16, 24, 32, 48, 64, 128, 256] +# 系統匣只吃小尺寸(Windows 依 DPI 取 16 或 32)。 +TRAY_SIZES = [16, 24, 32, 48] + + +def render(sizes): + """把 appicon.png 縮成多尺寸,包成一顆 .ico。""" + if not SRC.exists(): + sys.exit("❌ 找不到來源圖:%s" % SRC) + src = Image.open(SRC).convert("RGBA") + buf = io.BytesIO() + # Pillow 的 ICO 儲存會自己依 sizes 產生各層。 + src.save(buf, format="ICO", sizes=[(s, s) for s in sizes]) + return buf.getvalue() + + +def main(): + check_only = "--check" in sys.argv + fail = 0 + targets = ((APP_ICO, APP_SIZES, "視窗/工作列 icon"), + (TRAY_ICO, TRAY_SIZES, "系統匣 icon")) + for path, sizes, label in targets: + want = render(sizes) + have = path.read_bytes() if path.exists() else b"" + if check_only: + if hashlib.sha256(want).digest() == hashlib.sha256(have).digest(): + print(" ✅ %s(%s)與 appicon.png 一致" % (label, path.name)) + else: + print(" ❌ %s(%s)與 appicon.png 不一致 " + "⇒ 跑 `python3 gen-icons.py` 重產" % (label, path.name)) + fail = 1 + else: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(want) + print(" ✅ 產生 %s(%d bytes,%d 種尺寸)" + % (path.relative_to(HERE), len(want), len(sizes))) + return fail + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/cmd/arcrun-app/tray_windows.go b/cmd/arcrun-app/tray_windows.go index 6bd4b50..62dfade 100644 --- a/cmd/arcrun-app/tray_windows.go +++ b/cmd/arcrun-app/tray_windows.go @@ -30,9 +30,14 @@ import ( var trayApp *App // Windows 系統匣要 .ico(PNG 會顯示成空白/方塊)。 -// build/windows/icon.ico 是 Wails 產生 exe 圖示用的同一顆,一併拿來當托盤圖。 // -//go:embed build/windows/icon.ico +// 🔴 2026-08-06:這裡以前 embed `build/windows/icon.ico`,而那顆是 `wails init` 留下的 +// **Wails 預設「W」圖**(換 CIS logo 時只換了 appicon.png,沒人動它) +// ⇒ leo 封測看到視窗與托盤兩處都是「W」。 +// 現在兩顆 .ico 都由 `gen-icons.py` 從 `build/appicon.png` 現場產生(build-win.sh 會跑), +// 這裡改用小尺寸階梯的 trayicon.ico——系統匣只吃 16/32,塞 256 的那顆是浪費。 +// +//go:embed build/trayicon.ico var trayIconICO []byte // setupTray 建立系統匣圖示。