2026-08-11 19:07:05 +08:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"embed"
|
2026-08-14 07:51:46 +08:00
|
|
|
|
"log/slog"
|
|
|
|
|
|
"os"
|
2026-08-11 19:07:05 +08:00
|
|
|
|
|
2026-08-14 07:51:46 +08:00
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/services/notifications"
|
2026-08-11 19:07:05 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
//go:embed all:frontend/dist
|
|
|
|
|
|
var assets embed.FS
|
|
|
|
|
|
|
2026-08-14 07:51:46 +08:00
|
|
|
|
func devtoolsArgs() []string {
|
|
|
|
|
|
if p := os.Getenv("CC_DEVTOOLS_PORT"); p != "" {
|
|
|
|
|
|
return []string{"--remote-debugging-port=" + p}
|
|
|
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-11 19:07:05 +08:00
|
|
|
|
func main() {
|
|
|
|
|
|
app := NewApp()
|
2026-08-14 07:51:46 +08:00
|
|
|
|
notifier := notifications.New()
|
|
|
|
|
|
app.notifier = notifier
|
2026-08-11 19:07:05 +08:00
|
|
|
|
|
2026-08-14 07:51:46 +08:00
|
|
|
|
wapp := application.New(application.Options{
|
|
|
|
|
|
Name: "年糕崽崽项目管理(PMS)",
|
|
|
|
|
|
Description: "本地代码统计与项目工作台",
|
|
|
|
|
|
Services: []application.Service{
|
|
|
|
|
|
application.NewService(app),
|
|
|
|
|
|
application.NewService(notifier),
|
|
|
|
|
|
},
|
|
|
|
|
|
Assets: application.AssetOptions{
|
2026-08-15 17:18:00 +08:00
|
|
|
|
Handler: application.AssetFileServerFS(assets),
|
|
|
|
|
|
Middleware: remoteImageMiddleware,
|
2026-08-11 19:07:05 +08:00
|
|
|
|
},
|
2026-08-14 07:51:46 +08:00
|
|
|
|
LogLevel: slog.LevelError,
|
|
|
|
|
|
Windows: application.WindowsOptions{
|
|
|
|
|
|
// Opt-in DevTools protocol endpoint for automated UI testing; inert unless the env var is set.
|
|
|
|
|
|
AdditionalBrowserArgs: devtoolsArgs(),
|
2026-08-11 19:07:05 +08:00
|
|
|
|
},
|
2026-08-14 17:54:06 +08:00
|
|
|
|
// 单实例:第二个进程启动时通过 Wails 内置的 WM_COPYDATA / DBus 通道
|
|
|
|
|
|
// 通知首个进程,回调里唤起已存在的主窗口并切到前台。
|
|
|
|
|
|
SingleInstance: &application.SingleInstanceOptions{
|
|
|
|
|
|
UniqueID: "com.niangaozai.view-pms",
|
|
|
|
|
|
OnSecondInstanceLaunch: func(_ application.SecondInstanceData) {
|
|
|
|
|
|
// 回调运行在后台 goroutine,需派发到 UI 线程操作窗口。
|
|
|
|
|
|
application.InvokeAsync(func() { app.showMainWindow() })
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2026-08-11 19:07:05 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-08-14 07:51:46 +08:00
|
|
|
|
win := wapp.Window.NewWithOptions(application.WebviewWindowOptions{
|
|
|
|
|
|
Name: "main",
|
|
|
|
|
|
Title: "年糕崽崽项目管理(PMS)",
|
|
|
|
|
|
Width: 1280,
|
|
|
|
|
|
Height: 820,
|
|
|
|
|
|
MinWidth: 960,
|
|
|
|
|
|
MinHeight: 680,
|
|
|
|
|
|
URL: "/",
|
|
|
|
|
|
BackgroundColour: application.NewRGBA(13, 18, 28, 255),
|
2026-08-14 17:54:06 +08:00
|
|
|
|
// 无边框:标题栏由前端 TitleBar 自绘(logo + 菜单 + 窗控同一行)。
|
|
|
|
|
|
Frameless: true,
|
2026-08-15 17:18:00 +08:00
|
|
|
|
// 发版等场景需拖入本地安装包;仅 data-file-drop-target 区域接受。
|
|
|
|
|
|
EnableFileDrop: true,
|
2026-08-14 17:54:06 +08:00
|
|
|
|
Windows: application.WindowsWindow{
|
|
|
|
|
|
DisableMenu: true,
|
|
|
|
|
|
},
|
2026-08-14 07:51:46 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
app.SetupShell(wapp, win)
|
|
|
|
|
|
|
|
|
|
|
|
if err := wapp.Run(); err != nil {
|
2026-08-11 19:07:05 +08:00
|
|
|
|
println("Error:", err.Error())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|