feat(dcauth): 新增常驻托盘客户端与版本显示
Windows 改为单实例托盘常驻,协议唤起只弹一个确认窗口;补充 macOS 后台守护进程 与客户端版本显示。
This commit is contained in:
+39
-1
@@ -1,4 +1,4 @@
|
||||
//go:build !windows
|
||||
//go:build !windows && !darwin
|
||||
|
||||
package main
|
||||
|
||||
@@ -7,6 +7,44 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func runClient(protocolArg string) {
|
||||
identity, err := loadOrCreateIdentity()
|
||||
if err != nil {
|
||||
showError("DCAuth 初始化失败", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if protocolArg == "" {
|
||||
text := fmt.Sprintf(
|
||||
"DCAuth v%s\n设备码:%s\n机器码:%s\n\n设备码用于识别本机,机器码用于管理员核对。\n请从后台登录页点击“验证本机”完成登录。",
|
||||
clientVersion,
|
||||
identity.deviceID,
|
||||
identity.machineCode,
|
||||
)
|
||||
copyToClipboard(identity.deviceID + "\n" + identity.machineCode)
|
||||
showInfo("DCAuth v"+clientVersion+" 设备信息", 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("本机验证成功", "已确认本机设备,请回到浏览器继续登录。")
|
||||
}
|
||||
|
||||
func showInfo(title, text string) {
|
||||
fmt.Printf("[%s]\n%s\n", title, text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user