新增: 自动升级体系 + WorkerW重建检测 + 知识卡片优化
自动升级: - 版本变量注入 (-ldflags -X main.version) - 远程 version.json 检查 + 弹窗提示(非强制右下角/强制居中) - updater.exe 嵌入主程序, 运行时释放到临时目录 - 下载+SHA256校验+备份+替换+回滚 全流程 - 托盘菜单"检查更新" 稳定性: - WorkerW 重建自动检测(每10s)并重新嵌入 - 左键托盘点击防抖 - 设置窗口已打开时正确前置 优化: - 知识卡片prompt改为面向开发者的硬核内容 - 配置目录统一到 ~/.u-desktop/ - 设置窗口WebView2数据目录改为configDir下
This commit is contained in:
34
settings.go
34
settings.go
@@ -104,10 +104,12 @@ func refreshVisibleCards(cfg, oldCfg *Config) {
|
||||
|
||||
func openSettingsWindow() {
|
||||
settingsMu.Lock()
|
||||
if settingsOpen && settingsHwnd != 0 {
|
||||
if settingsOpen {
|
||||
settingsMu.Unlock()
|
||||
procShowWindow.Call(settingsHwnd, 9)
|
||||
procGetForegroundWindow.Call(settingsHwnd)
|
||||
if settingsHwnd != 0 {
|
||||
procShowWindow.Call(settingsHwnd, 9)
|
||||
procGetForegroundWindow.Call(settingsHwnd)
|
||||
}
|
||||
return
|
||||
}
|
||||
settingsOpen = true
|
||||
@@ -123,7 +125,7 @@ func openSettingsWindow() {
|
||||
runtime.UnlockOSThread()
|
||||
}()
|
||||
|
||||
dataDir := filepath.Join(os.TempDir(), "u-desktop-settings")
|
||||
dataDir := filepath.Join(configDir(), "settings-data")
|
||||
os.MkdirAll(dataDir, 0755)
|
||||
|
||||
w := webview2.NewWithOptions(webview2.WebViewOptions{
|
||||
@@ -194,7 +196,7 @@ func openSettingsWindow() {
|
||||
"photoDir": cfg.PhotoDir,
|
||||
"photoInterval": cfg.PhotoInterval,
|
||||
"photoCard": !cfg.HidePhoto,
|
||||
"photoFrameMode": cfg.PhotoFrameMode,
|
||||
"photoFrameMode": cfg.PhotoFrameMode,
|
||||
"autoStart": isAutoStartEnabled(),
|
||||
})
|
||||
return string(data)
|
||||
@@ -252,13 +254,13 @@ func openSettingsWindow() {
|
||||
for _, card := range []string{"time", "weather", "zodiac", "ainews", "knowledge"} {
|
||||
evalJS(fmt.Sprintf("if(window.setCardVisible) setCardVisible('%s',false)", card))
|
||||
}
|
||||
} else {
|
||||
reloadWallpaper()
|
||||
}
|
||||
}
|
||||
if v, ok := data["photoCard"]; ok {
|
||||
cfg.HidePhoto = !v
|
||||
saveConfig(cfg)
|
||||
evalJS(fmt.Sprintf("if(window.setCardVisible) setCardVisible('photo',%v)", v))
|
||||
refreshVisibleCards(cfg, &oldCfg)
|
||||
if cfg.PhotoDir != "" {
|
||||
if v {
|
||||
restartPhotoLoop()
|
||||
@@ -266,10 +268,9 @@ func openSettingsWindow() {
|
||||
stopPhotoLoop()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
saveConfig(cfg)
|
||||
refreshVisibleCards(cfg, &oldCfg)
|
||||
}
|
||||
saveConfig(cfg)
|
||||
refreshVisibleCards(cfg, &oldCfg)
|
||||
return ""
|
||||
})
|
||||
|
||||
@@ -383,15 +384,15 @@ func openSettingsWindow() {
|
||||
|
||||
w.Bind("pickGradientColor", func() string {
|
||||
hwnd := uintptr(w.Window())
|
||||
c1 := colorPickerDialog(hwnd, "")
|
||||
cfg := loadConfig()
|
||||
c1 := colorPickerDialog(hwnd, cfg.Color1)
|
||||
if c1 == "" {
|
||||
return ""
|
||||
}
|
||||
c2 := colorPickerDialog(hwnd, "")
|
||||
c2 := colorPickerDialog(hwnd, cfg.Color2)
|
||||
if c2 == "" {
|
||||
c2 = "#16213e"
|
||||
}
|
||||
cfg := loadConfig()
|
||||
cfg.WallpaperType = WPColor
|
||||
cfg.Color1 = c1
|
||||
cfg.Color2 = c2
|
||||
@@ -494,9 +495,10 @@ func openSettingsWindow() {
|
||||
w.SetHtml(settingsHTML)
|
||||
|
||||
hwnd := uintptr(w.Window())
|
||||
// disable resize
|
||||
style, _, _ := procGetWindowLongPtrW.Call(hwnd, gwlStyle)
|
||||
procSetWindowLongPtrW.Call(hwnd, gwlStyle, style & ^uintptr(wsSizebox|wsMaxbox))
|
||||
// disable resize + hide from taskbar
|
||||
style, _, _ := procGetWindowLongPtrW.Call(hwnd, gwlStyle)
|
||||
procSetWindowLongPtrW.Call(hwnd, gwlStyle, style & ^uintptr(wsSizebox|wsMaxbox))
|
||||
procSetWindowLongPtrW.Call(hwnd, gwlExStyle, wsExToolwindow)
|
||||
|
||||
// resizeToFit: JS measures content, Go adjusts window frame
|
||||
w.Bind("resizeToFit", func(contentW, contentH int) string {
|
||||
|
||||
Reference in New Issue
Block a user