feat(dcauth): 新增常驻托盘客户端与版本显示

Windows 改为单实例托盘常驻,协议唤起只弹一个确认窗口;补充 macOS 后台守护进程
与客户端版本显示。
This commit is contained in:
yml2213
2026-10-21 20:46:25 +08:00
parent 040100f290
commit cb916d7750
12 changed files with 1087 additions and 73 deletions
+2 -40
View File
@@ -15,7 +15,7 @@ import (
"time"
)
const clientVersion = "1.0.0"
const clientVersion = "1.1.0"
type appConfig struct {
DisplayName string
@@ -77,45 +77,7 @@ type authorizeRequest struct {
}
func main() {
registerProtocol()
identity, err := loadOrCreateIdentity()
if err != nil {
showError("DCAuth 初始化失败", err.Error())
return
}
protocolArg := findProtocolArg(os.Args[1:])
if protocolArg == "" {
text := fmt.Sprintf(
"设备码:%s\n机器码:%s\n\n设备码用于识别本机,机器码用于管理员核对。\n请从后台登录页点击“验证本机”完成登录。",
identity.deviceID,
identity.machineCode,
)
copyToClipboard(identity.deviceID + "\n" + identity.machineCode)
showInfo("DCAuth 设备信息", text+"\n\n设备码和机器码已复制到剪贴板。")
return
}
target, err := parseAuthorizeURL(protocolArg)
if err != nil {
showError("DCAuth 协议无效", err.Error())
return
}
app := appRegistry[target.App]
if !confirm(
app.DisplayName+" · 本机登录确认",
fmt.Sprintf("是否确认使用本机设备登录「%s」?\n\n设备码:%s\n机器码:%s", app.DisplayName, identity.deviceID, identity.machineCode),
) {
return
}
if err := submitAuthorization(identity, target); err != nil {
showError("本机验证失败", err.Error())
return
}
showInfo("本机验证成功", "已确认本机设备,请回到浏览器继续登录。")
runClient(findProtocolArg(os.Args[1:]))
}
type authorizeTarget struct {