Compare commits
3
Commits
370a94749a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec52bb12da | ||
|
|
b0edb189b9 | ||
|
|
983c3e1dfd |
@@ -31,6 +31,7 @@ type App struct {
|
|||||||
previousAction *walk.Action
|
previousAction *walk.Action
|
||||||
nextAction *walk.Action
|
nextAction *walk.Action
|
||||||
settingsAction *walk.Action
|
settingsAction *walk.Action
|
||||||
|
settingsDialog *walk.Dialog
|
||||||
timerMu sync.Mutex
|
timerMu sync.Mutex
|
||||||
timer *time.Timer
|
timer *time.Timer
|
||||||
busy atomic.Bool
|
busy atomic.Bool
|
||||||
@@ -42,14 +43,13 @@ func newApp(mw *walk.MainWindow, appDir string, cfg Config, cache *CacheIndex) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
icon, err := walk.NewIconFromSysDLL("shell32.dll", 4)
|
icon, err := walk.NewIconFromSysDLL("shell32", 4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ni.Dispose()
|
icon = walk.IconApplication()
|
||||||
return nil, fmt.Errorf("加载托盘图标: %w", err)
|
|
||||||
}
|
}
|
||||||
if err := ni.SetIcon(icon); err != nil {
|
if err := ni.SetIcon(icon); err != nil {
|
||||||
ni.Dispose()
|
ni.Dispose()
|
||||||
return nil, err
|
return nil, fmt.Errorf("设置托盘图标: %w", err)
|
||||||
}
|
}
|
||||||
if err := ni.SetToolTip(appName + " - 右键打开菜单"); err != nil {
|
if err := ni.SetToolTip(appName + " - 右键打开菜单"); err != nil {
|
||||||
ni.Dispose()
|
ni.Dispose()
|
||||||
@@ -195,8 +195,6 @@ func (a *App) refresh(automatic bool) {
|
|||||||
a.setBusy(false)
|
a.setBusy(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.notifyError("刷新壁纸失败:" + err.Error())
|
a.notifyError("刷新壁纸失败:" + err.Error())
|
||||||
} else {
|
|
||||||
_ = a.notifyIcon.ShowInfo(appName, "壁纸已刷新。")
|
|
||||||
}
|
}
|
||||||
if automatic {
|
if automatic {
|
||||||
a.scheduleTimer()
|
a.scheduleTimer()
|
||||||
@@ -233,7 +231,6 @@ func (a *App) moveHistory(direction int) {
|
|||||||
a.notifyError("切换壁纸失败:" + err.Error())
|
a.notifyError("切换壁纸失败:" + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_ = a.notifyIcon.ShowInfo(appName, "已切换到缓存壁纸。")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) toggleAutoChange() {
|
func (a *App) toggleAutoChange() {
|
||||||
|
|||||||
+7
-1
@@ -2,6 +2,11 @@
|
|||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="GoWallpaper" type="win32"/>
|
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="GoWallpaper" type="win32"/>
|
||||||
<description>GoWallpaper</description>
|
<description>GoWallpaper</description>
|
||||||
|
<dependency>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
</dependency>
|
||||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
<security>
|
<security>
|
||||||
<requestedPrivileges>
|
<requestedPrivileges>
|
||||||
@@ -16,7 +21,8 @@
|
|||||||
</compatibility>
|
</compatibility>
|
||||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
<windowsSettings>
|
<windowsSettings>
|
||||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||||
|
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
|
||||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||||
</windowsSettings>
|
</windowsSettings>
|
||||||
</application>
|
</application>
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ param(
|
|||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
$ProxyUrl = "http://127.0.0.1:10808"
|
||||||
|
$env:HTTP_PROXY = $ProxyUrl
|
||||||
|
$env:HTTPS_PROXY = $ProxyUrl
|
||||||
|
$env:NO_PROXY = "localhost,127.0.0.1"
|
||||||
$ProjectRoot = $PSScriptRoot
|
$ProjectRoot = $PSScriptRoot
|
||||||
$DistDir = Join-Path $ProjectRoot "dist"
|
$DistDir = Join-Path $ProjectRoot "dist"
|
||||||
$OutputPath = Join-Path $DistDir "GoWallpaper.exe"
|
$OutputPath = Join-Path $DistDir "GoWallpaper.exe"
|
||||||
|
|||||||
+22
-2
@@ -25,6 +25,12 @@ var styleOptions = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) showSettings() {
|
func (a *App) showSettings() {
|
||||||
|
if a.settingsDialog != nil {
|
||||||
|
a.settingsDialog.Show()
|
||||||
|
_ = a.settingsDialog.Activate()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var dlg *walk.Dialog
|
var dlg *walk.Dialog
|
||||||
var apiEdit, intervalEdit, cacheEdit *walk.LineEdit
|
var apiEdit, intervalEdit, cacheEdit *walk.LineEdit
|
||||||
var autoCheck, startupCheck *walk.CheckBox
|
var autoCheck, startupCheck *walk.CheckBox
|
||||||
@@ -39,7 +45,7 @@ func (a *App) showSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := Dialog{
|
err := Dialog{
|
||||||
AssignTo: &dlg,
|
AssignTo: &dlg,
|
||||||
Title: "GoWallpaper 设置",
|
Title: "GoWallpaper 设置",
|
||||||
MinSize: Size{520, 300},
|
MinSize: Size{520, 300},
|
||||||
@@ -93,15 +99,29 @@ func (a *App) showSettings() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dlg.Accept()
|
dlg.Accept()
|
||||||
|
if cfg.APIURL == "" {
|
||||||
|
a.notifyInfo("配置已保存。刷新壁纸前需要先设置随机图片 API 地址。")
|
||||||
|
} else {
|
||||||
|
a.notifyInfo("配置已保存。")
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
PushButton{Text: "取消", OnClicked: func() { dlg.Cancel() }},
|
PushButton{Text: "取消", OnClicked: func() { dlg.Cancel() }},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}.Run(a.mw)
|
}.Create(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.notifyError("无法打开设置窗口:" + err.Error())
|
a.notifyError("无法打开设置窗口:" + err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
a.settingsDialog = dlg
|
||||||
|
dlg.Closing().Attach(func(_ *bool, _ walk.CloseReason) {
|
||||||
|
if a.settingsDialog == dlg {
|
||||||
|
a.settingsDialog = nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
dlg.Show()
|
||||||
|
_ = dlg.Activate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePositiveInt(value, field string) (int, error) {
|
func parsePositiveInt(value, field string) (int, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user