阶段十:完成 Go Cmd Tools 注释基线清零

This commit is contained in:
Christ committed 2026-08-15 05:40:01 +08:00
1 parent 393c45a1e3
commit ea1f2ec430
25 files changed
+694 -4281

No files matched your search

+11
View File
@@ -8,15 +8,21 @@ import (
// icon.png 是从根目录 icon/windows/icon.png 同步的彩色产品图标,并直接嵌入托盘二进制。
//
// productIconPNG 保存productIconPNG,供当前处理流程使用
//
//go:embed icon.png
var productIconPNG []byte
// productIconGrayPNG 保存productIconGrayPNG,供当前处理流程使用
//
//go:embed icon-gray.png
var productIconGrayPNG []byte
// trayIconBytes 返回当前服务状态对应的图标,避免运行时依赖外部图标文件。
// Windows 的 Shell_NotifyIcon 需要 ICO;macOS/Linux 可以直接使用 PNG。
// trayIconBytes 负责trayIconBytes相关处理。
func trayIconBytes(running bool) []byte {
// data 保存数据,供当前处理流程使用
data := productIconGrayPNG
if running {
data = productIconPNG
@@ -27,14 +33,19 @@ func trayIconBytes(running bool) []byte {
return pngToICO(data, 256)
}
// pngToICO 负责pngToICO相关处理。
func pngToICO(data []byte, size int) []byte {
// headerSize 保存header数量,供当前处理流程使用
const headerSize = 6
// entrySize 保存entry数量,供当前处理流程使用
const entrySize = 16
// result 保存结果,供当前处理流程使用
result := make([]byte, headerSize+entrySize+len(data))
// ICONDIR: reserved, type=icon, image count=1.
binary.LittleEndian.PutUint16(result[0:2], 0)
binary.LittleEndian.PutUint16(result[2:4], 1)
binary.LittleEndian.PutUint16(result[4:6], 1)
// entry 保存entry,供当前处理流程使用
entry := result[headerSize : headerSize+entrySize]
if size >= 256 {
entry[0] = 0