- main.go: 入口+单实例互斥锁 - win32.go: Win32 API/embed/evalJS/全局变量 - config.go: 配置读写+图标生成 - weather.go: 天气API/定位/天气循环 - systray.go: 托盘菜单/WebView/全屏监控 - wallpaper.html → web/wallpaper.html
34 lines
807 B
Go
34 lines
807 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/getlantern/systray"
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func main() {
|
|
log.SetFlags(log.Ltime | log.Lmicroseconds)
|
|
|
|
mutexName, _ := windows.UTF16PtrFromString("Global\\u-desktop-single-instance")
|
|
mutex, err := windows.CreateMutex(nil, false, mutexName)
|
|
if err != nil {
|
|
log.Fatal("创建互斥锁失败:", err)
|
|
}
|
|
if windows.GetLastError() == windows.ERROR_ALREADY_EXISTS {
|
|
log.Println("已有实例运行,退出")
|
|
windows.CloseHandle(mutex)
|
|
return
|
|
}
|
|
defer windows.CloseHandle(mutex)
|
|
|
|
exePath, _ := os.Executable()
|
|
configDir := filepath.Join(filepath.Dir(exePath), "config")
|
|
os.MkdirAll(configDir, 0755)
|
|
configPath = filepath.Join(configDir, "settings.json")
|
|
procSetProcessDPIAware.Call()
|
|
systray.Run(onSystrayReady, nil)
|
|
}
|