diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17fd9ac..483c72c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ permissions: env: GUI_DIR: cmd/npc/npc-gui FRONTEND_DIR: cmd/npc/npc-gui/frontend - WAILS_VERSION: v2.11.0 + WAILS_VERSION: v3.0.0-beta.12 APP_NAME: npc-gui jobs: @@ -171,36 +171,26 @@ jobs: cache-dependency-path: ${{ env.FRONTEND_DIR }}/yarn.lock - name: Enable Yarn (corepack) run: corepack enable - - name: Install frontend dependencies - run: yarn install --frozen-lockfile - working-directory: ${{ env.FRONTEND_DIR }} - - name: Build frontend - run: yarn build - working-directory: ${{ env.FRONTEND_DIR }} - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: ${{ env.GUI_DIR }}/go.mod check-latest: true - name: Install Wails CLI - run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }} + run: go install github.com/wailsapp/wails/v3/cmd/wails3@${{ env.WAILS_VERSION }} working-directory: ${{ env.GUI_DIR }} - name: Build and package (Windows) shell: pwsh working-directory: ${{ env.GUI_DIR }} run: | - $wails = Join-Path (go env GOPATH) "bin\wails.exe" - $tagArgs = @() - if ($env:WAILS_TAGS) { $tagArgs += @("-tags", $env:WAILS_TAGS) } - & $wails build -m -s -trimpath -skipbindings @tagArgs -platform ${{ matrix.platform }} -o "$env:APP_NAME.exe" - Set-Location build\bin + $env:GOOS = "windows" + $env:GOARCH = "${{ matrix.arch }}" + wails3 build --tags npcgui + Set-Location bin $zipName = "$env:APP_NAME-${{ matrix.os_name }}-${{ matrix.arch }}.zip" $exe = Get-ChildItem -Path . -Filter *.exe | Select-Object -First 1 if (-not $exe) { - $exe = Get-ChildItem -Path . -File | Select-Object -First 1 - } - if (-not $exe) { - Write-Host "No build output found in build/bin" + Write-Host "No build output found in bin" Get-ChildItem -Path . | Format-Table -AutoSize exit 1 } @@ -209,7 +199,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: windows-builds-${{ matrix.arch }} - path: ${{ env.GUI_DIR }}/build/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip + path: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip # ==================== macOS GUI ==================== build_macos_gui: @@ -234,34 +224,28 @@ jobs: cache-dependency-path: ${{ env.FRONTEND_DIR }}/yarn.lock - name: Enable Yarn (corepack) run: corepack enable - - name: Install frontend dependencies - run: yarn install --frozen-lockfile - working-directory: ${{ env.FRONTEND_DIR }} - - name: Build frontend - run: yarn build - working-directory: ${{ env.FRONTEND_DIR }} - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: ${{ env.GUI_DIR }}/go.mod check-latest: true - name: Install Wails CLI - run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }} + run: go install github.com/wailsapp/wails/v3/cmd/wails3@${{ env.WAILS_VERSION }} working-directory: ${{ env.GUI_DIR }} - name: Build and package (macOS) shell: bash working-directory: ${{ env.GUI_DIR }} run: | - wails="$(go env GOPATH)/bin/wails" - tagArgs=() - if [ -n "$WAILS_TAGS" ]; then - tagArgs+=( -tags "$WAILS_TAGS" ) - fi - "$wails" build -m -s -trimpath -skipbindings "${tagArgs[@]}" -platform "${{ matrix.platform }}" -o "$APP_NAME" - cd build/bin + export GOOS=darwin + export GOARCH="${{ matrix.arch }}" + wails3 build --tags npcgui + cd bin app="$(ls -1d *.app 2>/dev/null | head -n 1)" if [ -z "$app" ]; then - echo "No .app found in build/bin" + app="$(find . -maxdepth 1 -type f -perm -111 -printf '%f\n' | head -n 1)" + fi + if [ -z "$app" ]; then + echo "No build output found in bin" ls -la exit 1 fi @@ -270,13 +254,11 @@ jobs: uses: actions/upload-artifact@v4 with: name: macos-builds-${{ matrix.arch }} - path: ${{ env.GUI_DIR }}/build/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip + path: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip # ==================== Linux GUI ==================== build_linux_gui: runs-on: ubuntu-latest - env: - WAILS_TAGS: webkit2_41 strategy: matrix: include: @@ -289,7 +271,7 @@ jobs: - name: Install Linux dependencies run: | sudo apt-get update - sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev pkg-config - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -298,34 +280,25 @@ jobs: cache-dependency-path: ${{ env.FRONTEND_DIR }}/yarn.lock - name: Enable Yarn (corepack) run: corepack enable - - name: Install frontend dependencies - run: yarn install --frozen-lockfile - working-directory: ${{ env.FRONTEND_DIR }} - - name: Build frontend - run: yarn build - working-directory: ${{ env.FRONTEND_DIR }} - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: ${{ env.GUI_DIR }}/go.mod check-latest: true - name: Install Wails CLI - run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }} + run: go install github.com/wailsapp/wails/v3/cmd/wails3@${{ env.WAILS_VERSION }} working-directory: ${{ env.GUI_DIR }} - name: Build and package (Linux) shell: bash working-directory: ${{ env.GUI_DIR }} run: | - wails="$(go env GOPATH)/bin/wails" - tagArgs=() - if [ -n "$WAILS_TAGS" ]; then - tagArgs+=( -tags "$WAILS_TAGS" ) - fi - "$wails" build -m -s -trimpath -skipbindings "${tagArgs[@]}" -platform "${{ matrix.platform }}" -o "$APP_NAME" - cd build/bin + export GOOS=linux + export GOARCH="${{ matrix.arch }}" + wails3 build --tags npcgui + cd bin bin="$(find . -maxdepth 1 -type f -perm -111 -printf '%f\n' | head -n 1)" if [ -z "$bin" ]; then - echo "No executable file found in build/bin" + echo "No executable file found in bin" ls -la exit 1 fi @@ -334,7 +307,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: linux-builds-${{ matrix.arch }} - path: ${{ env.GUI_DIR }}/build/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip + path: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip # ==================== GUI Release 上传 ==================== upload_gui_release: diff --git a/client/client.go b/client/client.go index f12eba2..8c5464c 100755 --- a/client/client.go +++ b/client/client.go @@ -34,8 +34,16 @@ type TRPClient struct { cnf *config.Config disconnectTime int once sync.Once - closeCh chan struct{} // closed when client is shutting down; stops ping - logger *logs.BeeLogger // 每个客户端独立的 logger + closeCh chan struct{} // closed when client is shutting down; stops ping + logger Logger // 每客户端独立的 logger,未设置时使用全局 logger +} + +// Logger 客户端日志接口,GUI / CLI 均可注入实现 +type Logger interface { + Info(format string, v ...interface{}) + Error(format string, v ...interface{}) + Warn(format string, v ...interface{}) + Trace(format string, v ...interface{}) } // new client @@ -55,7 +63,7 @@ func NewRPClient(svraddr string, vKey string, bridgeConnType string, proxyUrl st } // SetLogger 设置客户端的独立 logger -func (s *TRPClient) SetLogger(logger *logs.BeeLogger) { +func (s *TRPClient) SetLogger(logger Logger) { s.logger = logger } diff --git a/cmd/npc/npc-gui/.gitignore b/cmd/npc/npc-gui/.gitignore index 8d12495..20b21db 100644 --- a/cmd/npc/npc-gui/.gitignore +++ b/cmd/npc/npc-gui/.gitignore @@ -23,5 +23,14 @@ Thumbs.db # 构建临时文件 *.tmp -build/windows/ +*.syso dist/ + +# wails3 构建输出 +bin/ + +# wails3 task 缓存 +.task/ + +# NSIS 打包产物(WebView2 bootstrapper / 安装器) +build/windows/nsis/*.exe diff --git a/cmd/npc/npc-gui/README.md b/cmd/npc/npc-gui/README.md index 4ba7731..6e31f5d 100644 --- a/cmd/npc/npc-gui/README.md +++ b/cmd/npc/npc-gui/README.md @@ -1,4 +1,6 @@ -# NPS 客户端 GUI (Wails 版本) +# NPS 客户端 GUI (Wails v3 版本) + +基于 [Wails v3](https://v3.wails.io/)(beta)构建的 NPS 客户端图形界面。 ## 快捷命令格式 @@ -17,25 +19,109 @@ nps:MyServer|127.0.0.1:8024|mykey123|false bnBzOk15U2VydmVyfDEyNy4wLjAuMTo4MDI0fG15a2V5MTIzfGZhbHNl ``` -## 安装与运行 +## 前置要求 -### 前置要求 -- Go 1.21+ +- Go 1.25+(wails v3 最低要求) - Node.js 16+ - Yarn +- Wails v3 CLI(wails3) -### 开发模式 +安装 Wails CLI: ```bash -cd npc-gui - -# 安装依赖 -yarn install - -# 运行开发服务器 -wails dev +go install github.com/wailsapp/wails/v3/cmd/wails3@v3.0.0-beta.12 ``` +## 启动 / 调试 + +### 开发模式(热重载) + +```bash +cd cmd/npc/npc-gui + +# 启动开发模式:自动执行前端依赖安装、bindings 生成、yarn build:dev、 +# Go 编译并运行应用(无需手动 yarn build) +# Vite 端口默认为 9245,自定义端口用 -port(如 -port 34115) +wails3 dev +``` + +### 构建 + +```bash +cd cmd/npc/npc-gui + +# 构建当前平台(前端构建 + bindings 生成 + Go 编译自动完成) +wails3 build --tags npcgui +``` + +产物输出到 `bin/` 目录(如 Windows 为 `bin/npc-gui.exe`)。 + +### 跨平台构建 + +通过 `GOOS`/`GOARCH` 环境变量指定目标平台: + +```bash +# Windows amd64(在非 Windows 上需 Docker 镜像 wails-cross 支持 CGO 交叉编译) +GOOS=windows GOARCH=amd64 wails3 build --tags npcgui + +# macOS +GOOS=darwin GOARCH=arm64 wails3 build --tags npcgui + +# Linux(需要 libgtk-3-dev / libwebkit2gtk-4.1-dev) +GOOS=linux GOARCH=amd64 wails3 build --tags npcgui +``` + +### 打包安装包 + +```bash +# Windows NSIS 安装器(需要 makensis) +wails3 package + +# 或指定安装范围(user = 免 UAC 按用户安装) +wails3 package INSTALL_SCOPE=user +``` + +### 手动生成前端绑定 + +Go 侧绑定方法签名变更后,重新生成前端 bindings: + +```bash +cd cmd/npc/npc-gui +wails3 generate bindings +``` + +生成结果位于 `frontend/bindings/`。 + +### 常用任务 + +```bash +wails3 task --list # 列出所有 Taskfile 任务 +wails3 task build # 等价于 wails3 build +wails3 task run # 运行已构建的产物 +wails3 update build-assets # 刷新 build/ 目录构建资产 +``` + +## 项目结构(v3) + +``` +cmd/npc/npc-gui/ +├── Taskfile.yml # 根任务定义(APP_NAME、包管理器、端口) +├── main.go # 应用入口(application.New + 窗口 + 服务注册) +├── app_bindings.go # App 服务(前端可调用的绑定方法) +├── tray.go # 系统托盘(v3 内置 SystemTray) +├── build/ +│ ├── config.yml # 应用信息、版本、dev 模式配置 +│ ├── Taskfile.yml # 公共任务(前端安装/构建、bindings 生成、图标) +│ └── windows|darwin|linux/ # 各平台构建资产与打包模板 +└── frontend/ + ├── bindings/ # wails3 generate bindings 生成(已提交) + ├── src/App.vue # 主界面(import { App as AppAPI } from '../bindings/npc-gui/index.js') + └── dist/ # 前端构建产物(embed 进二进制) +``` + +## 构建标签 + +- `npcgui`:GUI 客户端构建必须传入(排除 `server/proxy/tcp.go` 中的服务端隧道实现,见 `server/proxy/tcp_npcgui.go` 占位实现) ## 配置存储 @@ -44,4 +130,4 @@ wails dev - Linux: `~/.config/npc/npc_data.json` - macOS: `~/Library/Application Support/npc/npc_data.json` - +客户端日志默认保存在 `<配置目录>/npc/logs/`,可在设置中修改日志目录。 diff --git a/cmd/npc/npc-gui/Taskfile.yml b/cmd/npc/npc-gui/Taskfile.yml new file mode 100644 index 0000000..7551f35 --- /dev/null +++ b/cmd/npc/npc-gui/Taskfile.yml @@ -0,0 +1,37 @@ +version: '3' + +vars: + APP_NAME: "npc-gui" + BIN_DIR: "bin" + PACKAGE_MANAGER: "yarn" + VITE_PORT: '{{.WAILS_VITE_PORT | default 34115}}' + # Target OS for build/package/run. Defaults to the host OS, and is overridden + # by `wails3 build GOOS=...` (or the GOOS env var) for cross-compilation. + GOOS: '{{.GOOS | default OS}}' + +includes: + common: ./build/Taskfile.yml + windows: ./build/windows/Taskfile.yml + darwin: ./build/darwin/Taskfile.yml + linux: ./build/linux/Taskfile.yml + +tasks: + build: + summary: Builds the application + cmds: + - task: "{{.GOOS}}:build" + + package: + summary: Packages a production build of the application + cmds: + - task: "{{.GOOS}}:package" + + run: + summary: Runs the application + cmds: + - task: "{{.GOOS}}:run" + + dev: + summary: Runs the application in development mode + cmds: + - wails3 dev -config ./build/config.yml -port {{.VITE_PORT}} diff --git a/cmd/npc/npc-gui/app_bindings.go b/cmd/npc/npc-gui/app_bindings.go index cb86fc3..5351657 100644 --- a/cmd/npc/npc-gui/app_bindings.go +++ b/cmd/npc/npc-gui/app_bindings.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "log/slog" "os" "path/filepath" "strings" @@ -14,13 +15,13 @@ import ( "ehang.io/nps/client" "ehang.io/nps/lib/version" - _ "github.com/astaxie/beego" - "github.com/astaxie/beego/logs" - wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" + "github.com/wailsapp/wails/v3/pkg/application" ) type App struct { - ctx context.Context + app *application.App + window *application.WebviewWindow + tray *application.SystemTray } // ShortClient 与前端结构对应 @@ -49,33 +50,22 @@ var ( // 改为用 context 管理内置客户端,而不是外部进程 running = make(map[string]context.CancelFunc) clients = make(map[string]*client.TRPClient) - clientErrors = make(map[string]string) // 存储客户端连接错误信息 - clientConnected = make(map[string]bool) // 存储客户端连接状态 (true=connected) - clientAttempted = make(map[string]bool) // 存储客户端是否尝试过连接 - clientLoggers = make(map[string]*logs.BeeLogger) // 为每个客户端单独管理 logger - statusMu sync.Mutex // 状态锁 + clientErrors = make(map[string]string) // 存储客户端连接错误信息 + clientConnected = make(map[string]bool) // 存储客户端连接状态 (true=connected) + clientAttempted = make(map[string]bool) // 存储客户端是否尝试过连接 + statusMu sync.Mutex // 状态锁 runningMu sync.Mutex - loggerMu sync.Mutex // 保护 clientLoggers 的并发访问 disconnectTimeout = 60 connType = "tcp" - - // 日志缓存机制,避免频繁读取文件 - logsCacheMu sync.RWMutex - logsCache = make(map[string][]ConnectionLog) // 缓存:clientId -> logs - logsCacheTime = make(map[string]time.Time) // 缓存时间:clientId -> time - logsCacheTTL = 2 * time.Second // 缓存有效期 2 秒 ) -func NewApp() *App { return &App{} } +func NewApp(app *application.App, window *application.WebviewWindow) *App { + return &App{app: app, window: window} +} -func (a *App) startup(ctx context.Context) { - // 保存 context,用于后续调用 runtime API - a.ctx = ctx - - // 初始化日志系统,只使用 store logger(内存缓存) - // 每个客户端有自己独立的日志文件,不需要全局日志文件 - logs.SetLogger("store") - logs.SetLevel(logs.LevelDebug) +func (a *App) ServiceStartup(ctx context.Context, options application.ServiceOptions) error { + // 初始化日志系统:应用日志走 slog,客户端日志走内存缓冲 + JSON 文件 + initAppLogger() // 同步开机启动状态:检查配置与实际注册表是否一致 go func() { @@ -84,21 +74,32 @@ func (a *App) startup(ctx context.Context) { actualEnabled := isStartupEnabled() if store.Settings.StartupEnabled && !actualEnabled { // 配置说启用,但实际未启用,则启用之 - logs.Info("同步开机启动状态:启用") + slog.Info("同步开机启动状态:启用") if err := enableStartup(); err != nil { - logs.Error("同步开机启动失败: %v", err) + slog.Error("同步开机启动失败", "err", err) } } else if !store.Settings.StartupEnabled && actualEnabled { // 配置说禁用,但实际已启用,则禁用之 - logs.Info("同步开机启动状态:禁用") + slog.Info("同步开机启动状态:禁用") if err := disableStartup(); err != nil { - logs.Error("同步开机启动失败: %v", err) + slog.Error("同步开机启动失败", "err", err) } } } }() - go a.startTray() + a.startTray() + return nil +} + +func (a *App) ServiceShutdown() error { + setQuitting() + closeAllLogStores() + if a.tray != nil { + a.tray.Destroy() + a.tray = nil + } + return nil } func getLogsPath() string { @@ -137,53 +138,6 @@ func getClientLogFilePath(vkey string) string { return filepath.Join(logsDir, fmt.Sprintf("npc-client-%s.log", vkey)) } -// initClientLogger 为客户端初始化独立的 logger -func initClientLogger(vkey string) { - loggerMu.Lock() - defer loggerMu.Unlock() - - if _, exists := clientLoggers[vkey]; !exists { - // 为每个客户端创建独立的 BeeLogger - logger := logs.NewLogger() - // 设置为 Debug 级别,可以看到 Trace 日志 - logger.SetLevel(logs.LevelDebug) - - // 设置独立的日志文件 - logFilePath := getClientLogFilePath(vkey) - // Windows 路径中的反斜杠需要转义 - escapedPath := strings.ReplaceAll(logFilePath, "\\", "\\\\") - logger.SetLogger(logs.AdapterFile, `{"filename":"`+escapedPath+`","daily":true,"maxdays":7}`) - - clientLoggers[vkey] = logger - } -} - -// getClientLogger 获取客户端的 logger -func getClientLogger(id string) *logs.BeeLogger { - loggerMu.Lock() - defer loggerMu.Unlock() - return clientLoggers[id] -} - -// closeClientLogger 关闭客户端的 logger -func closeClientLogger(id string) { - loggerMu.Lock() - defer loggerMu.Unlock() - - if logger, exists := clientLoggers[id]; exists { - if logger != nil { - logger.Close() - } - delete(clientLoggers, id) - } -} - -func (a *App) shutdown(ctx context.Context) { - setQuitting() - QuitTray() - wailsRuntime.Quit(a.ctx) -} - // 持久化文件结构(向后兼容旧的仅数组格式) type GuiSettings struct { StartupEnabled bool `json:"startupEnabled"` @@ -338,16 +292,16 @@ func (a *App) SaveGuiSettings(s GuiSettings) error { if oldStartupEnabled != s.StartupEnabled { if s.StartupEnabled { if err := enableStartup(); err != nil { - logs.Error("启用开机启动失败: %v", err) + slog.Error("启用开机启动失败", "err", err) return fmt.Errorf("启用开机启动失败: %v", err) } - logs.Info("已启用开机启动") + slog.Info("已启用开机启动") } else { if err := disableStartup(); err != nil { - logs.Error("禁用开机启动失败: %v", err) + slog.Error("禁用开机启动失败", "err", err) return fmt.Errorf("禁用开机启动失败: %v", err) } - logs.Info("已禁用开机启动") + slog.Info("已禁用开机启动") } } @@ -387,7 +341,7 @@ func (a *App) GetDefaultLogDir() string { // SelectDirectory 打开目录选择对话框 func (a *App) SelectDirectory() (string, error) { - logs.Info("SelectDirectory 被调用") + slog.Info("SelectDirectory 被调用") // 获取当前设置的日志目录作为默认目录 defaultDir := "" @@ -396,20 +350,23 @@ func (a *App) SelectDirectory() (string, error) { defaultDir = store.Settings.LogDir } - logs.Info("默认目录: %s", defaultDir) + slog.Info("默认目录", "dir", defaultDir) // 打开目录选择对话框 - selectedDir, err := wailsRuntime.OpenDirectoryDialog(a.ctx, wailsRuntime.OpenDialogOptions{ - Title: "选择日志目录", - DefaultDirectory: defaultDir, + dialog := a.app.Dialog.OpenFileWithOptions(&application.OpenFileDialogOptions{ + CanChooseDirectories: true, + CanChooseFiles: false, + Title: "选择日志目录", + Directory: defaultDir, }) + selectedDir, err := dialog.PromptForSingleSelection() if err != nil { - logs.Error("打开目录选择对话框失败: %v", err) + slog.Error("打开目录选择对话框失败", "err", err) return "", err } - logs.Info("用户选择的目录: %s", selectedDir) + slog.Info("用户选择的目录", "dir", selectedDir) return selectedDir, nil } @@ -563,13 +520,13 @@ func (a *App) RemoveShortcut(name, addr, key string) error { func (a *App) ToggleClient(name, addr, key string, tls bool, runningState bool) error { id := addr + "|" + key - logs.Info("ToggleClient called: name=%s, addr=%s, tls=%v, runningState=%v", name, addr, tls, runningState) + slog.Info("ToggleClient called", "name", name, "addr", addr, "tls", tls, "runningState", runningState) runningMu.Lock() defer runningMu.Unlock() if runningState { // start npc client in goroutine if _, ok := running[id]; !ok { - logs.Info("Starting NPC client: %s", id) + slog.Info("Starting NPC client", "id", id) ctx, cancel := context.WithCancel(context.Background()) running[id] = cancel // 清除之前的状态 @@ -580,12 +537,12 @@ func (a *App) ToggleClient(name, addr, key string, tls bool, runningState bool) statusMu.Unlock() go startNpcClientWithContext(ctx, id, addr, key, tls) } else { - logs.Info("Client already running: %s", id) + slog.Info("Client already running", "id", id) } } else { // stop the client if cancel, ok := running[id]; ok { - logs.Info("Stopping NPC client: %s", id) + slog.Info("Stopping NPC client", "id", id) cancel() delete(running, id) // 清除状态 @@ -600,7 +557,7 @@ func (a *App) ToggleClient(name, addr, key string, tls bool, runningState bool) delete(clients, id) } } else { - logs.Info("Client not running, nothing to stop: %s", id) + slog.Info("Client not running, nothing to stop", "id", id) } } return nil @@ -618,21 +575,17 @@ func startNpcClient(id, server, vkey string, tlsEnable bool) { // startNpcClientWithContext 在给定的 context 中运行 npc 客户端 func startNpcClientWithContext(ctx context.Context, id, server, vkey string, tlsEnable bool) { - // 为该客户端初始化独立的日志文件 - initClientLogger(id) - clientLogger := getClientLogger(id) + // 为该客户端准备日志存储(内存缓冲 + 独立日志文件) + store := getClientLogStore(id) + clientLogger := &trpcLogger{store: store} client.SetTlsEnable(tlsEnable) - if clientLogger != nil { - clientLogger.Info("启动 NPC 客户端: server=%s, vkey=%s, tls=%v", server, vkey, tlsEnable) - } + clientLogger.Info("启动 NPC 客户端: server=%s, vkey=%s, tls=%v", server, vkey, tlsEnable) for { select { case <-ctx.Done(): - if clientLogger != nil { - clientLogger.Info("停止 NPC 客户端") - } + clientLogger.Info("停止 NPC 客户端") statusMu.Lock() delete(clientConnected, id) delete(clientAttempted, id) @@ -644,15 +597,11 @@ func startNpcClientWithContext(ctx context.Context, id, server, vkey string, tls delete(clients, id) } runningMu.Unlock() - // 关闭客户端日志 - closeClientLogger(id) return default: } - if clientLogger != nil { - clientLogger.Info("连接服务器") - } + clientLogger.Info("连接服务器") // 重置连接状态,准备新的连接尝试 statusMu.Lock() @@ -662,9 +611,7 @@ func startNpcClientWithContext(ctx context.Context, id, server, vkey string, tls rpcClient := client.NewRPClient(server, vkey, connType, "", nil, disconnectTimeout) // 设置客户端的独立 logger - if clientLogger != nil { - rpcClient.SetLogger(clientLogger) - } + rpcClient.SetLogger(clientLogger) // 将客户端保存到全局 map runningMu.Lock() @@ -678,9 +625,7 @@ func startNpcClientWithContext(ctx context.Context, id, server, vkey string, tls go func() { select { case <-ctx.Done(): - if clientLogger != nil { - clientLogger.Info("Context 已取消,关闭客户端") - } + clientLogger.Info("Context 已取消,关闭客户端") rpcClient.Close() } }() @@ -690,9 +635,7 @@ func startNpcClientWithContext(ctx context.Context, id, server, vkey string, tls // 检查 context 是否已取消 select { case <-ctx.Done(): - if clientLogger != nil { - clientLogger.Info("停止 NPC 客户端") - } + clientLogger.Info("停止 NPC 客户端") statusMu.Lock() delete(clientConnected, id) delete(clientAttempted, id) @@ -704,8 +647,6 @@ func startNpcClientWithContext(ctx context.Context, id, server, vkey string, tls delete(clients, id) } runningMu.Unlock() - // 关闭客户端日志 - closeClientLogger(id) return case <-time.After(5 * time.Second): // 继续重新连接 @@ -721,7 +662,7 @@ func monitorFirstConnection(ctx context.Context, id string, rpcClient *client.TR initialTimeout := time.After(5 * time.Second) connected := false - clientLogger := getClientLogger(id) + clientLogger := &trpcLogger{store: getClientLogStore(id)} for { select { @@ -734,9 +675,7 @@ func monitorFirstConnection(ctx context.Context, id string, rpcClient *client.TR clientConnected[id] = false clientErrors[id] = "连接服务器失败,正在重新连接..." statusMu.Unlock() - if clientLogger != nil { - clientLogger.Error("连接服务器失败 (timeout),将自动重连") - } + clientLogger.Error("连接服务器失败 (timeout),将自动重连") } // 即使超时,也继续监听连接状态变化 case <-ticker.C: @@ -749,9 +688,7 @@ func monitorFirstConnection(ctx context.Context, id string, rpcClient *client.TR clientConnected[id] = true delete(clientErrors, id) statusMu.Unlock() - if clientLogger != nil { - clientLogger.Info("客户端连接成功") - } + clientLogger.Info("客户端连接成功") connected = true } } else { @@ -761,9 +698,7 @@ func monitorFirstConnection(ctx context.Context, id string, rpcClient *client.TR clientConnected[id] = false clientErrors[id] = "连接已断开,正在重新连接..." statusMu.Unlock() - if clientLogger != nil { - clientLogger.Warn("客户端连接已断开") - } + clientLogger.Warn("客户端连接已断开") connected = false } } @@ -771,101 +706,14 @@ func monitorFirstConnection(ctx context.Context, id string, rpcClient *client.TR } } -// GetConnectionLogs 获取指定客户端的连接日志(从独立日志文件读取) +// GetConnectionLogs 获取指定客户端的连接日志(直接读内存缓冲,无需解析文件) func (a *App) GetConnectionLogs(clientId string) ([]ConnectionLog, error) { - // 检查缓存是否有效 - logsCacheMu.RLock() - if cachedLogs, exists := logsCache[clientId]; exists { - if cacheTime, ok := logsCacheTime[clientId]; ok { - if time.Since(cacheTime) < logsCacheTTL { - // 缓存仍然有效 - logsCacheMu.RUnlock() - return cachedLogs, nil - } - } - } - logsCacheMu.RUnlock() - - // 缓存过期或不存在,重新读取日志 - // 读取该客户端的独立日志文件 - clientLogFile := getClientLogFilePath(clientId) - - data, err := os.ReadFile(clientLogFile) - if err != nil { - // 如果文件不存在或读取失败,返回空日志 - return []ConnectionLog{}, nil - } - - logContent := string(data) - if logContent == "" { - return []ConnectionLog{}, nil - } - - var result []ConnectionLog - lines := strings.Split(logContent, "\n") - - for _, line := range lines { - line = strings.TrimSpace(line) - if line == "" { - continue - } - - // 判断日志类型 - logType := "info" - if strings.Contains(line, "[E]") { - logType = "error" - } else if strings.Contains(line, "[W]") { - logType = "warning" - } else if strings.Contains(line, "成功") || strings.Contains(line, "connected") || strings.Contains(line, "Success") { - logType = "success" - } - - // 提取时间戳(日志格式通常是:2026-01-09 11:04:56 或 11:04:56) - var timestamp string - timeFields := strings.Fields(line) - if len(timeFields) >= 2 { - // 尝试获取前两个字段作为日期和时间 - timestamp = timeFields[0] + " " + timeFields[1] - } else if len(timeFields) >= 1 { - timestamp = timeFields[0] - } - - log := ConnectionLog{ - Timestamp: timestamp, - Message: line, - Type: logType, - ClientId: clientId, - } - - result = append(result, log) - } - - // 更新缓存 - logsCacheMu.Lock() - logsCache[clientId] = result - logsCacheTime[clientId] = time.Now() - logsCacheMu.Unlock() - - return result, nil + return getClientLogStore(clientId).snapshot(), nil } -// ClearConnectionLogs 清空指定客户端的连接日志文件 +// ClearConnectionLogs 清空指定客户端的连接日志(内存缓冲与日志文件) func (a *App) ClearConnectionLogs(clientId string) error { - // 获取日志文件路径 - clientLogFile := getClientLogFilePath(clientId) - - // 清空日志文件内容(写入空字符串) - if err := os.WriteFile(clientLogFile, []byte(""), 0o644); err != nil { - return err - } - - // 清空缓存 - logsCacheMu.Lock() - delete(logsCache, clientId) - delete(logsCacheTime, clientId) - logsCacheMu.Unlock() - - return nil + return getClientLogStore(clientId).clear() } // getExecutablePath 获取当前可执行文件的完整路径 diff --git a/cmd/npc/npc-gui/build/Taskfile.yml b/cmd/npc/npc-gui/build/Taskfile.yml new file mode 100644 index 0000000..0790f6b --- /dev/null +++ b/cmd/npc/npc-gui/build/Taskfile.yml @@ -0,0 +1,398 @@ +version: '3' + +tasks: + go:mod:tidy: + summary: Runs `go mod tidy` + internal: true + # Universal/multi-arch builds invoke this concurrently from parallel deps; + # two `go mod tidy` processes racing on go.mod can corrupt it (#4637). + run: once + cmds: + - go mod tidy + + install:frontend:deps: + summary: Install frontend dependencies + run: once + cmds: + - task: install:frontend:deps:{{.PACKAGE_MANAGER}} + + install:frontend:deps:npm: + dir: frontend + sources: + - package.json + - package-lock.json + generates: + - node_modules + preconditions: + - sh: npm version + msg: "Looks like npm isn't installed. Npm is part of the Node installer: https://nodejs.org/en/download/" + cmds: + - npm install + + install:frontend:deps:bun: + dir: frontend + sources: + - package.json + - bun.lock + - bun.lockb + generates: + - node_modules + preconditions: + - sh: bun --version + msg: "bun not found" + cmds: + - bun install + + install:frontend:deps:pnpm: + dir: frontend + sources: + - package.json + - pnpm-lock.yaml + generates: + - node_modules + preconditions: + - sh: pnpm --version + msg: "pnpm not found" + cmds: + - pnpm install + + install:frontend:deps:yarn: + dir: frontend + sources: + - package.json + - yarn.lock + status: + - test -d node_modules || test -f .pnp.cjs + preconditions: + - sh: yarn --version + msg: "yarn not found" + cmds: + - yarn install + + build:frontend: + label: build:frontend (DEV={{.DEV}} RUNNER={{.PACKAGE_MANAGER}}) + summary: Build the frontend project + # darwin:build:universal runs its per-arch builds as parallel deps, each of + # which depends on this task. Without run:once the two executions race: + # one regenerates frontend/bindings (-clean deletes it first) while the + # other's bundler is reading it, failing intermittently with + # 'Could not resolve "./bindings/"' (#4637). + run: once + dir: frontend + sources: + - "**/*" + - exclude: node_modules/**/* + generates: + - dist/**/* + deps: + - task: install:frontend:deps + - task: generate:bindings + vars: + BUILD_FLAGS: + ref: .BUILD_FLAGS + OBFUSCATED: + ref: .OBFUSCATED + cmds: + - task: frontend:run + vars: + SCRIPT: '{{if eq .DEV "true"}}build:dev{{else}}build{{end}}' + env: + PRODUCTION: '{{if eq .DEV "true"}}false{{else}}true{{end}}' + + frontend:run: + summary: Run a frontend script with selected runner + cmds: + - task: frontend:run:{{.PACKAGE_MANAGER}} + vars: + SCRIPT: "{{.SCRIPT}}" + vars: + SCRIPT: "{{.SCRIPT}}" + + frontend:run:npm: + dir: frontend + cmds: + - npm run {{.SCRIPT}} -q + vars: + SCRIPT: "{{.SCRIPT}}" + + frontend:run:yarn: + dir: frontend + cmds: + - yarn {{.SCRIPT}} + vars: + SCRIPT: "{{.SCRIPT}}" + + frontend:run:pnpm: + dir: frontend + cmds: + - pnpm run {{.SCRIPT}} + vars: + SCRIPT: "{{.SCRIPT}}" + + frontend:run:bun: + dir: frontend + cmds: + - bun run {{.SCRIPT}} + vars: + SCRIPT: "{{.SCRIPT}}" + + frontend:vendor:puppertino: + summary: Fetches Puppertino CSS into frontend/public for consistent mobile styling + sources: + - frontend/public/puppertino/puppertino.css + generates: + - frontend/public/puppertino/puppertino.css + cmds: + - | + set -euo pipefail + mkdir -p frontend/public/puppertino + # If bundled Puppertino exists, prefer it. Otherwise, try to fetch, but don't fail build on error. + if [ ! -f frontend/public/puppertino/puppertino.css ]; then + echo "No bundled Puppertino found. Attempting to fetch from GitHub..." + if curl -fsSL https://raw.githubusercontent.com/codedgar/Puppertino/main/dist/css/full.css -o frontend/public/puppertino/puppertino.css; then + curl -fsSL https://raw.githubusercontent.com/codedgar/Puppertino/main/LICENSE -o frontend/public/puppertino/LICENSE || true + echo "Puppertino CSS downloaded to frontend/public/puppertino/puppertino.css" + else + echo "Warning: Could not fetch Puppertino CSS. Proceeding without download since template may bundle it." + fi + else + echo "Using bundled Puppertino at frontend/public/puppertino/puppertino.css" + fi + # Ensure index.html includes Puppertino CSS and button classes + INDEX_HTML=frontend/index.html + if [ -f "$INDEX_HTML" ]; then + if ! grep -q 'href="/puppertino/puppertino.css"' "$INDEX_HTML"; then + # Insert Puppertino link tag after style.css link + awk ' + /href="\/style.css"\/?/ && !x { print; print " "; x=1; next }1 + ' "$INDEX_HTML" > "$INDEX_HTML.tmp" && mv "$INDEX_HTML.tmp" "$INDEX_HTML" + fi + # Replace default .btn with Puppertino primary button classes if present + sed -E -i'' 's/class=\"btn\"/class=\"p-btn p-prim-col\"/g' "$INDEX_HTML" || true + fi + + + + generate:bindings: + summary: Generates bindings for the frontend + run: once + deps: + - task: go:mod:tidy + sources: + - "**/*.[jt]s" + - exclude: frontend/**/* + - frontend/bindings/**/* # Rerun when switching between dev/production mode causes changes in output + - "**/*.go" + - go.mod + - go.sum + generates: + - frontend/bindings/**/* + cmds: + - wails3 generate bindings -f '{{.BUILD_FLAGS}}' -clean=true -time-type=Date{{if eq .OBFUSCATED "true"}} -obfuscated{{end}} + + generate:icons: + summary: Generates Windows `.ico` and Mac `.icns` from an image; on macOS, `-iconcomposerinput appicon.icon -macassetdir darwin` also produces `Assets.car` from a `.icon` file (skipped on other platforms). + run: once + dir: build + sources: + - "appicon.png" + - "appicon.icon" + generates: + - "darwin/icons.icns" + - "windows/icon.ico" + cmds: + - wails3 generate icons -input appicon.png -macfilename darwin/icons.icns -windowsfilename windows/icon.ico -iconcomposerinput appicon.icon -macassetdir darwin + + dev:frontend: + summary: Runs the frontend in development mode + deps: + - task: install:frontend:deps + cmds: + - task: frontend:dev:{{.PACKAGE_MANAGER}} + + frontend:dev:npm: + dir: frontend + cmds: + - npm run dev -- --port {{.VITE_PORT}} --strictPort + + frontend:dev:yarn: + dir: frontend + cmds: + - yarn dev --port {{.VITE_PORT}} --strictPort + + frontend:dev:pnpm: + dir: frontend + cmds: + - pnpm dev --port {{.VITE_PORT}} --strictPort + + frontend:dev:bun: + dir: frontend + cmds: + - bun run dev --port {{.VITE_PORT}} --strictPort + + update:build-assets: + summary: Updates the build assets + dir: build + cmds: + - wails3 update build-assets -name "{{.APP_NAME}}" -binaryname "{{.APP_NAME}}" -config config.yml -dir . + + build:server: + summary: Builds the application in server mode (no GUI, HTTP server only) + desc: | + Builds a production server binary by default: -tags server,production, + -trimpath and a stripped binary, mirroring the desktop `build` task. + Server mode runs as a pure HTTP server without native GUI dependencies. + + Usage: task build:server [DEV=true] [OBFUSCATED=true] [EXTRA_TAGS=tag1,tag2] + DEV=true development server (-tags server, no strip, inlining kept) + OBFUSCATED=true obfuscated build via garble (requires garble installed) + EXTRA_TAGS additional comma-separated build tags + deps: + - task: build:frontend + vars: + DEV: + ref: .DEV + BUILD_FLAGS: + ref: .BUILD_FLAGS + OBFUSCATED: + ref: .OBFUSCATED + preconditions: + - sh: '{{if eq .OBFUSCATED "true"}}command -v garble >/dev/null 2>&1{{else}}true{{end}}' + msg: "garble is required for obfuscated builds. Install it with: go install mvdan.cc/garble@v0.16.0 (requires Go 1.24+). See https://github.com/burrowers/garble/releases for version/toolchain compatibility." + cmds: + - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o "{{.BIN_DIR}}/{{.APP_NAME}}-server{{exeExt}}"' + vars: + BUILD_FLAGS: '-tags server{{if eq .DEV "true"}}{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -buildvcs=false -gcflags=all="-l"{{else}},production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s"{{end}}' + + run:server: + summary: Builds and runs a development server (DEV=true) + deps: + - task: build:server + vars: + DEV: "true" + cmds: + - '"./{{.BIN_DIR}}/{{.APP_NAME}}-server{{exeExt}}"' + + build:docker: + summary: Builds a Docker image for server mode deployment + desc: | + Creates a minimal Docker image containing the production server binary. + Defaults to a pure-Go static binary on a distroless/static base. The + production frontend is built first so the embedded assets are current. + + Usage: task build:docker [TAG=myapp:latest] [CGO_ENABLED=1] [GO_IMAGE=...] [RUNTIME_IMAGE=...] + For CGO apps, set CGO_ENABLED=1 with libc-compatible builder/runtime images, e.g.: + task build:docker CGO_ENABLED=1 GO_IMAGE=golang:bookworm RUNTIME_IMAGE=gcr.io/distroless/base-debian12 + deps: + # Build the production frontend so frontend/dist (embedded by the Go build + # inside the image) is present and current in the Docker build context. + # Pass the server,production tags so binding generation analyses the same + # build the Docker image compiles, not the default-tag build. + - task: build:frontend + vars: + BUILD_FLAGS: "-tags server,production" + cmds: + - >- + docker build + --build-arg CGO_ENABLED={{.CGO_ENABLED | default "0"}} + --build-arg GO_IMAGE={{.GO_IMAGE | default "golang:alpine"}} + --build-arg RUNTIME_IMAGE={{.RUNTIME_IMAGE | default "gcr.io/distroless/static-debian12"}} + -t {{.TAG | default (printf "%s:latest" .APP_NAME)}} + -f build/docker/Dockerfile.server . + vars: + TAG: "{{.TAG}}" + preconditions: + - sh: docker info > /dev/null 2>&1 + msg: "Docker is required. Please install Docker first." + - sh: test -f build/docker/Dockerfile.server + msg: "Dockerfile.server not found. Run 'wails3 update build-assets' to generate it." + + run:docker: + summary: Builds and runs the Docker image + desc: | + Builds the Docker image and runs it, exposing port 8080. + Usage: task run:docker [TAG=myapp:latest] [PORT=8080] + Note: The internal container port is always 8080. The PORT variable + only changes the host port mapping. Ensure your app uses port 8080 + or modify the Dockerfile to match your ServerOptions.Port setting. + deps: + - task: build:docker + vars: + TAG: + ref: .TAG + cmds: + - docker run --rm -p {{.PORT | default "8080"}}:8080 {{.TAG | default (printf "%s:latest" .APP_NAME)}} + vars: + TAG: "{{.TAG}}" + PORT: "{{.PORT}}" + + setup:docker: + summary: Builds Docker image for cross-compilation (~800MB download) + desc: | + Builds the Docker image needed for cross-compiling to any platform. + Run this once to enable cross-platform builds from any OS. + cmds: + - docker build -t wails-cross -f build/docker/Dockerfile.cross build/docker/ + preconditions: + - sh: docker info > /dev/null 2>&1 + msg: "Docker is required. Please install Docker first." + + ios:device:list: + summary: Lists connected iOS devices (UDIDs) + cmds: + - xcrun xcdevice list + + ios:run:device: + summary: Build, install, and launch on a physical iPhone using Apple tools (xcodebuild/devicectl) + vars: + PROJECT: '{{.PROJECT}}' # e.g., build/ios/xcode/.xcodeproj + SCHEME: '{{.SCHEME}}' # e.g., ios.dev + CONFIG: '{{.CONFIG | default "Debug"}}' + DERIVED: '{{.DERIVED | default "build/ios/DerivedData"}}' + UDID: '{{.UDID}}' # from `task ios:device:list` + BUNDLE_ID: '{{.BUNDLE_ID}}' # e.g., com.yourco.wails.ios.dev + TEAM_ID: '{{.TEAM_ID}}' # optional, if your project is not already set up for signing + preconditions: + - sh: xcrun -f xcodebuild + msg: "xcodebuild not found. Please install Xcode." + - sh: xcrun -f devicectl + msg: "devicectl not found. Please update to Xcode 15+ (which includes devicectl)." + - sh: test -n '{{.PROJECT}}' + msg: "Set PROJECT to your .xcodeproj path (e.g., PROJECT=build/ios/xcode/App.xcodeproj)." + - sh: test -n '{{.SCHEME}}' + msg: "Set SCHEME to your app scheme (e.g., SCHEME=ios.dev)." + - sh: test -n '{{.UDID}}' + msg: "Set UDID to your device UDID (see: task ios:device:list)." + - sh: test -n '{{.BUNDLE_ID}}' + msg: "Set BUNDLE_ID to your app's bundle identifier (e.g., com.yourco.wails.ios.dev)." + cmds: + - | + set -euo pipefail + echo "Building for device: UDID={{.UDID}} SCHEME={{.SCHEME}} PROJECT={{.PROJECT}}" + XCB_ARGS=( + -project "{{.PROJECT}}" + -scheme "{{.SCHEME}}" + -configuration "{{.CONFIG}}" + -destination "id={{.UDID}}" + -derivedDataPath "{{.DERIVED}}" + -allowProvisioningUpdates + -allowProvisioningDeviceRegistration + ) + # Optionally inject signing identifiers if provided + if [ -n '{{.TEAM_ID}}' ]; then XCB_ARGS+=(DEVELOPMENT_TEAM={{.TEAM_ID}}); fi + if [ -n '{{.BUNDLE_ID}}' ]; then XCB_ARGS+=(PRODUCT_BUNDLE_IDENTIFIER={{.BUNDLE_ID}}); fi + xcodebuild "${XCB_ARGS[@]}" build | xcpretty || true + # If xcpretty isn't installed, run without it + if [ "${PIPESTATUS[0]}" -ne 0 ]; then + xcodebuild "${XCB_ARGS[@]}" build + fi + # Find built .app + APP_PATH=$(find "{{.DERIVED}}/Build/Products" -type d -name "*.app" -maxdepth 3 | head -n 1) + if [ -z "$APP_PATH" ]; then + echo "Could not locate built .app under {{.DERIVED}}/Build/Products" >&2 + exit 1 + fi + echo "Installing: $APP_PATH" + xcrun devicectl device install app --device "{{.UDID}}" "$APP_PATH" + echo "Launching: {{.BUNDLE_ID}}" + xcrun devicectl device process launch --device "{{.UDID}}" --stderr console --stdout console "{{.BUNDLE_ID}}" diff --git a/cmd/npc/npc-gui/build/appicon.icon/Assets/wails_icon_vector.svg b/cmd/npc/npc-gui/build/appicon.icon/Assets/wails_icon_vector.svg new file mode 100644 index 0000000..b099222 --- /dev/null +++ b/cmd/npc/npc-gui/build/appicon.icon/Assets/wails_icon_vector.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/cmd/npc/npc-gui/build/appicon.icon/icon.json b/cmd/npc/npc-gui/build/appicon.icon/icon.json new file mode 100644 index 0000000..e11fb93 --- /dev/null +++ b/cmd/npc/npc-gui/build/appicon.icon/icon.json @@ -0,0 +1,51 @@ +{ + "fill" : { + "automatic-gradient" : "extended-gray:1.00000,1.00000" + }, + "groups" : [ + { + "layers" : [ + { + "fill-specializations" : [ + { + "appearance" : "dark", + "value" : { + "solid" : "srgb:0.92143,0.92145,0.92144,1.00000" + } + }, + { + "appearance" : "tinted", + "value" : { + "solid" : "srgb:0.83742,0.83744,0.83743,1.00000" + } + } + ], + "image-name" : "wails_icon_vector.svg", + "name" : "wails_icon_vector", + "position" : { + "scale" : 0.85, + "translation-in-points" : [ + 0.0, + 0.0 + ] + } + } + ], + "shadow" : { + "kind" : "neutral", + "opacity" : 0.5 + }, + "specular" : true, + "translucency" : { + "enabled" : true, + "value" : 0.5 + } + } + ], + "supported-platforms" : { + "circles" : [ + "watchOS" + ], + "squares" : "shared" + } +} diff --git a/cmd/npc/npc-gui/build/config.yml b/cmd/npc/npc-gui/build/config.yml new file mode 100644 index 0000000..9d49291 --- /dev/null +++ b/cmd/npc/npc-gui/build/config.yml @@ -0,0 +1,79 @@ +# This file contains the configuration for this project. +# When you update `info` or `fileAssociations`, run `wails3 task common:update:build-assets` to update the assets. +# Note that this will overwrite any changes you have made to the assets. +version: '3' + +# This information is used to generate the build assets. +info: + companyName: "My Company" # The name of the company + productName: "My Product" # The name of the application + productIdentifier: "com.mycompany.myproduct" # The unique product identifier + description: "A program that does X" # The application description + copyright: "(c) 2025, My Company" # Copyright text + comments: "Some Product Comments" # Comments + version: "0.0.1" # The application version + # cfBundleIconName: "appicon" # The macOS icon name in Assets.car icon bundles (optional) + # # Should match the name of your .icon file without the extension + # # If not set and Assets.car exists, defaults to "appicon" + +# iOS build configuration (uncomment to customise iOS project generation) +# Note: Keys under `ios` OVERRIDE values under `info` when set. +# ios: +# # The iOS bundle identifier used in the generated Xcode project (CFBundleIdentifier) +# bundleID: "com.mycompany.myproduct" +# # The display name shown under the app icon (CFBundleDisplayName/CFBundleName) +# displayName: "My Product" +# # The app version to embed in Info.plist (CFBundleShortVersionString/CFBundleVersion) +# version: "0.0.1" +# # The company/organisation name for templates and project settings +# company: "My Company" +# # Additional comments to embed in Info.plist metadata +# comments: "Some Product Comments" + +# Dev mode configuration +dev_mode: + root_path: . + log_level: warn + debounce: 1000 + ignore: + dir: + - .git + - node_modules + - frontend + - bin + file: + - .DS_Store + - .gitignore + - .gitkeep + - "*_test.go" + watched_extension: + - "*.go" + - "*.js" # Watch for changes to JS/TS files included using the //wails:include directive. + - "*.ts" # The frontend directory will be excluded entirely by the setting above. + git_ignore: true + executes: + - cmd: wails3 build DEV=true + type: blocking + - cmd: wails3 task common:dev:frontend + type: background + - cmd: wails3 task run + type: primary + +# File Associations +# More information at: https://v3.wails.io/noit/done/yet +fileAssociations: +# - ext: wails +# name: Wails +# description: Wails Application File +# iconName: wailsFileIcon +# role: Editor +# - ext: jpg +# name: JPEG +# description: Image File +# iconName: jpegFileIcon +# role: Editor +# mimeType: image/jpeg # (optional) + +# Other data +other: + - name: My Other Data \ No newline at end of file diff --git a/cmd/npc/npc-gui/build/darwin/Assets.car b/cmd/npc/npc-gui/build/darwin/Assets.car new file mode 100644 index 0000000..32e5ad9 Binary files /dev/null and b/cmd/npc/npc-gui/build/darwin/Assets.car differ diff --git a/cmd/npc/npc-gui/build/darwin/Info.dev.plist b/cmd/npc/npc-gui/build/darwin/Info.dev.plist new file mode 100644 index 0000000..df8e655 --- /dev/null +++ b/cmd/npc/npc-gui/build/darwin/Info.dev.plist @@ -0,0 +1,34 @@ + + + + CFBundlePackageType + APPL + CFBundleName + NPS Client + CFBundleExecutable + npc-gui + CFBundleIdentifier + com.nps.client + CFBundleVersion + 0.26.38 + CFBundleGetInfoString + NPS 客户端 + CFBundleShortVersionString + 0.26.38 + CFBundleIconFile + icons + CFBundleIconName + appicon + LSMinimumSystemVersion + 12.0.0 + NSHighResolutionCapable + true + NSHumanReadableCopyright + Copyright © 2026 NPS + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + + \ No newline at end of file diff --git a/cmd/npc/npc-gui/build/darwin/Info.plist b/cmd/npc/npc-gui/build/darwin/Info.plist new file mode 100644 index 0000000..35d67f6 --- /dev/null +++ b/cmd/npc/npc-gui/build/darwin/Info.plist @@ -0,0 +1,29 @@ + + + + CFBundlePackageType + APPL + CFBundleName + NPS Client + CFBundleExecutable + npc-gui + CFBundleIdentifier + com.nps.client + CFBundleVersion + 0.26.38 + CFBundleGetInfoString + NPS 客户端 + CFBundleShortVersionString + 0.26.38 + CFBundleIconFile + icons + CFBundleIconName + appicon + LSMinimumSystemVersion + 12.0.0 + NSHighResolutionCapable + true + NSHumanReadableCopyright + Copyright © 2026 NPS + + \ No newline at end of file diff --git a/cmd/npc/npc-gui/build/darwin/Taskfile.yml b/cmd/npc/npc-gui/build/darwin/Taskfile.yml new file mode 100644 index 0000000..e3ee1ee --- /dev/null +++ b/cmd/npc/npc-gui/build/darwin/Taskfile.yml @@ -0,0 +1,220 @@ +version: '3' + +includes: + common: ../Taskfile.yml + +vars: + # Docker image for cross-compilation (used when building on non-macOS) + CROSS_IMAGE: wails-cross + +tasks: + build: + summary: Builds the application + cmds: + - task: '{{if eq OS "darwin"}}build:native{{else}}build:docker{{end}}' + vars: + ARCH: '{{.ARCH}}' + DEV: '{{.DEV}}' + OUTPUT: '{{.OUTPUT}}' + EXTRA_TAGS: '{{.EXTRA_TAGS}}' + OBFUSCATED: '{{.OBFUSCATED}}' + GARBLE_ARGS: '{{.GARBLE_ARGS}}' + vars: + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + + build:native: + summary: Builds the application natively on macOS + internal: true + deps: + - task: common:go:mod:tidy + - task: common:build:frontend + vars: + BUILD_FLAGS: + ref: .BUILD_FLAGS + OBFUSCATED: + ref: .OBFUSCATED + DEV: + ref: .DEV + - task: common:generate:icons + preconditions: + - sh: '{{if eq .OBFUSCATED "true"}}command -v garble >/dev/null 2>&1{{else}}true{{end}}' + msg: "garble is required for obfuscated builds. Install it with: go install mvdan.cc/garble@v0.16.0 (requires Go 1.24+). See https://github.com/burrowers/garble/releases for version/toolchain compatibility." + cmds: + - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o "{{.OUTPUT}}"' + vars: + BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s"{{end}}' + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + env: + GOOS: darwin + CGO_ENABLED: 1 + GOARCH: '{{.ARCH | default ARCH}}' + CGO_CFLAGS: "-mmacosx-version-min=12.0" + CGO_LDFLAGS: "-mmacosx-version-min=12.0" + MACOSX_DEPLOYMENT_TARGET: "12.0" + + build:docker: + summary: Cross-compiles for macOS using Docker (for Linux/Windows hosts) + internal: true + deps: + - task: common:build:frontend + vars: + OBFUSCATED: + ref: .OBFUSCATED + - task: common:generate:icons + preconditions: + - sh: docker info > /dev/null 2>&1 + msg: "Docker is required for cross-compilation. Please install Docker." + - sh: docker image inspect {{.CROSS_IMAGE}} > /dev/null 2>&1 + msg: | + Docker image '{{.CROSS_IMAGE}}' not found. + Build it first: wails3 task setup:docker + cmds: + - docker run --rm -v "{{.ROOT_DIR}}:/app" {{.DOCKER_MOUNTS}} -e APP_NAME="{{.APP_NAME}}" {{if .EXTRA_TAGS}}-e EXTRA_TAGS="{{.EXTRA_TAGS}}"{{end}} {{if eq .OBFUSCATED "true"}}-e OBFUSCATED=true{{end}} {{if .GARBLE_ARGS}}-e GARBLE_ARGS="{{.GARBLE_ARGS}}"{{end}} {{.CROSS_IMAGE}} darwin {{.DOCKER_ARCH}} + - cmd: docker run --rm -v "{{.ROOT_DIR}}:/app" alpine chown -R $(id -u):$(id -g) /app/bin + platforms: [linux, darwin] + - mkdir -p {{.BIN_DIR}} + - mv "bin/{{.APP_NAME}}-darwin-{{.DOCKER_ARCH}}" "{{.OUTPUT}}" + vars: + DOCKER_ARCH: '{{if eq .ARCH "arm64"}}arm64{{else if eq .ARCH "amd64"}}amd64{{else}}arm64{{end}}' + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + # Generate Docker volume mounts: Go module cache + go.mod replace directives + # Uses wails3 tool docker-mounts for cross-platform compatibility (Windows/Linux/macOS) + DOCKER_MOUNTS: + sh: 'wails3 tool docker-mounts' + + build:universal: + summary: Builds darwin universal binary (arm64 + amd64) + deps: + - task: build + vars: + ARCH: amd64 + OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" + - task: build + vars: + ARCH: arm64 + OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" + cmds: + - task: '{{if eq OS "darwin"}}build:universal:lipo:native{{else}}build:universal:lipo:go{{end}}' + + build:universal:lipo:native: + summary: Creates universal binary using native lipo (macOS) + internal: true + cmds: + - lipo -create -output "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" + - rm "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" + + build:universal:lipo:go: + summary: Creates universal binary using wails3 tool lipo (Linux/Windows) + internal: true + cmds: + - wails3 tool lipo -output "{{.BIN_DIR}}/{{.APP_NAME}}" -input "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" -input "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" + - rm -f "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" + + package: + summary: Packages the application into a `.app` bundle + deps: + - task: build + cmds: + - task: create:app:bundle + + package:universal: + summary: Packages darwin universal binary (arm64 + amd64) + deps: + - task: build:universal + cmds: + - task: create:app:bundle + + package:dmg: + summary: Packages the application into a styled `.dmg` + deps: + - task: package + cmds: + - task: create:dmg + + create:dmg: + summary: Creates a configurable `.dmg` from the `.app` bundle + platforms: [darwin] + cmds: + - >- + wails3 tool package --format dmg --name "{{.APP_NAME}}" --out "{{.BIN_DIR}}" + --background "{{.DMG_BACKGROUND}}" + --volume-icon "{{.DMG_VOLUME_ICON}}" + --file-icon "{{.DMG_FILE_ICON}}" + --window-width "{{.DMG_WINDOW_WIDTH}}" + --window-height "{{.DMG_WINDOW_HEIGHT}}" + {{if .DMG_FILES}}--files "{{.DMG_FILES}}"{{end}} + vars: + DMG_BACKGROUND: '{{.DMG_BACKGROUND | default "build/darwin/dmg-background.png"}}' + DMG_VOLUME_ICON: '{{.DMG_VOLUME_ICON | default "build/darwin/icons.icns"}}' + DMG_FILE_ICON: '{{.DMG_FILE_ICON | default "build/darwin/dmg-file-icon.icns"}}' + DMG_WINDOW_WIDTH: '{{.DMG_WINDOW_WIDTH | default "540"}}' + DMG_WINDOW_HEIGHT: '{{.DMG_WINDOW_HEIGHT | default "380"}}' + DMG_FILES: '{{.DMG_FILES | default ""}}' + + + create:app:bundle: + summary: Creates an `.app` bundle + cmds: + - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS" + - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources" + - cp build/darwin/icons.icns "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources" + - | + if [ -f build/darwin/Assets.car ]; then + cp build/darwin/Assets.car "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources" + fi + - cp "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS" + - cp build/darwin/Info.plist "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents" + - task: '{{if eq OS "darwin"}}codesign:adhoc{{else}}codesign:skip{{end}}' + + codesign:adhoc: + summary: Ad-hoc signs the app bundle (macOS only) + internal: true + cmds: + - codesign --force --deep --sign - "{{.BIN_DIR}}/{{.APP_NAME}}.app" + + codesign:skip: + summary: Skips codesigning when cross-compiling + internal: true + cmds: + - 'echo "Skipping codesign (not available on {{OS}}). Sign the .app on macOS before distribution."' + + run: + cmds: + - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS" + - mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources" + - cp build/darwin/icons.icns "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources" + - | + if [ -f build/darwin/Assets.car ]; then + cp build/darwin/Assets.car "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources" + fi + - cp "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS" + - cp "build/darwin/Info.dev.plist" "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Info.plist" + - codesign --force --deep --sign - "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app" + - '"{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS/{{.APP_NAME}}"' + + sign: + summary: Signs the application bundle with Developer ID + desc: | + Signs the .app bundle for distribution. + Uses signing identity from `wails3 setup` (stored in ~/.config/wails/defaults.yaml). + Override with: task darwin:sign -- --identity "Developer ID Application: ..." + deps: + - task: package + cmds: + - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}.app" {{.CLI_ARGS}} + + sign:notarize: + summary: Signs and notarizes the application bundle + desc: | + Signs the .app bundle and submits it for notarization. + Uses signing identity and keychain profile from `wails3 setup`. + + First-time setup: + wails3 setup + deps: + - task: package + cmds: + - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}.app" --notarize {{.CLI_ARGS}} diff --git a/cmd/npc/npc-gui/build/darwin/dmg-background.png b/cmd/npc/npc-gui/build/darwin/dmg-background.png new file mode 100644 index 0000000..ab099c8 Binary files /dev/null and b/cmd/npc/npc-gui/build/darwin/dmg-background.png differ diff --git a/cmd/npc/npc-gui/build/darwin/dmg-file-icon.icns b/cmd/npc/npc-gui/build/darwin/dmg-file-icon.icns new file mode 100644 index 0000000..6817187 Binary files /dev/null and b/cmd/npc/npc-gui/build/darwin/dmg-file-icon.icns differ diff --git a/cmd/npc/npc-gui/build/darwin/dmg-file-icon.png b/cmd/npc/npc-gui/build/darwin/dmg-file-icon.png new file mode 100644 index 0000000..cec0a40 Binary files /dev/null and b/cmd/npc/npc-gui/build/darwin/dmg-file-icon.png differ diff --git a/cmd/npc/npc-gui/build/darwin/icons.icns b/cmd/npc/npc-gui/build/darwin/icons.icns new file mode 100644 index 0000000..4138775 Binary files /dev/null and b/cmd/npc/npc-gui/build/darwin/icons.icns differ diff --git a/cmd/npc/npc-gui/build/docker/Dockerfile.cross b/cmd/npc/npc-gui/build/docker/Dockerfile.cross new file mode 100644 index 0000000..54915c6 --- /dev/null +++ b/cmd/npc/npc-gui/build/docker/Dockerfile.cross @@ -0,0 +1,225 @@ +# Cross-compile Wails v3 apps to any platform +# +# Darwin: Zig + macOS SDK +# Linux: Native GCC when host matches target, Zig for cross-arch +# Windows: Zig + bundled mingw +# +# Usage: +# docker build -t wails-cross -f Dockerfile.cross . +# docker run --rm -v $(pwd):/app wails-cross darwin arm64 +# docker run --rm -v $(pwd):/app wails-cross darwin amd64 +# docker run --rm -v $(pwd):/app wails-cross linux amd64 +# docker run --rm -v $(pwd):/app wails-cross linux arm64 +# docker run --rm -v $(pwd):/app wails-cross windows amd64 +# docker run --rm -v $(pwd):/app wails-cross windows arm64 + +# Debian 13 provides the GTK >= 4.14 API baseline used by the default Linux backend. +FROM golang:1.26-trixie + +ARG TARGETARCH +ARG GARBLE_VERSION=v0.16.0 + +# Install base tools, GCC, and GTK/WebKit dev packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl xz-utils python3 nodejs npm pkg-config gcc libc6-dev \ + libgtk-3-dev libwebkit2gtk-4.1-dev \ + libgtk-4-dev libwebkitgtk-6.0-dev \ + && pkg-config --atleast-version=4.14 gtk4 \ + && pkg-config --exists webkitgtk-6.0 \ + && pkg-config --exists gtk+-3.0 \ + && pkg-config --exists webkit2gtk-4.1 \ + && rm -rf /var/lib/apt/lists/* + +RUN go install mvdan.cc/garble@${GARBLE_VERSION} + +# Install Zig - automatically selects correct binary for host architecture. +# The SHA-256 is fetched from Zig's official download manifest and verified +# before extraction to protect against MITM or corrupted downloads. +ARG ZIG_VERSION=0.14.0 +RUN ZIG_ARCH=$(case "${TARGETARCH}" in arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \ + ZIG_FILE="zig-linux-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz" && \ + curl -fSL "https://ziglang.org/download/${ZIG_VERSION}/${ZIG_FILE}" -o "/tmp/${ZIG_FILE}" && \ + EXPECTED=$(curl -fsSL "https://ziglang.org/download/index.json" | \ + python3 -c "import json,sys; d=json.load(sys.stdin); print(d[sys.argv[1]][sys.argv[2]+'-linux']['shasum'])" \ + "${ZIG_VERSION}" "${ZIG_ARCH}") && \ + echo "${EXPECTED} /tmp/${ZIG_FILE}" | sha256sum -c - && \ + tar -xJ -f "/tmp/${ZIG_FILE}" -C /opt && \ + rm "/tmp/${ZIG_FILE}" && \ + ln -s /opt/zig-linux-${ZIG_ARCH}-${ZIG_VERSION}/zig /usr/local/bin/zig + +# Download macOS SDK (required for darwin targets) +ARG MACOS_SDK_VERSION=14.5 +RUN curl -L "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK_VERSION}/MacOSX${MACOS_SDK_VERSION}.sdk.tar.xz" \ + | tar -xJ -C /opt \ + && mv /opt/MacOSX${MACOS_SDK_VERSION}.sdk /opt/macos-sdk + +ENV MACOS_SDK_PATH=/opt/macos-sdk + +# Create Zig CC wrappers for cross-compilation targets +# Darwin and Windows use Zig; Linux uses native GCC (run with --platform for cross-arch) + +# Darwin arm64 +COPY <<'ZIGWRAP' /usr/local/bin/zcc-darwin-arm64 +#!/bin/sh +ARGS="" +SKIP_NEXT=0 +for arg in "$@"; do + if [ $SKIP_NEXT -eq 1 ]; then + SKIP_NEXT=0 + continue + fi + case "$arg" in + -target) SKIP_NEXT=1 ;; + -mmacosx-version-min=*) ;; + *) ARGS="$ARGS $arg" ;; + esac +done +exec zig cc -fno-sanitize=all -target aarch64-macos-none -isysroot /opt/macos-sdk -I/opt/macos-sdk/usr/include -L/opt/macos-sdk/usr/lib -F/opt/macos-sdk/System/Library/Frameworks -w $ARGS +ZIGWRAP +RUN chmod +x /usr/local/bin/zcc-darwin-arm64 + +# Darwin amd64 +COPY <<'ZIGWRAP' /usr/local/bin/zcc-darwin-amd64 +#!/bin/sh +ARGS="" +SKIP_NEXT=0 +for arg in "$@"; do + if [ $SKIP_NEXT -eq 1 ]; then + SKIP_NEXT=0 + continue + fi + case "$arg" in + -target) SKIP_NEXT=1 ;; + -mmacosx-version-min=*) ;; + *) ARGS="$ARGS $arg" ;; + esac +done +exec zig cc -fno-sanitize=all -target x86_64-macos-none -isysroot /opt/macos-sdk -I/opt/macos-sdk/usr/include -L/opt/macos-sdk/usr/lib -F/opt/macos-sdk/System/Library/Frameworks -w $ARGS +ZIGWRAP +RUN chmod +x /usr/local/bin/zcc-darwin-amd64 + +# Windows amd64 - uses Zig's bundled mingw +COPY <<'ZIGWRAP' /usr/local/bin/zcc-windows-amd64 +#!/bin/sh +ARGS="" +SKIP_NEXT=0 +for arg in "$@"; do + if [ $SKIP_NEXT -eq 1 ]; then + SKIP_NEXT=0 + continue + fi + case "$arg" in + -target) SKIP_NEXT=1 ;; + -Wl,*) ;; + *) ARGS="$ARGS $arg" ;; + esac +done +exec zig cc -target x86_64-windows-gnu $ARGS +ZIGWRAP +RUN chmod +x /usr/local/bin/zcc-windows-amd64 + +# Windows arm64 - uses Zig's bundled mingw +COPY <<'ZIGWRAP' /usr/local/bin/zcc-windows-arm64 +#!/bin/sh +ARGS="" +SKIP_NEXT=0 +for arg in "$@"; do + if [ $SKIP_NEXT -eq 1 ]; then + SKIP_NEXT=0 + continue + fi + case "$arg" in + -target) SKIP_NEXT=1 ;; + -Wl,*) ;; + *) ARGS="$ARGS $arg" ;; + esac +done +exec zig cc -target aarch64-windows-gnu $ARGS +ZIGWRAP +RUN chmod +x /usr/local/bin/zcc-windows-arm64 + +# Build script +COPY <<'SCRIPT' /usr/local/bin/build.sh +#!/bin/sh +set -e + +OS=${1:-darwin} +ARCH=${2:-arm64} + +case "${OS}-${ARCH}" in + darwin-arm64|darwin-aarch64) + export CC=zcc-darwin-arm64 + export GOARCH=arm64 + export GOOS=darwin + ;; + darwin-amd64|darwin-x86_64) + export CC=zcc-darwin-amd64 + export GOARCH=amd64 + export GOOS=darwin + ;; + linux-arm64|linux-aarch64) + export CC=gcc + export GOARCH=arm64 + export GOOS=linux + ;; + linux-amd64|linux-x86_64) + export CC=gcc + export GOARCH=amd64 + export GOOS=linux + ;; + windows-arm64|windows-aarch64) + export CC=zcc-windows-arm64 + export GOARCH=arm64 + export GOOS=windows + ;; + windows-amd64|windows-x86_64) + export CC=zcc-windows-amd64 + export GOARCH=amd64 + export GOOS=windows + ;; + *) + echo "Usage: " + echo " os: darwin, linux, windows" + echo " arch: amd64, arm64" + exit 1 + ;; +esac + +export CGO_ENABLED=1 +export CGO_CFLAGS="-w" + +# Build frontend if exists and not already built (host may have built it) +if [ -d "frontend" ] && [ -f "frontend/package.json" ] && [ ! -d "frontend/dist" ]; then + (cd frontend && npm install --silent && npm run build --silent) +fi + +# Build +APP=${APP_NAME:-$(basename $(pwd))} +mkdir -p bin + +EXT="" +LDFLAGS="-s -w" +if [ "$GOOS" = "windows" ]; then + EXT=".exe" + LDFLAGS="-s -w -H windowsgui" +fi + +TAGS="production" +if [ -n "$EXTRA_TAGS" ]; then + TAGS="${TAGS},${EXTRA_TAGS}" +fi + +COMPILER="go build" +if [ "$OBFUSCATED" = "true" ]; then + COMPILER="garble ${GARBLE_ARGS} build" + TAGS="${TAGS},wails_obfuscated" +fi + +${COMPILER} -tags "$TAGS" -trimpath -buildvcs=false -ldflags="$LDFLAGS" -o bin/${APP}-${GOOS}-${GOARCH}${EXT} . +echo "Built: bin/${APP}-${GOOS}-${GOARCH}${EXT}" +SCRIPT +RUN chmod +x /usr/local/bin/build.sh + +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/build.sh"] +CMD ["darwin", "arm64"] diff --git a/cmd/npc/npc-gui/build/docker/Dockerfile.server b/cmd/npc/npc-gui/build/docker/Dockerfile.server new file mode 100644 index 0000000..7afbae3 --- /dev/null +++ b/cmd/npc/npc-gui/build/docker/Dockerfile.server @@ -0,0 +1,67 @@ +# Wails Server Mode Dockerfile +# Multi-stage build for a minimal image. +# +# Defaults produce a pure-Go, fully static binary on a distroless/static base: +# the smallest, most secure image, and correct for the default (CGO-free) app. +# +# If your app needs CGO, override the build args, e.g.: +# docker build --build-arg CGO_ENABLED=1 \ +# --build-arg GO_IMAGE=golang:bookworm \ +# --build-arg RUNTIME_IMAGE=gcr.io/distroless/base-debian12 \ +# -f build/docker/Dockerfile.server . +# CGO needs a C toolchain in the builder and a libc in the runtime image; keep +# the builder and runtime libc compatible (a glibc builder -> a glibc runtime). +# The Taskfile passes these through: task build:docker CGO_ENABLED=1 GO_IMAGE=... RUNTIME_IMAGE=... + +ARG GO_IMAGE=golang:alpine +ARG RUNTIME_IMAGE=gcr.io/distroless/static-debian12 +ARG CGO_ENABLED=0 + +# Build stage +FROM ${GO_IMAGE} AS builder +ARG CGO_ENABLED + +WORKDIR /app + +# Install build dependencies: git always; a C compiler only when CGO is enabled. +# Supports both apk (alpine) and apt (debian/bookworm) base images. +RUN if command -v apk >/dev/null 2>&1; then \ + apk add --no-cache git $([ "$CGO_ENABLED" = "1" ] && echo gcc musl-dev); \ + else \ + apt-get update && apt-get install -y --no-install-recommends git $([ "$CGO_ENABLED" = "1" ] && echo gcc libc6-dev) && rm -rf /var/lib/apt/lists/*; \ + fi + +# Copy source code +COPY . . + +# Remove local replace directive if present (for production builds) +RUN sed -i '/^replace/d' go.mod || true + +# Download dependencies +RUN go mod tidy + +# Build the production server binary. +# - server,production tags: HTTP server mode with production code paths (no dev +# logger/asset middleware), matching the desktop production build. +# - CGO_ENABLED defaults to 0 for a fully static binary (distroless/static); +# override with --build-arg CGO_ENABLED=1 (see header) for CGO apps. +RUN CGO_ENABLED=${CGO_ENABLED} go build -tags server,production -trimpath -buildvcs=false -ldflags="-s -w" -o server . + +# Runtime stage - minimal image +FROM ${RUNTIME_IMAGE} + +# Copy the binary +COPY --from=builder /app/server /server + +# Copy frontend assets +COPY --from=builder /app/frontend/dist /frontend/dist + +# Expose the default port +EXPOSE 8080 + +# Bind to all interfaces (required for Docker) +# Can be overridden at runtime with -e WAILS_SERVER_HOST=... +ENV WAILS_SERVER_HOST=0.0.0.0 + +# Run the server +ENTRYPOINT ["/server"] diff --git a/cmd/npc/npc-gui/build/linux/Taskfile.yml b/cmd/npc/npc-gui/build/linux/Taskfile.yml new file mode 100644 index 0000000..496ee95 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/Taskfile.yml @@ -0,0 +1,220 @@ +version: '3' + +includes: + common: ../Taskfile.yml + +vars: + # Signing configuration - edit these values for your project + # PGP_KEY: "path/to/signing-key.asc" + # SIGN_ROLE: "builder" # Options: origin, maint, archive, builder + # + # Password is stored securely in system keychain. Run: wails3 setup signing + + # Docker image for cross-compilation (used when building on non-Linux or no CC available) + CROSS_IMAGE: wails-cross + +tasks: + build: + summary: Builds the application for Linux + cmds: + # Linux requires CGO - use Docker when: + # 1. Cross-compiling from non-Linux, OR + # 2. No C compiler is available, OR + # 3. Target architecture differs from host architecture (cross-arch compilation) + - task: '{{if and (eq OS "linux") (eq .HAS_CC "true") (eq .TARGET_ARCH ARCH)}}build:native{{else}}build:docker{{end}}' + vars: + ARCH: '{{.ARCH}}' + DEV: '{{.DEV}}' + OUTPUT: '{{.OUTPUT}}' + EXTRA_TAGS: '{{.EXTRA_TAGS}}' + OBFUSCATED: '{{.OBFUSCATED}}' + GARBLE_ARGS: '{{.GARBLE_ARGS}}' + vars: + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + # Determine target architecture (defaults to host ARCH if not specified) + TARGET_ARCH: '{{.ARCH | default ARCH}}' + # Check if a C compiler is available (gcc or clang) — cross-platform via wails3 tool + HAS_CC: + sh: 'wails3 tool has "gcc|clang"' + + build:native: + summary: Builds the application natively on Linux + internal: true + deps: + - task: common:go:mod:tidy + - task: common:build:frontend + vars: + BUILD_FLAGS: + ref: .BUILD_FLAGS + OBFUSCATED: + ref: .OBFUSCATED + DEV: + ref: .DEV + - task: common:generate:icons + - task: generate:dotdesktop + preconditions: + - sh: '{{if eq .OBFUSCATED "true"}}command -v garble >/dev/null 2>&1{{else}}true{{end}}' + msg: "garble is required for obfuscated builds. Install it with: go install mvdan.cc/garble@v0.16.0 (requires Go 1.24+). See https://github.com/burrowers/garble/releases for version/toolchain compatibility." + cmds: + - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o {{.OUTPUT}}' + vars: + BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s"{{end}}' + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + env: + GOOS: linux + CGO_ENABLED: 1 + GOARCH: '{{.ARCH | default ARCH}}' + + build:docker: + summary: Builds for Linux using Docker (for non-Linux hosts or when no C compiler available) + internal: true + deps: + - task: common:build:frontend + vars: + OBFUSCATED: + ref: .OBFUSCATED + - task: common:generate:icons + - task: generate:dotdesktop + preconditions: + - sh: docker info > /dev/null 2>&1 + msg: "Docker is required for cross-compilation to Linux. Please install Docker." + - sh: docker image inspect {{.CROSS_IMAGE}} > /dev/null 2>&1 + msg: | + Docker image '{{.CROSS_IMAGE}}' not found. + Build it first: wails3 task setup:docker + cmds: + - docker run --rm -v "{{.ROOT_DIR}}:/app" {{.DOCKER_MOUNTS}} -e APP_NAME="{{.APP_NAME}}" {{if .EXTRA_TAGS}}-e EXTRA_TAGS="{{.EXTRA_TAGS}}"{{end}} {{if eq .OBFUSCATED "true"}}-e OBFUSCATED=true{{end}} {{if .GARBLE_ARGS}}-e GARBLE_ARGS="{{.GARBLE_ARGS}}"{{end}} "{{.CROSS_IMAGE}}" linux {{.DOCKER_ARCH}} + - cmd: docker run --rm -v "{{.ROOT_DIR}}:/app" alpine chown -R $(id -u):$(id -g) /app/bin + platforms: [linux, darwin] + - mkdir -p {{.BIN_DIR}} + - mv "bin/{{.APP_NAME}}-linux-{{.DOCKER_ARCH}}" "{{.OUTPUT}}" + vars: + DOCKER_ARCH: '{{.ARCH | default "amd64"}}' + DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}' + OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}' + # Generate Docker volume mounts: Go module cache + go.mod replace directives + # Uses wails3 tool docker-mounts for cross-platform compatibility (Windows/Linux/macOS) + DOCKER_MOUNTS: + sh: 'wails3 tool docker-mounts' + + package: + summary: Packages the application for Linux + deps: + - task: build + cmds: + - task: create:appimage + - task: create:deb + - task: create:rpm + - task: create:aur + + create:appimage: + summary: Creates an AppImage + dir: build/linux/appimage + deps: + - task: build + - task: generate:dotdesktop + cmds: + - cp "{{.APP_BINARY}}" "{{.APP_NAME}}" + - cp ../../appicon.png "{{.APP_NAME}}.png" + - wails3 generate appimage -binary "{{.APP_NAME}}" -icon {{.ICON}} -desktopfile {{.DESKTOP_FILE}} -outputdir {{.OUTPUT_DIR}} -builddir {{.ROOT_DIR}}/build/linux/appimage/build + vars: + APP_NAME: '{{.APP_NAME}}' + APP_BINARY: '../../../bin/{{.APP_NAME}}' + ICON: '{{.APP_NAME}}.png' + DESKTOP_FILE: '../{{.APP_NAME}}.desktop' + OUTPUT_DIR: '../../../bin' + + create:deb: + summary: Creates a deb package + deps: + - task: build + cmds: + - task: generate:dotdesktop + - task: generate:deb + + create:rpm: + summary: Creates a rpm package + deps: + - task: build + cmds: + - task: generate:dotdesktop + - task: generate:rpm + + create:aur: + summary: Creates a arch linux packager package + deps: + - task: build + cmds: + - task: generate:dotdesktop + - task: generate:aur + + generate:deb: + summary: Creates a deb package + cmds: + - wails3 tool package -name "{{.APP_NAME}}" -format deb -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin + + generate:rpm: + summary: Creates a rpm package + cmds: + - wails3 tool package -name "{{.APP_NAME}}" -format rpm -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin + + generate:aur: + summary: Creates a arch linux packager package + cmds: + - wails3 tool package -name "{{.APP_NAME}}" -format archlinux -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin + + generate:dotdesktop: + summary: Generates a `.desktop` file + dir: build + cmds: + - mkdir -p {{.ROOT_DIR}}/build/linux/appimage + - wails3 generate .desktop -name "{{.APP_NAME}}" -exec "{{.EXEC}}" -icon "{{.ICON}}" -outputfile "{{.ROOT_DIR}}/build/linux/{{.APP_NAME}}.desktop" -categories "{{.CATEGORIES}}" + vars: + APP_NAME: '{{.APP_NAME}}' + EXEC: '{{.APP_NAME}}' + ICON: '{{.APP_NAME}}' + CATEGORIES: 'Development;' + OUTPUTFILE: '{{.ROOT_DIR}}/build/linux/{{.APP_NAME}}.desktop' + + run: + cmds: + - '{{.BIN_DIR}}/{{.APP_NAME}}' + + sign:deb: + summary: Signs the DEB package + desc: | + Signs the .deb package with a PGP key. + Set PGP_KEY in the vars section to override the key configured globally via + `wails3 setup` (~/.config/wails/defaults.yaml). + Password is retrieved from system keychain (run: wails3 setup signing) + deps: + - task: create:deb + cmds: + # PGP_KEY is optional: if unset, `wails3 tool sign` falls back to the key + # configured globally via `wails3 setup`. + - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}*.deb" {{if .PGP_KEY}}--pgp-key "{{.PGP_KEY}}"{{end}} {{if .SIGN_ROLE}}--role "{{.SIGN_ROLE}}"{{end}} + + sign:rpm: + summary: Signs the RPM package + desc: | + Signs the .rpm package with a PGP key. + Set PGP_KEY in the vars section to override the key configured globally via + `wails3 setup` (~/.config/wails/defaults.yaml). + Password is retrieved from system keychain (run: wails3 setup signing) + deps: + - task: create:rpm + cmds: + - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}*.rpm" {{if .PGP_KEY}}--pgp-key "{{.PGP_KEY}}"{{end}} + + sign:packages: + summary: Signs all Linux packages (DEB and RPM) + desc: | + Signs both .deb and .rpm packages with a PGP key. + Set PGP_KEY in the vars section to override the key configured globally via + `wails3 setup` (~/.config/wails/defaults.yaml). + Password is retrieved from system keychain (run: wails3 setup signing) + cmds: + - task: sign:deb + - task: sign:rpm diff --git a/cmd/npc/npc-gui/build/linux/appimage/build.sh b/cmd/npc/npc-gui/build/linux/appimage/build.sh new file mode 100644 index 0000000..85901c3 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/appimage/build.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Copyright (c) 2018-Present Lea Anthony +# SPDX-License-Identifier: MIT + +# Fail script on any error +set -euxo pipefail + +# Define variables +APP_DIR="${APP_NAME}.AppDir" + +# Create AppDir structure +mkdir -p "${APP_DIR}/usr/bin" +cp -r "${APP_BINARY}" "${APP_DIR}/usr/bin/" +cp "${ICON_PATH}" "${APP_DIR}/" +cp "${DESKTOP_FILE}" "${APP_DIR}/" + +if [[ $(uname -m) == *x86_64* ]]; then + # Download linuxdeploy and make it executable + wget -q -4 -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage + chmod +x linuxdeploy-x86_64.AppImage + + # Run linuxdeploy to bundle the application + ./linuxdeploy-x86_64.AppImage --appdir "${APP_DIR}" --output appimage +else + # Download linuxdeploy and make it executable (arm64) + wget -q -4 -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-aarch64.AppImage + chmod +x linuxdeploy-aarch64.AppImage + + # Run linuxdeploy to bundle the application (arm64) + ./linuxdeploy-aarch64.AppImage --appdir "${APP_DIR}" --output appimage +fi + +# Rename the generated AppImage +mv "${APP_NAME}*.AppImage" "${APP_NAME}.AppImage" + diff --git a/cmd/npc/npc-gui/build/linux/desktop b/cmd/npc/npc-gui/build/linux/desktop new file mode 100644 index 0000000..926a3fb --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Name=NPS Client +Comment=NPS 客户端 +# The Exec line includes %u to pass the URL to the application +Exec=/usr/local/bin/npc-gui %u +Terminal=false +Type=Application +Icon=npc-gui +Categories=Utility; +StartupWMClass=npc-gui + + diff --git a/cmd/npc/npc-gui/build/linux/nfpm/nfpm.yaml b/cmd/npc/npc-gui/build/linux/nfpm/nfpm.yaml new file mode 100644 index 0000000..9c2c452 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/nfpm/nfpm.yaml @@ -0,0 +1,80 @@ +# Feel free to remove those if you don't want/need to use them. +# Make sure to check the documentation at https://nfpm.goreleaser.com +# +# The lines below are called `modelines`. See `:help modeline` + +name: "npc-gui" +arch: ${GOARCH} +platform: "linux" +version: "0.26.38" +section: "default" +priority: "extra" +maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}> +description: "NPS 客户端" +vendor: "NPS" +homepage: "https://wails.io" +license: "MIT" +release: "1" + +contents: + - src: "./bin/npc-gui" + dst: "/usr/local/bin/npc-gui" + - src: "./build/appicon.png" + dst: "/usr/share/icons/hicolor/128x128/apps/npc-gui.png" + - src: "./build/linux/npc-gui.desktop" + dst: "/usr/share/applications/npc-gui.desktop" + +# Default dependencies for the GTK4 + WebKitGTK 6.0 stack (Ubuntu 24.04+ / Debian 13+) +depends: + - libgtk-4-1 + - libwebkitgtk-6.0-4 + +# Distribution-specific overrides for different package formats +overrides: + # RPM packages for Fedora / RHEL / AlmaLinux / Rocky Linux + rpm: + depends: + - gtk4 + - webkitgtk6.0 + + # Arch Linux packages + archlinux: + depends: + - gtk4 + - webkitgtk-6.0 + +# scripts section to ensure desktop database is updated after install +scripts: + postinstall: "./build/linux/nfpm/scripts/postinstall.sh" + # You can also add preremove, postremove if needed + # preremove: "./build/linux/nfpm/scripts/preremove.sh" + # postremove: "./build/linux/nfpm/scripts/postremove.sh" + +# If you build your app with -tags gtk3 (legacy WebKit2GTK 4.1 stack — supported through v3.0.x, removed in v3.1), +# replace the depends/overrides above with these: +# +# depends: +# - libgtk-3-0 +# - libwebkit2gtk-4.1-0 +# overrides: +# rpm: +# depends: +# - gtk3 +# - webkit2gtk4.1 +# archlinux: +# depends: +# - gtk3 +# - webkit2gtk-4.1 +# +# replaces: +# - foobar +# provides: +# - bar +# recommends: +# - whatever +# suggests: +# - something-else +# conflicts: +# - not-foo +# - not-bar +# changelog: "changelog.yaml" diff --git a/cmd/npc/npc-gui/build/linux/nfpm/scripts/postinstall.sh b/cmd/npc/npc-gui/build/linux/nfpm/scripts/postinstall.sh new file mode 100644 index 0000000..4bbb815 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/nfpm/scripts/postinstall.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Update desktop database for .desktop file changes +# This makes the application appear in application menus and registers its capabilities. +if command -v update-desktop-database >/dev/null 2>&1; then + echo "Updating desktop database..." + update-desktop-database -q /usr/share/applications +else + echo "Warning: update-desktop-database command not found. Desktop file may not be immediately recognized." >&2 +fi + +# Update MIME database for custom URL schemes (x-scheme-handler) +# This ensures the system knows how to handle your custom protocols. +if command -v update-mime-database >/dev/null 2>&1; then + echo "Updating MIME database..." + update-mime-database -n /usr/share/mime +else + echo "Warning: update-mime-database command not found. Custom URL schemes may not be immediately recognized." >&2 +fi + +exit 0 diff --git a/cmd/npc/npc-gui/build/linux/nfpm/scripts/postremove.sh b/cmd/npc/npc-gui/build/linux/nfpm/scripts/postremove.sh new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/nfpm/scripts/postremove.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/cmd/npc/npc-gui/build/linux/nfpm/scripts/preinstall.sh b/cmd/npc/npc-gui/build/linux/nfpm/scripts/preinstall.sh new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/nfpm/scripts/preinstall.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/cmd/npc/npc-gui/build/linux/nfpm/scripts/preremove.sh b/cmd/npc/npc-gui/build/linux/nfpm/scripts/preremove.sh new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/cmd/npc/npc-gui/build/linux/nfpm/scripts/preremove.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/cmd/npc/npc-gui/build/windows/Taskfile.yml b/cmd/npc/npc-gui/build/windows/Taskfile.yml new file mode 100644 index 0000000..9cb4e35 --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/Taskfile.yml @@ -0,0 +1,195 @@ +version: '3' + +includes: + common: ../Taskfile.yml + +vars: + # Signing configuration - edit these values for your project + # SIGN_CERTIFICATE: "path/to/certificate.pfx" + # SIGN_THUMBPRINT: "certificate-thumbprint" # Alternative to SIGN_CERTIFICATE + # TIMESTAMP_SERVER: "http://timestamp.digicert.com" + # + # Password is stored securely in system keychain. Run: wails3 setup signing + + # Docker image for cross-compilation with CGO (used when CGO_ENABLED=1 on non-Windows) + CROSS_IMAGE: wails-cross + +tasks: + build: + summary: Builds the application for Windows + cmds: + # Auto-detect CGO: if CGO_ENABLED=1, use Docker; otherwise use native Go cross-compile + - task: '{{if and (ne OS "windows") (eq .CGO_ENABLED "1")}}build:docker{{else}}build:native{{end}}' + vars: + ARCH: '{{.ARCH}}' + DEV: '{{.DEV}}' + EXTRA_TAGS: '{{.EXTRA_TAGS}}' + OBFUSCATED: '{{.OBFUSCATED}}' + GARBLE_ARGS: '{{.GARBLE_ARGS}}' + vars: + # Default to CGO_ENABLED=0 if not explicitly set + CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}' + + build:native: + summary: Builds the application using native Go cross-compilation + internal: true + deps: + - task: common:go:mod:tidy + - task: common:build:frontend + vars: + BUILD_FLAGS: + ref: .BUILD_FLAGS + OBFUSCATED: + ref: .OBFUSCATED + DEV: + ref: .DEV + - task: common:generate:icons + preconditions: + - sh: '{{if eq .OBFUSCATED "true"}}command -v garble >/dev/null 2>&1{{else}}true{{end}}' + msg: "garble is required for obfuscated builds. Install it with: go install mvdan.cc/garble@v0.16.0 (requires Go 1.24+). See https://github.com/burrowers/garble/releases for version/toolchain compatibility." + cmds: + - task: generate:syso + vars: + ARCH: '{{.ARCH}}' + - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o "{{.BIN_DIR}}/{{.APP_NAME}}.exe"' + - cmd: powershell Remove-item *.syso + platforms: [windows] + - cmd: rm -f *.syso + platforms: [linux, darwin] + vars: + BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -H windowsgui"{{end}}' + env: + GOOS: windows + CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}' + GOARCH: '{{.ARCH | default ARCH}}' + + build:docker: + summary: Cross-compiles for Windows using Docker with Zig (for CGO builds on non-Windows) + internal: true + deps: + - task: common:build:frontend + vars: + OBFUSCATED: + ref: .OBFUSCATED + - task: common:generate:icons + preconditions: + - sh: docker info > /dev/null 2>&1 + msg: "Docker is required for CGO cross-compilation. Please install Docker." + - sh: docker image inspect {{.CROSS_IMAGE}} > /dev/null 2>&1 + msg: | + Docker image '{{.CROSS_IMAGE}}' not found. + Build it first: wails3 task setup:docker + cmds: + - task: generate:syso + vars: + ARCH: '{{.ARCH}}' + - docker run --rm -v "{{.ROOT_DIR}}:/app" {{.DOCKER_MOUNTS}} -e APP_NAME="{{.APP_NAME}}" {{if .EXTRA_TAGS}}-e EXTRA_TAGS="{{.EXTRA_TAGS}}"{{end}} {{if eq .OBFUSCATED "true"}}-e OBFUSCATED=true{{end}} {{if .GARBLE_ARGS}}-e GARBLE_ARGS="{{.GARBLE_ARGS}}"{{end}} {{.CROSS_IMAGE}} windows {{.DOCKER_ARCH}} + - cmd: docker run --rm -v "{{.ROOT_DIR}}:/app" alpine chown -R $(id -u):$(id -g) /app/bin + platforms: [linux, darwin] + - rm -f *.syso + vars: + DOCKER_ARCH: '{{.ARCH | default "amd64"}}' + # Generate Docker volume mounts: Go module cache + go.mod replace directives + # Uses wails3 tool docker-mounts for cross-platform compatibility (Windows/Linux/macOS) + DOCKER_MOUNTS: + sh: 'wails3 tool docker-mounts' + + package: + summary: Packages the application + cmds: + - task: '{{if eq (.FORMAT | default "nsis") "msix"}}create:msix:package{{else}}create:nsis:installer{{end}}' + vars: + INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}' + vars: + FORMAT: '{{.FORMAT | default "nsis"}}' + INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}' + + generate:syso: + summary: Generates Windows `.syso` file + dir: build + cmds: + - wails3 generate syso -arch {{.ARCH}} -icon windows/icon.ico -manifest windows/wails.exe.manifest -info windows/info.json -out ../wails_windows_{{.ARCH}}.syso + vars: + ARCH: '{{.ARCH | default ARCH}}' + + create:nsis:installer: + summary: Creates an NSIS installer + dir: build/windows/nsis + deps: + - task: build + preconditions: + - sh: '[ "{{.INSTALL_SCOPE}}" = "user" ] || [ "{{.INSTALL_SCOPE}}" = "machine" ]' + msg: "INSTALL_SCOPE must be 'user' or 'machine', got '{{.INSTALL_SCOPE}}'" + cmds: + # Create the Microsoft WebView2 bootstrapper if it doesn't exist + - wails3 generate webview2bootstrapper -dir "{{.ROOT_DIR}}/build/windows/nsis" + - | + {{if eq OS "windows"}} + makensis {{if eq .INSTALL_SCOPE "user"}}-DWAILS_INSTALL_SCOPE=user -DREQUEST_EXECUTION_LEVEL=user {{end}}-DARG_WAILS_{{.ARG_FLAG}}_BINARY="{{.ROOT_DIR}}\{{.BIN_DIR}}\{{.APP_NAME}}.exe" project.nsi + {{else}} + makensis {{if eq .INSTALL_SCOPE "user"}}-DWAILS_INSTALL_SCOPE=user -DREQUEST_EXECUTION_LEVEL=user {{end}}-DARG_WAILS_{{.ARG_FLAG}}_BINARY="{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}.exe" project.nsi + {{end}} + vars: + ARCH: '{{.ARCH | default ARCH}}' + ARG_FLAG: '{{if eq .ARCH "amd64"}}AMD64{{else}}ARM64{{end}}' + INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}' + + create:msix:package: + summary: Creates an MSIX package + deps: + - task: build + cmds: + - |- + wails3 tool msix \ + --config "{{.ROOT_DIR}}/wails.json" \ + --name "{{.APP_NAME}}" \ + --executable "{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}.exe" \ + --arch "{{.ARCH}}" \ + --out "{{.ROOT_DIR}}/{{.BIN_DIR}}/{{.APP_NAME}}-{{.ARCH}}.msix" \ + {{if .CERT_PATH}}--cert "{{.CERT_PATH}}"{{end}} \ + {{if .PUBLISHER}}--publisher "{{.PUBLISHER}}"{{end}} \ + {{if .USE_MSIX_TOOL}}--use-msix-tool{{else}}--use-makeappx{{end}} + vars: + ARCH: '{{.ARCH | default ARCH}}' + CERT_PATH: '{{.CERT_PATH | default ""}}' + PUBLISHER: '{{.PUBLISHER | default ""}}' + USE_MSIX_TOOL: '{{.USE_MSIX_TOOL | default "false"}}' + + install:msix:tools: + summary: Installs tools required for MSIX packaging + cmds: + - wails3 tool msix-install-tools + + run: + cmds: + - '{{.BIN_DIR}}/{{.APP_NAME}}.exe' + + sign: + summary: Signs the Windows executable + desc: | + Signs the .exe with an Authenticode certificate. + Set SIGN_CERTIFICATE or SIGN_THUMBPRINT to override the certificate + configured globally via `wails3 setup` (~/.config/wails/defaults.yaml). + Password is retrieved from system keychain (run: wails3 setup signing) + deps: + - task: build + cmds: + # Certificate vars are optional: if unset, `wails3 tool sign` falls back to + # the certificate configured globally via `wails3 setup`. + - wails3 tool sign --input "{{.BIN_DIR}}/{{.APP_NAME}}.exe" {{if .SIGN_CERTIFICATE}}--certificate "{{.SIGN_CERTIFICATE}}"{{end}} {{if .SIGN_THUMBPRINT}}--thumbprint "{{.SIGN_THUMBPRINT}}"{{end}} {{if .TIMESTAMP_SERVER}}--timestamp "{{.TIMESTAMP_SERVER}}"{{end}} + + sign:installer: + summary: Signs the NSIS installer + desc: | + Creates and signs the NSIS installer. + Set SIGN_CERTIFICATE or SIGN_THUMBPRINT to override the certificate + configured globally via `wails3 setup` (~/.config/wails/defaults.yaml). + Password is retrieved from system keychain (run: wails3 setup signing) + deps: + - task: create:nsis:installer + vars: + INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}' + vars: + INSTALL_SCOPE: '{{.INSTALL_SCOPE | default "machine"}}' + cmds: + - wails3 tool sign --input "build/windows/nsis/{{.APP_NAME}}-installer.exe" {{if .SIGN_CERTIFICATE}}--certificate "{{.SIGN_CERTIFICATE}}"{{end}} {{if .SIGN_THUMBPRINT}}--thumbprint "{{.SIGN_THUMBPRINT}}"{{end}} {{if .TIMESTAMP_SERVER}}--timestamp "{{.TIMESTAMP_SERVER}}"{{end}} diff --git a/cmd/npc/npc-gui/build/windows/icon.ico b/cmd/npc/npc-gui/build/windows/icon.ico new file mode 100644 index 0000000..fb09e10 Binary files /dev/null and b/cmd/npc/npc-gui/build/windows/icon.ico differ diff --git a/cmd/npc/npc-gui/build/windows/info.json b/cmd/npc/npc-gui/build/windows/info.json new file mode 100644 index 0000000..3c23b19 --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/info.json @@ -0,0 +1,15 @@ +{ + "fixed": { + "file_version": "0.26.38" + }, + "info": { + "0000": { + "ProductVersion": "0.26.38", + "CompanyName": "NPS", + "FileDescription": "NPS 客户端", + "LegalCopyright": "Copyright © 2026 NPS", + "ProductName": "NPS Client", + "Comments": "NPS 客户端" + } + } +} \ No newline at end of file diff --git a/cmd/npc/npc-gui/build/windows/msix/app_manifest.xml b/cmd/npc/npc-gui/build/windows/msix/app_manifest.xml new file mode 100644 index 0000000..3f09810 --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/msix/app_manifest.xml @@ -0,0 +1,55 @@ + + + + + + + NPS Client + NPS + NPS 客户端 + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cmd/npc/npc-gui/build/windows/msix/template.xml b/cmd/npc/npc-gui/build/windows/msix/template.xml new file mode 100644 index 0000000..bdf645e --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/msix/template.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + false + NPS Client + NPS + NPS 客户端 + Assets\AppIcon.png + + + + + + + diff --git a/cmd/npc/npc-gui/build/windows/nsis/project.nsi b/cmd/npc/npc-gui/build/windows/nsis/project.nsi new file mode 100644 index 0000000..b8cc41f --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/nsis/project.nsi @@ -0,0 +1,119 @@ +Unicode true + +#### +## Please note: Template replacements don't work in this file. They are provided with default defines like +## mentioned underneath. +## If the keyword is not defined, "wails_tools.nsh" will populate them. +## If they are defined here, "wails_tools.nsh" will not touch them. This allows you to use this project.nsi manually +## from outside of Wails for debugging and development of the installer. +## +## For development first make a wails nsis build to populate the "wails_tools.nsh": +## > wails build --target windows/amd64 --nsis +## Then you can call makensis on this file with specifying the path to your binary: +## For a AMD64 only installer: +## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe +## For a ARM64 only installer: +## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe +## For a installer with both architectures: +## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe +#### +## The following information is taken from the wails_tools.nsh file, but they can be overwritten here. +#### +## !define INFO_PROJECTNAME "my-project" # Default "npc-gui" +## !define INFO_COMPANYNAME "My Company" # Default "NPS" +## !define INFO_PRODUCTNAME "My Product Name" # Default "NPS Client" +## !define INFO_PRODUCTVERSION "1.0.0" # Default "0.26.38" +## !define INFO_COPYRIGHT "(c) Now, My Company" # Default "Copyright © 2026 NPS" +### +## !define PRODUCT_EXECUTABLE "Application.exe" # Default "${INFO_PROJECTNAME}.exe" +## !define UNINST_KEY_NAME "UninstKeyInRegistry" # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}" +#### +## !define REQUEST_EXECUTION_LEVEL "admin" # Default "admin" see also https://nsis.sourceforge.io/Docs/Chapter4.html +## !define WAILS_INSTALL_SCOPE "user" # Default "machine" - set to "user" for per-user install ($LOCALAPPDATA) without UAC prompt +#### +## Include the wails tools +#### +!include "wails_tools.nsh" + +# The version information for this two must consist of 4 parts +VIProductVersion "${INFO_PRODUCTVERSION}.0" +VIFileVersion "${INFO_PRODUCTVERSION}.0" + +VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}" +VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer" +VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}" +VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}" +VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}" +VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}" + +# Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware +ManifestDPIAware true + +!include "MUI.nsh" + +!define MUI_ICON "..\icon.ico" +!define MUI_UNICON "..\icon.ico" +# !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\leftimage.bmp" #Include this to add a bitmap on the left side of the Welcome Page. Must be a size of 164x314 +!define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps +!define MUI_ABORTWARNING # This will warn the user if they exit from the installer. + +!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page. +# !insertmacro MUI_PAGE_LICENSE "resources\eula.txt" # Adds a EULA page to the installer +!insertmacro MUI_PAGE_DIRECTORY # In which folder install page. +!insertmacro MUI_PAGE_INSTFILES # Installing page. +!insertmacro MUI_PAGE_FINISH # Finished installation page. + +!insertmacro MUI_UNPAGE_INSTFILES # Uninstalling page + +!insertmacro MUI_LANGUAGE "English" # Set the Language of the installer + +## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1 +#!uninstfinalize 'signtool --file "%1"' +#!finalize 'signtool --file "%1"' + +Name "${INFO_PRODUCTNAME}" +OutFile "..\..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file. +!if "${WAILS_INSTALL_SCOPE}" == "user" + InstallDir "$LOCALAPPDATA\Programs\${INFO_PRODUCTNAME}" +!else + InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" +!endif +ShowInstDetails show # This will always show the installation details. + +Function .onInit + !insertmacro wails.checkArchitecture +FunctionEnd + +Section + !insertmacro wails.setShellContext + + !insertmacro wails.webview2runtime + + SetOutPath $INSTDIR + + !insertmacro wails.files + + CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" + CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" + + !insertmacro wails.associateFiles + !insertmacro wails.associateCustomProtocols + + !insertmacro wails.writeUninstaller +SectionEnd + +Section "uninstall" + !insertmacro wails.setShellContext + + RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath + + RMDir /r $INSTDIR + + Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" + Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk" + + !insertmacro wails.unassociateFiles + !insertmacro wails.unassociateCustomProtocols + + !insertmacro wails.deleteUninstaller +SectionEnd diff --git a/cmd/npc/npc-gui/build/windows/nsis/wails_tools.nsh b/cmd/npc/npc-gui/build/windows/nsis/wails_tools.nsh new file mode 100644 index 0000000..b116639 --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/nsis/wails_tools.nsh @@ -0,0 +1,261 @@ +# DO NOT EDIT - Generated automatically by `wails build` + +!include "x64.nsh" +!include "WinVer.nsh" +!include "FileFunc.nsh" + +!ifndef INFO_PROJECTNAME + !define INFO_PROJECTNAME "npc-gui" +!endif +!ifndef INFO_COMPANYNAME + !define INFO_COMPANYNAME "NPS" +!endif +!ifndef INFO_PRODUCTNAME + !define INFO_PRODUCTNAME "NPS Client" +!endif +!ifndef INFO_PRODUCTVERSION + !define INFO_PRODUCTVERSION "0.26.38" +!endif +!ifndef INFO_COPYRIGHT + !define INFO_COPYRIGHT "Copyright © 2026 NPS" +!endif +!ifndef PRODUCT_EXECUTABLE + !define PRODUCT_EXECUTABLE "${INFO_PROJECTNAME}.exe" +!endif +!ifndef UNINST_KEY_NAME + !define UNINST_KEY_NAME "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}" +!endif +!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINST_KEY_NAME}" + +!ifndef WAILS_INSTALL_SCOPE + !define WAILS_INSTALL_SCOPE "machine" +!endif + +!ifndef REQUEST_EXECUTION_LEVEL + !if "${WAILS_INSTALL_SCOPE}" == "user" + !define REQUEST_EXECUTION_LEVEL "user" + !else + !define REQUEST_EXECUTION_LEVEL "admin" + !endif +!endif + +RequestExecutionLevel "${REQUEST_EXECUTION_LEVEL}" + +!ifdef ARG_WAILS_AMD64_BINARY + !define SUPPORTS_AMD64 +!endif + +!ifdef ARG_WAILS_ARM64_BINARY + !define SUPPORTS_ARM64 +!endif + +!ifdef SUPPORTS_AMD64 + !ifdef SUPPORTS_ARM64 + !define ARCH "amd64_arm64" + !else + !define ARCH "amd64" + !endif +!else + !ifdef SUPPORTS_ARM64 + !define ARCH "arm64" + !else + !error "Wails: Undefined ARCH, please provide at least one of ARG_WAILS_AMD64_BINARY or ARG_WAILS_ARM64_BINARY" + !endif +!endif + +!macro wails.checkArchitecture + !ifndef WAILS_WIN10_REQUIRED + !define WAILS_WIN10_REQUIRED "This product is only supported on Windows 10 (Server 2016) and later." + !endif + + !ifndef WAILS_ARCHITECTURE_NOT_SUPPORTED + !define WAILS_ARCHITECTURE_NOT_SUPPORTED "This product can't be installed on the current Windows architecture. Supports: ${ARCH}" + !endif + + ${If} ${AtLeastWin10} + !ifdef SUPPORTS_AMD64 + ${if} ${IsNativeAMD64} + Goto ok + ${EndIf} + !endif + + !ifdef SUPPORTS_ARM64 + ${if} ${IsNativeARM64} + Goto ok + ${EndIf} + !endif + + IfSilent silentArch notSilentArch + silentArch: + SetErrorLevel 65 + Abort + notSilentArch: + MessageBox MB_OK "${WAILS_ARCHITECTURE_NOT_SUPPORTED}" + Quit + ${else} + IfSilent silentWin notSilentWin + silentWin: + SetErrorLevel 64 + Abort + notSilentWin: + MessageBox MB_OK "${WAILS_WIN10_REQUIRED}" + Quit + ${EndIf} + + ok: +!macroend + +!macro wails.files + !ifdef SUPPORTS_AMD64 + ${if} ${IsNativeAMD64} + File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_AMD64_BINARY}" + ${EndIf} + !endif + + !ifdef SUPPORTS_ARM64 + ${if} ${IsNativeARM64} + File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_ARM64_BINARY}" + ${EndIf} + !endif +!macroend + +!macro wails.writeUninstaller + WriteUninstaller "$INSTDIR\uninstall.exe" + + SetRegView 64 + !if "${WAILS_INSTALL_SCOPE}" == "user" + WriteRegStr HKCU "${UNINST_KEY}" "Publisher" "${INFO_COMPANYNAME}" + WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${INFO_PRODUCTNAME}" + WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${INFO_PRODUCTVERSION}" + WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXECUTABLE}" + WriteRegStr HKCU "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKCU "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD HKCU "${UNINST_KEY}" "EstimatedSize" "$0" + !else + WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "${INFO_COMPANYNAME}" + WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${INFO_PRODUCTNAME}" + WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${INFO_PRODUCTVERSION}" + WriteRegStr HKLM "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXECUTABLE}" + WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" "$0" + !endif +!macroend + +!macro wails.deleteUninstaller + Delete "$INSTDIR\uninstall.exe" + + SetRegView 64 + !if "${WAILS_INSTALL_SCOPE}" == "user" + DeleteRegKey HKCU "${UNINST_KEY}" + !else + DeleteRegKey HKLM "${UNINST_KEY}" + !endif +!macroend + +!macro wails.setShellContext + ${If} ${REQUEST_EXECUTION_LEVEL} == "admin" + SetShellVarContext all + ${else} + SetShellVarContext current + ${EndIf} +!macroend + +# Install webview2 by launching the bootstrapper +# See https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#online-only-deployment +!macro wails.webview2runtime + !ifndef WAILS_INSTALL_WEBVIEW_DETAILPRINT + !define WAILS_INSTALL_WEBVIEW_DETAILPRINT "Installing: WebView2 Runtime" + !endif + + SetRegView 64 + # If the admin key exists and is not empty then webview2 is already installed + ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" + ${If} $0 != "" + Goto ok + ${EndIf} + + ${If} ${REQUEST_EXECUTION_LEVEL} == "user" + # If the installer is run in user level, check the user specific key exists and is not empty then webview2 is already installed + ReadRegStr $0 HKCU "Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" + ${If} $0 != "" + Goto ok + ${EndIf} + ${EndIf} + + SetDetailsPrint both + DetailPrint "${WAILS_INSTALL_WEBVIEW_DETAILPRINT}" + SetDetailsPrint listonly + + InitPluginsDir + CreateDirectory "$pluginsdir\webview2bootstrapper" + SetOutPath "$pluginsdir\webview2bootstrapper" + File "MicrosoftEdgeWebview2Setup.exe" + ExecWait '"$pluginsdir\webview2bootstrapper\MicrosoftEdgeWebview2Setup.exe" /silent /install' + + SetDetailsPrint both + ok: +!macroend + +# Copy of APP_ASSOCIATE and APP_UNASSOCIATE macros from here https://gist.github.com/nikku/281d0ef126dbc215dd58bfd5b3a5cd5b +!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND + ; Backup the previously associated file class + ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "${FILECLASS}_backup" "$R0" + + WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "${FILECLASS}" + + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}" "" `${DESCRIPTION}` + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\DefaultIcon" "" `${ICON}` + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell" "" "open" + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open" "" `${COMMANDTEXT}` + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open\command" "" `${COMMAND}` +!macroend + +!macro APP_UNASSOCIATE EXT FILECLASS + ; Backup the previously associated file class + ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" `${FILECLASS}_backup` + WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "$R0" + + DeleteRegKey SHELL_CONTEXT `Software\Classes\${FILECLASS}` +!macroend + +!macro wails.associateFiles + ; Create file associations + +!macroend + +!macro wails.unassociateFiles + ; Delete app associations + +!macroend + +!macro CUSTOM_PROTOCOL_ASSOCIATE PROTOCOL DESCRIPTION ICON COMMAND + DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "" "${DESCRIPTION}" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "URL Protocol" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\DefaultIcon" "" "${ICON}" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell" "" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open" "" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open\command" "" "${COMMAND}" +!macroend + +!macro CUSTOM_PROTOCOL_UNASSOCIATE PROTOCOL + DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}" +!macroend + +!macro wails.associateCustomProtocols + ; Create custom protocols associations + +!macroend + +!macro wails.unassociateCustomProtocols + ; Delete app custom protocol associations + +!macroend \ No newline at end of file diff --git a/cmd/npc/npc-gui/build/windows/wails.exe.manifest b/cmd/npc/npc-gui/build/windows/wails.exe.manifest new file mode 100644 index 0000000..570730c --- /dev/null +++ b/cmd/npc/npc-gui/build/windows/wails.exe.manifest @@ -0,0 +1,22 @@ + + + + + + + + + + + true/pm + permonitorv2,permonitor + + + + + + + + + + \ No newline at end of file diff --git a/cmd/npc/npc-gui/frontend/bindings/github.com/wailsapp/wails/v3/internal/eventcreate.js b/cmd/npc/npc-gui/frontend/bindings/github.com/wailsapp/wails/v3/internal/eventcreate.js new file mode 100644 index 0000000..1ea1058 --- /dev/null +++ b/cmd/npc/npc-gui/frontend/bindings/github.com/wailsapp/wails/v3/internal/eventcreate.js @@ -0,0 +1,9 @@ +//@ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import { Create as $Create } from "@wailsio/runtime"; + +Object.freeze($Create.Events); diff --git a/cmd/npc/npc-gui/frontend/bindings/github.com/wailsapp/wails/v3/internal/eventdata.d.ts b/cmd/npc/npc-gui/frontend/bindings/github.com/wailsapp/wails/v3/internal/eventdata.d.ts new file mode 100644 index 0000000..3dd1807 --- /dev/null +++ b/cmd/npc/npc-gui/frontend/bindings/github.com/wailsapp/wails/v3/internal/eventdata.d.ts @@ -0,0 +1,2 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT diff --git a/cmd/npc/npc-gui/frontend/bindings/npc-gui/app.js b/cmd/npc/npc-gui/frontend/bindings/npc-gui/app.js new file mode 100644 index 0000000..8754a3f --- /dev/null +++ b/cmd/npc/npc-gui/frontend/bindings/npc-gui/app.js @@ -0,0 +1,173 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "@wailsio/runtime"; + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import * as $models from "./models.js"; + +/** + * @param {string} arg + * @returns {$CancellablePromise} + */ +export function AddShortcut(arg) { + return $Call.ByID(1551262862, arg); +} + +/** + * @param {string} s + * @returns {$CancellablePromise} + */ +export function AddShortcutFromBase64(s) { + return $Call.ByID(1504335541, s); +} + +/** + * CheckForUpdate 检查是否有新版本可用(检测升级) + * @returns {$CancellablePromise<$models.UpdateInfo | null>} + */ +export function CheckForUpdate() { + return $Call.ByID(2347956003).then(/** @type {($result: any) => any} */(($result) => { + return $$createType1($result); + })); +} + +/** + * ClearConnectionLogs 清空指定客户端的连接日志(内存缓冲与日志文件) + * @param {string} clientId + * @returns {$CancellablePromise} + */ +export function ClearConnectionLogs(clientId) { + return $Call.ByID(390310005, clientId); +} + +/** + * DownloadAndInstallUpdate 下载最新版本并热替换当前可执行文件 + * @returns {$CancellablePromise} + */ +export function DownloadAndInstallUpdate() { + return $Call.ByID(2440793480); +} + +/** + * GetAppVersion 返回来自 lib/version 的版本号 + * @returns {$CancellablePromise} + */ +export function GetAppVersion() { + return $Call.ByID(1780012486); +} + +/** + * @returns {$CancellablePromise<{ [_ in string]?: string }>} + */ +export function GetClientStates() { + return $Call.ByID(4274000306).then(/** @type {($result: any) => any} */(($result) => { + return $$createType2($result); + })); +} + +/** + * GetConnectionLogs 获取指定客户端的连接日志(直接读内存缓冲,无需解析文件) + * @param {string} clientId + * @returns {$CancellablePromise<$models.ConnectionLog[]>} + */ +export function GetConnectionLogs(clientId) { + return $Call.ByID(1455453564, clientId).then(/** @type {($result: any) => any} */(($result) => { + return $$createType4($result); + })); +} + +/** + * GetDefaultLogDir 获取默认日志目录路径 + * @returns {$CancellablePromise} + */ +export function GetDefaultLogDir() { + return $Call.ByID(2287653297); +} + +/** + * 以下为对 settings 与 clientStates 的访问方法(供前端调用) + * @returns {$CancellablePromise<$models.GuiSettings>} + */ +export function GetGuiSettings() { + return $Call.ByID(3468339871).then(/** @type {($result: any) => any} */(($result) => { + return $$createType5($result); + })); +} + +/** + * @returns {$CancellablePromise<$models.ShortClient[]>} + */ +export function GetShortcuts() { + return $Call.ByID(737927018).then(/** @type {($result: any) => any} */(($result) => { + return $$createType7($result); + })); +} + +/** + * @param {string} name + * @param {string} addr + * @param {string} key + * @returns {$CancellablePromise} + */ +export function RemoveShortcut(name, addr, key) { + return $Call.ByID(658180051, name, addr, key); +} + +/** + * RestartApp 重启当前程序(更新完成后调用) + * @returns {$CancellablePromise} + */ +export function RestartApp() { + return $Call.ByID(4246341431); +} + +/** + * @param {{ [_ in string]?: string }} m + * @returns {$CancellablePromise} + */ +export function SaveClientStates(m) { + return $Call.ByID(2752835897, m); +} + +/** + * @param {$models.GuiSettings} s + * @returns {$CancellablePromise} + */ +export function SaveGuiSettings(s) { + return $Call.ByID(979570966, s); +} + +/** + * SelectDirectory 打开目录选择对话框 + * @returns {$CancellablePromise} + */ +export function SelectDirectory() { + return $Call.ByID(1735672136); +} + +/** + * @param {string} name + * @param {string} addr + * @param {string} key + * @param {boolean} tls + * @param {boolean} runningState + * @returns {$CancellablePromise} + */ +export function ToggleClient(name, addr, key, tls, runningState) { + return $Call.ByID(1335627254, name, addr, key, tls, runningState); +} + +// Private type creation functions +const $$createType0 = $models.UpdateInfo.createFrom; +const $$createType1 = $Create.Nullable($$createType0); +const $$createType2 = $Create.Map($Create.Any, $Create.Any); +const $$createType3 = $models.ConnectionLog.createFrom; +const $$createType4 = $Create.Array($$createType3); +const $$createType5 = $models.GuiSettings.createFrom; +const $$createType6 = $models.ShortClient.createFrom; +const $$createType7 = $Create.Array($$createType6); diff --git a/cmd/npc/npc-gui/frontend/bindings/npc-gui/index.js b/cmd/npc/npc-gui/frontend/bindings/npc-gui/index.js new file mode 100644 index 0000000..645ae28 --- /dev/null +++ b/cmd/npc/npc-gui/frontend/bindings/npc-gui/index.js @@ -0,0 +1,15 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +import * as App from "./app.js"; +export { + App +}; + +export { + ConnectionLog, + GuiSettings, + ShortClient, + UpdateInfo +} from "./models.js"; diff --git a/cmd/npc/npc-gui/frontend/bindings/npc-gui/models.js b/cmd/npc/npc-gui/frontend/bindings/npc-gui/models.js new file mode 100644 index 0000000..1d055ef --- /dev/null +++ b/cmd/npc/npc-gui/frontend/bindings/npc-gui/models.js @@ -0,0 +1,262 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import { Create as $Create } from "@wailsio/runtime"; + +/** + * ConnectionLog 连接日志项 + */ +export class ConnectionLog { + /** + * Creates a new ConnectionLog instance. + * @param {Partial} [$$source = {}] - The source object to create the ConnectionLog. + */ + constructor($$source = {}) { + if (!("timestamp" in $$source)) { + /** + * @member + * @type {string} + */ + this["timestamp"] = ""; + } + if (!("message" in $$source)) { + /** + * @member + * @type {string} + */ + this["message"] = ""; + } + if (!("type" in $$source)) { + /** + * "info", "error", "warning", "success" + * @member + * @type {string} + */ + this["type"] = ""; + } + if (!("clientId" in $$source)) { + /** + * @member + * @type {string} + */ + this["clientId"] = ""; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new ConnectionLog instance from a string or object. + * @param {any} [$$source = {}] + * @returns {ConnectionLog} + */ + static createFrom($$source = {}) { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new ConnectionLog(/** @type {Partial} */($$parsedSource)); + } +} + +/** + * 持久化文件结构(向后兼容旧的仅数组格式) + */ +export class GuiSettings { + /** + * Creates a new GuiSettings instance. + * @param {Partial} [$$source = {}] - The source object to create the GuiSettings. + */ + constructor($$source = {}) { + if (!("startupEnabled" in $$source)) { + /** + * @member + * @type {boolean} + */ + this["startupEnabled"] = false; + } + if (!("rememberClientState" in $$source)) { + /** + * @member + * @type {boolean} + */ + this["rememberClientState"] = false; + } + if (!("logDir" in $$source)) { + /** + * @member + * @type {string} + */ + this["logDir"] = ""; + } + if (!("themeMode" in $$source)) { + /** + * "auto", "light", "dark" + * @member + * @type {string} + */ + this["themeMode"] = ""; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new GuiSettings instance from a string or object. + * @param {any} [$$source = {}] + * @returns {GuiSettings} + */ + static createFrom($$source = {}) { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new GuiSettings(/** @type {Partial} */($$parsedSource)); + } +} + +/** + * ShortClient 与前端结构对应 + */ +export class ShortClient { + /** + * Creates a new ShortClient instance. + * @param {Partial} [$$source = {}] - The source object to create the ShortClient. + */ + constructor($$source = {}) { + if (!("name" in $$source)) { + /** + * @member + * @type {string} + */ + this["name"] = ""; + } + if (!("addr" in $$source)) { + /** + * @member + * @type {string} + */ + this["addr"] = ""; + } + if (!("key" in $$source)) { + /** + * @member + * @type {string} + */ + this["key"] = ""; + } + if (!("tls" in $$source)) { + /** + * @member + * @type {boolean} + */ + this["tls"] = false; + } + if (!("running" in $$source)) { + /** + * 兼容旧版本,实际用Status + * @member + * @type {boolean} + */ + this["running"] = false; + } + if (!("error" in $$source)) { + /** + * 连接错误信息 + * @member + * @type {string} + */ + this["error"] = ""; + } + if (!("status" in $$source)) { + /** + * 连接状态: "stopped", "connecting", "connected" + * @member + * @type {string} + */ + this["status"] = ""; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new ShortClient instance from a string or object. + * @param {any} [$$source = {}] + * @returns {ShortClient} + */ + static createFrom($$source = {}) { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new ShortClient(/** @type {Partial} */($$parsedSource)); + } +} + +/** + * UpdateInfo 版本检查结果,供前端展示 + */ +export class UpdateInfo { + /** + * Creates a new UpdateInfo instance. + * @param {Partial} [$$source = {}] - The source object to create the UpdateInfo. + */ + constructor($$source = {}) { + if (!("currentVersion" in $$source)) { + /** + * @member + * @type {string} + */ + this["currentVersion"] = ""; + } + if (!("latestVersion" in $$source)) { + /** + * @member + * @type {string} + */ + this["latestVersion"] = ""; + } + if (!("updateAvailable" in $$source)) { + /** + * @member + * @type {boolean} + */ + this["updateAvailable"] = false; + } + if (!("releaseNotes" in $$source)) { + /** + * @member + * @type {string} + */ + this["releaseNotes"] = ""; + } + if (!("publishedAt" in $$source)) { + /** + * @member + * @type {string} + */ + this["publishedAt"] = ""; + } + if (!("downloadUrl" in $$source)) { + /** + * @member + * @type {string} + */ + this["downloadUrl"] = ""; + } + if (!("assetName" in $$source)) { + /** + * @member + * @type {string} + */ + this["assetName"] = ""; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new UpdateInfo instance from a string or object. + * @param {any} [$$source = {}] + * @returns {UpdateInfo} + */ + static createFrom($$source = {}) { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new UpdateInfo(/** @type {Partial} */($$parsedSource)); + } +} diff --git a/cmd/npc/npc-gui/frontend/package.json b/cmd/npc/npc-gui/frontend/package.json index d276a7d..9b54ce3 100644 --- a/cmd/npc/npc-gui/frontend/package.json +++ b/cmd/npc/npc-gui/frontend/package.json @@ -6,10 +6,12 @@ "scripts": { "dev": "vite", "build": "vite build", + "build:dev": "vite build --minify false --mode development", "preview": "vite preview", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" }, "dependencies": { + "@wailsio/runtime": "^3.0.0-beta.12", "vue": "^3.3.4" }, "devDependencies": { diff --git a/cmd/npc/npc-gui/frontend/src/App.vue b/cmd/npc/npc-gui/frontend/src/App.vue index fe6bf16..be1ed41 100644 --- a/cmd/npc/npc-gui/frontend/src/App.vue +++ b/cmd/npc/npc-gui/frontend/src/App.vue @@ -1,89 +1,167 @@ diff --git a/cmd/npc/npc-gui/frontend/vite.config.js b/cmd/npc/npc-gui/frontend/vite.config.js index 9c78de1..cd12cfb 100644 --- a/cmd/npc/npc-gui/frontend/vite.config.js +++ b/cmd/npc/npc-gui/frontend/vite.config.js @@ -4,15 +4,14 @@ import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], + server: { + // 必须绑定 IPv4 回环地址:Wails 应用通过 127.0.0.1 代理请求 dev server, + // vite 默认只监听 ::1(IPv6)会导致 502 + host: '127.0.0.1', + port: Number(process.env.WAILS_VITE_PORT) || 34115, + strictPort: true + }, build: { - outDir: 'dist', - rollupOptions: { - external: ['/wails/go/main/App.js'], - output: { - globals: { - '/wails/go/main/App.js': 'window' - } - } - } + outDir: 'dist' } }) diff --git a/cmd/npc/npc-gui/frontend/wailsjs/go/main/App.d.ts b/cmd/npc/npc-gui/frontend/wailsjs/go/main/App.d.ts deleted file mode 100644 index beceee5..0000000 --- a/cmd/npc/npc-gui/frontend/wailsjs/go/main/App.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL -// This file is automatically generated. DO NOT EDIT -import {main} from '../models'; - -export function AddShortcut(arg1:string):Promise; - -export function AddShortcutFromBase64(arg1:string):Promise; - -export function ClearConnectionLogs(arg1:string):Promise; - -export function GetAppVersion():Promise; - -export function GetClientStates():Promise>; - -export function GetConnectionLogs(arg1:string):Promise>; - -export function GetDefaultLogDir():Promise; - -export function GetGuiSettings():Promise; - -export function GetShortcuts():Promise>; - -export function RemoveShortcut(arg1:string,arg2:string,arg3:string):Promise; - -export function SaveClientStates(arg1:Record):Promise; - -export function SaveGuiSettings(arg1:main.GuiSettings):Promise; - -export function SelectDirectory():Promise; - -export function ToggleClient(arg1:string,arg2:string,arg3:string,arg4:boolean,arg5:boolean):Promise; diff --git a/cmd/npc/npc-gui/frontend/wailsjs/go/main/App.js b/cmd/npc/npc-gui/frontend/wailsjs/go/main/App.js deleted file mode 100644 index 79e76fd..0000000 --- a/cmd/npc/npc-gui/frontend/wailsjs/go/main/App.js +++ /dev/null @@ -1,59 +0,0 @@ -// @ts-check -// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL -// This file is automatically generated. DO NOT EDIT - -export function AddShortcut(arg1) { - return window['go']['main']['App']['AddShortcut'](arg1); -} - -export function AddShortcutFromBase64(arg1) { - return window['go']['main']['App']['AddShortcutFromBase64'](arg1); -} - -export function ClearConnectionLogs(arg1) { - return window['go']['main']['App']['ClearConnectionLogs'](arg1); -} - -export function GetAppVersion() { - return window['go']['main']['App']['GetAppVersion'](); -} - -export function GetClientStates() { - return window['go']['main']['App']['GetClientStates'](); -} - -export function GetConnectionLogs(arg1) { - return window['go']['main']['App']['GetConnectionLogs'](arg1); -} - -export function GetDefaultLogDir() { - return window['go']['main']['App']['GetDefaultLogDir'](); -} - -export function GetGuiSettings() { - return window['go']['main']['App']['GetGuiSettings'](); -} - -export function GetShortcuts() { - return window['go']['main']['App']['GetShortcuts'](); -} - -export function RemoveShortcut(arg1, arg2, arg3) { - return window['go']['main']['App']['RemoveShortcut'](arg1, arg2, arg3); -} - -export function SaveClientStates(arg1) { - return window['go']['main']['App']['SaveClientStates'](arg1); -} - -export function SaveGuiSettings(arg1) { - return window['go']['main']['App']['SaveGuiSettings'](arg1); -} - -export function SelectDirectory() { - return window['go']['main']['App']['SelectDirectory'](); -} - -export function ToggleClient(arg1, arg2, arg3, arg4, arg5) { - return window['go']['main']['App']['ToggleClient'](arg1, arg2, arg3, arg4, arg5); -} diff --git a/cmd/npc/npc-gui/frontend/wailsjs/go/models.ts b/cmd/npc/npc-gui/frontend/wailsjs/go/models.ts deleted file mode 100644 index aed11e4..0000000 --- a/cmd/npc/npc-gui/frontend/wailsjs/go/models.ts +++ /dev/null @@ -1,65 +0,0 @@ -export namespace main { - - export class ConnectionLog { - timestamp: string; - message: string; - type: string; - clientId: string; - - static createFrom(source: any = {}) { - return new ConnectionLog(source); - } - - constructor(source: any = {}) { - if ('string' === typeof source) source = JSON.parse(source); - this.timestamp = source["timestamp"]; - this.message = source["message"]; - this.type = source["type"]; - this.clientId = source["clientId"]; - } - } - export class GuiSettings { - startupEnabled: boolean; - rememberClientState: boolean; - logDir: string; - themeMode: string; - - static createFrom(source: any = {}) { - return new GuiSettings(source); - } - - constructor(source: any = {}) { - if ('string' === typeof source) source = JSON.parse(source); - this.startupEnabled = source["startupEnabled"]; - this.rememberClientState = source["rememberClientState"]; - this.logDir = source["logDir"]; - this.themeMode = source["themeMode"]; - } - } - export class ShortClient { - name: string; - addr: string; - key: string; - tls: boolean; - running: boolean; - error: string; - status: string; - - static createFrom(source: any = {}) { - return new ShortClient(source); - } - - constructor(source: any = {}) { - if ('string' === typeof source) source = JSON.parse(source); - this.name = source["name"]; - this.addr = source["addr"]; - this.key = source["key"]; - this.tls = source["tls"]; - this.running = source["running"]; - this.error = source["error"]; - this.status = source["status"]; - } - } - -} - diff --git a/cmd/npc/npc-gui/frontend/wailsjs/runtime/package.json b/cmd/npc/npc-gui/frontend/wailsjs/runtime/package.json deleted file mode 100644 index 1e7c8a5..0000000 --- a/cmd/npc/npc-gui/frontend/wailsjs/runtime/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@wailsapp/runtime", - "version": "2.0.0", - "description": "Wails Javascript runtime library", - "main": "runtime.js", - "types": "runtime.d.ts", - "scripts": { - }, - "repository": { - "type": "git", - "url": "git+https://github.com/wailsapp/wails.git" - }, - "keywords": [ - "Wails", - "Javascript", - "Go" - ], - "author": "Lea Anthony ", - "license": "MIT", - "bugs": { - "url": "https://github.com/wailsapp/wails/issues" - }, - "homepage": "https://github.com/wailsapp/wails#readme" -} diff --git a/cmd/npc/npc-gui/frontend/wailsjs/runtime/runtime.d.ts b/cmd/npc/npc-gui/frontend/wailsjs/runtime/runtime.d.ts deleted file mode 100644 index 4445dac..0000000 --- a/cmd/npc/npc-gui/frontend/wailsjs/runtime/runtime.d.ts +++ /dev/null @@ -1,249 +0,0 @@ -/* - _ __ _ __ -| | / /___ _(_) /____ -| | /| / / __ `/ / / ___/ -| |/ |/ / /_/ / / (__ ) -|__/|__/\__,_/_/_/____/ -The electron alternative for Go -(c) Lea Anthony 2019-present -*/ - -export interface Position { - x: number; - y: number; -} - -export interface Size { - w: number; - h: number; -} - -export interface Screen { - isCurrent: boolean; - isPrimary: boolean; - width : number - height : number -} - -// Environment information such as platform, buildtype, ... -export interface EnvironmentInfo { - buildType: string; - platform: string; - arch: string; -} - -// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) -// emits the given event. Optional data may be passed with the event. -// This will trigger any event listeners. -export function EventsEmit(eventName: string, ...data: any): void; - -// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name. -export function EventsOn(eventName: string, callback: (...data: any) => void): () => void; - -// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple) -// sets up a listener for the given event name, but will only trigger a given number times. -export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void; - -// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce) -// sets up a listener for the given event name, but will only trigger once. -export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void; - -// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff) -// unregisters the listener for the given event name. -export function EventsOff(eventName: string, ...additionalEventNames: string[]): void; - -// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) -// unregisters all listeners. -export function EventsOffAll(): void; - -// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) -// logs the given message as a raw message -export function LogPrint(message: string): void; - -// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace) -// logs the given message at the `trace` log level. -export function LogTrace(message: string): void; - -// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug) -// logs the given message at the `debug` log level. -export function LogDebug(message: string): void; - -// [LogError](https://wails.io/docs/reference/runtime/log#logerror) -// logs the given message at the `error` log level. -export function LogError(message: string): void; - -// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal) -// logs the given message at the `fatal` log level. -// The application will quit after calling this method. -export function LogFatal(message: string): void; - -// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo) -// logs the given message at the `info` log level. -export function LogInfo(message: string): void; - -// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning) -// logs the given message at the `warning` log level. -export function LogWarning(message: string): void; - -// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload) -// Forces a reload by the main application as well as connected browsers. -export function WindowReload(): void; - -// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp) -// Reloads the application frontend. -export function WindowReloadApp(): void; - -// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop) -// Sets the window AlwaysOnTop or not on top. -export function WindowSetAlwaysOnTop(b: boolean): void; - -// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) -// *Windows only* -// Sets window theme to system default (dark/light). -export function WindowSetSystemDefaultTheme(): void; - -// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme) -// *Windows only* -// Sets window to light theme. -export function WindowSetLightTheme(): void; - -// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme) -// *Windows only* -// Sets window to dark theme. -export function WindowSetDarkTheme(): void; - -// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter) -// Centers the window on the monitor the window is currently on. -export function WindowCenter(): void; - -// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle) -// Sets the text in the window title bar. -export function WindowSetTitle(title: string): void; - -// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen) -// Makes the window full screen. -export function WindowFullscreen(): void; - -// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen) -// Restores the previous window dimensions and position prior to full screen. -export function WindowUnfullscreen(): void; - -// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen) -// Returns the state of the window, i.e. whether the window is in full screen mode or not. -export function WindowIsFullscreen(): Promise; - -// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize) -// Sets the width and height of the window. -export function WindowSetSize(width: number, height: number): void; - -// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize) -// Gets the width and height of the window. -export function WindowGetSize(): Promise; - -// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize) -// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions. -// Setting a size of 0,0 will disable this constraint. -export function WindowSetMaxSize(width: number, height: number): void; - -// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize) -// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions. -// Setting a size of 0,0 will disable this constraint. -export function WindowSetMinSize(width: number, height: number): void; - -// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition) -// Sets the window position relative to the monitor the window is currently on. -export function WindowSetPosition(x: number, y: number): void; - -// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition) -// Gets the window position relative to the monitor the window is currently on. -export function WindowGetPosition(): Promise; - -// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide) -// Hides the window. -export function WindowHide(): void; - -// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow) -// Shows the window, if it is currently hidden. -export function WindowShow(): void; - -// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise) -// Maximises the window to fill the screen. -export function WindowMaximise(): void; - -// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise) -// Toggles between Maximised and UnMaximised. -export function WindowToggleMaximise(): void; - -// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise) -// Restores the window to the dimensions and position prior to maximising. -export function WindowUnmaximise(): void; - -// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised) -// Returns the state of the window, i.e. whether the window is maximised or not. -export function WindowIsMaximised(): Promise; - -// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise) -// Minimises the window. -export function WindowMinimise(): void; - -// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise) -// Restores the window to the dimensions and position prior to minimising. -export function WindowUnminimise(): void; - -// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised) -// Returns the state of the window, i.e. whether the window is minimised or not. -export function WindowIsMinimised(): Promise; - -// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal) -// Returns the state of the window, i.e. whether the window is normal or not. -export function WindowIsNormal(): Promise; - -// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour) -// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. -export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void; - -// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall) -// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system. -export function ScreenGetAll(): Promise; - -// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl) -// Opens the given URL in the system browser. -export function BrowserOpenURL(url: string): void; - -// [Environment](https://wails.io/docs/reference/runtime/intro#environment) -// Returns information about the environment -export function Environment(): Promise; - -// [Quit](https://wails.io/docs/reference/runtime/intro#quit) -// Quits the application. -export function Quit(): void; - -// [Hide](https://wails.io/docs/reference/runtime/intro#hide) -// Hides the application. -export function Hide(): void; - -// [Show](https://wails.io/docs/reference/runtime/intro#show) -// Shows the application. -export function Show(): void; - -// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext) -// Returns the current text stored on clipboard -export function ClipboardGetText(): Promise; - -// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext) -// Sets a text on the clipboard -export function ClipboardSetText(text: string): Promise; - -// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop) -// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings. -export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void - -// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff) -// OnFileDropOff removes the drag and drop listeners and handlers. -export function OnFileDropOff() :void - -// Check if the file path resolver is available -export function CanResolveFilePaths(): boolean; - -// Resolves file paths for an array of files -export function ResolveFilePaths(files: File[]): void \ No newline at end of file diff --git a/cmd/npc/npc-gui/frontend/wailsjs/runtime/runtime.js b/cmd/npc/npc-gui/frontend/wailsjs/runtime/runtime.js deleted file mode 100644 index 7cb89d7..0000000 --- a/cmd/npc/npc-gui/frontend/wailsjs/runtime/runtime.js +++ /dev/null @@ -1,242 +0,0 @@ -/* - _ __ _ __ -| | / /___ _(_) /____ -| | /| / / __ `/ / / ___/ -| |/ |/ / /_/ / / (__ ) -|__/|__/\__,_/_/_/____/ -The electron alternative for Go -(c) Lea Anthony 2019-present -*/ - -export function LogPrint(message) { - window.runtime.LogPrint(message); -} - -export function LogTrace(message) { - window.runtime.LogTrace(message); -} - -export function LogDebug(message) { - window.runtime.LogDebug(message); -} - -export function LogInfo(message) { - window.runtime.LogInfo(message); -} - -export function LogWarning(message) { - window.runtime.LogWarning(message); -} - -export function LogError(message) { - window.runtime.LogError(message); -} - -export function LogFatal(message) { - window.runtime.LogFatal(message); -} - -export function EventsOnMultiple(eventName, callback, maxCallbacks) { - return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks); -} - -export function EventsOn(eventName, callback) { - return EventsOnMultiple(eventName, callback, -1); -} - -export function EventsOff(eventName, ...additionalEventNames) { - return window.runtime.EventsOff(eventName, ...additionalEventNames); -} - -export function EventsOffAll() { - return window.runtime.EventsOffAll(); -} - -export function EventsOnce(eventName, callback) { - return EventsOnMultiple(eventName, callback, 1); -} - -export function EventsEmit(eventName) { - let args = [eventName].slice.call(arguments); - return window.runtime.EventsEmit.apply(null, args); -} - -export function WindowReload() { - window.runtime.WindowReload(); -} - -export function WindowReloadApp() { - window.runtime.WindowReloadApp(); -} - -export function WindowSetAlwaysOnTop(b) { - window.runtime.WindowSetAlwaysOnTop(b); -} - -export function WindowSetSystemDefaultTheme() { - window.runtime.WindowSetSystemDefaultTheme(); -} - -export function WindowSetLightTheme() { - window.runtime.WindowSetLightTheme(); -} - -export function WindowSetDarkTheme() { - window.runtime.WindowSetDarkTheme(); -} - -export function WindowCenter() { - window.runtime.WindowCenter(); -} - -export function WindowSetTitle(title) { - window.runtime.WindowSetTitle(title); -} - -export function WindowFullscreen() { - window.runtime.WindowFullscreen(); -} - -export function WindowUnfullscreen() { - window.runtime.WindowUnfullscreen(); -} - -export function WindowIsFullscreen() { - return window.runtime.WindowIsFullscreen(); -} - -export function WindowGetSize() { - return window.runtime.WindowGetSize(); -} - -export function WindowSetSize(width, height) { - window.runtime.WindowSetSize(width, height); -} - -export function WindowSetMaxSize(width, height) { - window.runtime.WindowSetMaxSize(width, height); -} - -export function WindowSetMinSize(width, height) { - window.runtime.WindowSetMinSize(width, height); -} - -export function WindowSetPosition(x, y) { - window.runtime.WindowSetPosition(x, y); -} - -export function WindowGetPosition() { - return window.runtime.WindowGetPosition(); -} - -export function WindowHide() { - window.runtime.WindowHide(); -} - -export function WindowShow() { - window.runtime.WindowShow(); -} - -export function WindowMaximise() { - window.runtime.WindowMaximise(); -} - -export function WindowToggleMaximise() { - window.runtime.WindowToggleMaximise(); -} - -export function WindowUnmaximise() { - window.runtime.WindowUnmaximise(); -} - -export function WindowIsMaximised() { - return window.runtime.WindowIsMaximised(); -} - -export function WindowMinimise() { - window.runtime.WindowMinimise(); -} - -export function WindowUnminimise() { - window.runtime.WindowUnminimise(); -} - -export function WindowSetBackgroundColour(R, G, B, A) { - window.runtime.WindowSetBackgroundColour(R, G, B, A); -} - -export function ScreenGetAll() { - return window.runtime.ScreenGetAll(); -} - -export function WindowIsMinimised() { - return window.runtime.WindowIsMinimised(); -} - -export function WindowIsNormal() { - return window.runtime.WindowIsNormal(); -} - -export function BrowserOpenURL(url) { - window.runtime.BrowserOpenURL(url); -} - -export function Environment() { - return window.runtime.Environment(); -} - -export function Quit() { - window.runtime.Quit(); -} - -export function Hide() { - window.runtime.Hide(); -} - -export function Show() { - window.runtime.Show(); -} - -export function ClipboardGetText() { - return window.runtime.ClipboardGetText(); -} - -export function ClipboardSetText(text) { - return window.runtime.ClipboardSetText(text); -} - -/** - * Callback for OnFileDrop returns a slice of file path strings when a drop is finished. - * - * @export - * @callback OnFileDropCallback - * @param {number} x - x coordinate of the drop - * @param {number} y - y coordinate of the drop - * @param {string[]} paths - A list of file paths. - */ - -/** - * OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings. - * - * @export - * @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished. - * @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target) - */ -export function OnFileDrop(callback, useDropTarget) { - return window.runtime.OnFileDrop(callback, useDropTarget); -} - -/** - * OnFileDropOff removes the drag and drop listeners and handlers. - */ -export function OnFileDropOff() { - return window.runtime.OnFileDropOff(); -} - -export function CanResolveFilePaths() { - return window.runtime.CanResolveFilePaths(); -} - -export function ResolveFilePaths(files) { - return window.runtime.ResolveFilePaths(files); -} \ No newline at end of file diff --git a/cmd/npc/npc-gui/frontend/yarn.lock b/cmd/npc/npc-gui/frontend/yarn.lock index e2e8a56..2e170f3 100644 --- a/cmd/npc/npc-gui/frontend/yarn.lock +++ b/cmd/npc/npc-gui/frontend/yarn.lock @@ -2,30 +2,30 @@ # yarn lockfile v1 -"@babel/helper-string-parser@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz#54da796097ab19ce67ed9f88b47bb2ec49367687" - integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA== +"@babel/helper-string-parser@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz#7f0871d99824d23137d60f86fcf6130fd5a1b51f" + integrity sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw== -"@babel/helper-validator-identifier@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz#010b6938fab7cb7df74aa2bbc06aa503b8fe5fb4" - integrity sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q== +"@babel/helper-validator-identifier@^7.29.7": + version "7.29.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz#bd87084ced0c796ec46bda492de6e83d29e89fc2" + integrity sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg== -"@babel/parser@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.28.5.tgz#0b0225ee90362f030efd644e8034c99468893b08" - integrity sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ== +"@babel/parser@^7.29.8": + version "7.29.8" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.29.8.tgz#9653716a2f10c677b98fbc63d4bfb000c302cf17" + integrity sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA== dependencies: - "@babel/types" "^7.28.5" + "@babel/types" "^7.29.8" -"@babel/types@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.28.5.tgz#10fc405f60897c35f07e85493c932c7b5ca0592b" - integrity sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA== +"@babel/types@^7.29.8": + version "7.29.8" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.29.8.tgz#1229eef31d85156d70fa3f4cd859376d0eaf6863" + integrity sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg== dependencies: - "@babel/helper-string-parser" "^7.27.1" - "@babel/helper-validator-identifier" "^7.28.5" + "@babel/helper-string-parser" "^7.29.7" + "@babel/helper-validator-identifier" "^7.29.7" "@esbuild/android-arm64@0.18.20": version "0.18.20" @@ -147,95 +147,101 @@ resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-4.6.2.tgz#057d2ded94c4e71b94e9814f92dcd9306317aa46" integrity sha512-kqf7SGFoG+80aZG6Pf+gsZIVvGSCKE98JbiWqcCV9cThtg91Jav0yvYFC9Zb+jKetNGF6ZKeoaxgZfND21fWKw== -"@vue/compiler-core@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.5.26.tgz#1a91ea90980528bedff7b1c292690bfb30612485" - integrity sha512-vXyI5GMfuoBCnv5ucIT7jhHKl55Y477yxP6fc4eUswjP8FG3FFVFd41eNDArR+Uk3QKn2Z85NavjaxLxOC19/w== +"@vue/compiler-core@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.5.41.tgz#82a4012d8b420f5a62c1658a72d16f7d1edf11aa" + integrity sha512-q0Xtv/F9w2YO/7htQhtiL+Ev2WCJbe5N2hc+XfgyKkEKqWpSxknmT8QOuGdEKNdjPq0c3F7rNpFkTo3Kfrm7pg== dependencies: - "@babel/parser" "^7.28.5" - "@vue/shared" "3.5.26" - entities "^7.0.0" + "@babel/parser" "^7.29.8" + "@vue/shared" "3.5.41" + entities "^7.0.1" estree-walker "^2.0.2" source-map-js "^1.2.1" -"@vue/compiler-dom@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.5.26.tgz#66c36b6ed8bdf43236d7188ea332bc9d078eb286" - integrity sha512-y1Tcd3eXs834QjswshSilCBnKGeQjQXB6PqFn/1nxcQw4pmG42G8lwz+FZPAZAby6gZeHSt/8LMPfZ4Rb+Bd/A== +"@vue/compiler-dom@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.5.41.tgz#1029f75de09c665a0a92c6156463754192acb361" + integrity sha512-oKacVfNglLvGjnS6BXOlGL7EyG2h8X03pqXCjzotRZUaXGjbrTJUnVAQjrCqUnS+lyu31nwQjZY/d817GmCnfw== dependencies: - "@vue/compiler-core" "3.5.26" - "@vue/shared" "3.5.26" + "@vue/compiler-core" "3.5.41" + "@vue/shared" "3.5.41" -"@vue/compiler-sfc@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.5.26.tgz#fb1c6c4bf9a9e22bb169e039e19437cb6995917a" - integrity sha512-egp69qDTSEZcf4bGOSsprUr4xI73wfrY5oRs6GSgXFTiHrWj4Y3X5Ydtip9QMqiCMCPVwLglB9GBxXtTadJ3mA== +"@vue/compiler-sfc@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.5.41.tgz#f9c7c2170ad6ee4bf35c178b5df026485d8a63db" + integrity sha512-XJhip7R2wy6vX3knCxdZN4KracFaZUef58s1KYewqluedHIJaPIVfXoYT7MF1F8nCvv6k8bWWxDC8opMkg1VTQ== dependencies: - "@babel/parser" "^7.28.5" - "@vue/compiler-core" "3.5.26" - "@vue/compiler-dom" "3.5.26" - "@vue/compiler-ssr" "3.5.26" - "@vue/shared" "3.5.26" + "@babel/parser" "^7.29.8" + "@vue/compiler-core" "3.5.41" + "@vue/compiler-dom" "3.5.41" + "@vue/compiler-ssr" "3.5.41" + "@vue/shared" "3.5.41" estree-walker "^2.0.2" magic-string "^0.30.21" - postcss "^8.5.6" + postcss "^8.5.19" source-map-js "^1.2.1" -"@vue/compiler-ssr@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.5.26.tgz#f6e94bccbb5339180779036ddfb614f998a197ea" - integrity sha512-lZT9/Y0nSIRUPVvapFJEVDbEXruZh2IYHMk2zTtEgJSlP5gVOqeWXH54xDKAaFS4rTnDeDBQUYDtxKyoW9FwDw== +"@vue/compiler-ssr@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.5.41.tgz#8e5f9f6a8d21b802fce7373807dd935ed4541083" + integrity sha512-U3v5OejKEGqOI0Wy0+Sz7hGuIFZHA4LSXzrNM3IMIeDyJEBBfTpX26n3SDgToRpP2bLc9FfI2j/kSgcJ8Emq5A== dependencies: - "@vue/compiler-dom" "3.5.26" - "@vue/shared" "3.5.26" + "@vue/compiler-dom" "3.5.41" + "@vue/shared" "3.5.41" -"@vue/reactivity@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.5.26.tgz#59a1edf566dc80133c1c26c93711c877e8602c48" - integrity sha512-9EnYB1/DIiUYYnzlnUBgwU32NNvLp/nhxLXeWRhHUEeWNTn1ECxX8aGO7RTXeX6PPcxe3LLuNBFoJbV4QZ+CFQ== +"@vue/reactivity@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.5.41.tgz#83be61b88b198f21c157d3aa6dcb843a25a11872" + integrity sha512-rznsqKM0np0x18EjzF8x88MpEhdNsffbvFbckLL5+oUKz1BxAImEmO7J1ArRYSyo6aQaVoBDp7jEkT91OOxydA== dependencies: - "@vue/shared" "3.5.26" + "@vue/shared" "3.5.41" -"@vue/runtime-core@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.5.26.tgz#3f2c040bcf8018c03a1ab5adb0d788c13c986f0e" - integrity sha512-xJWM9KH1kd201w5DvMDOwDHYhrdPTrAatn56oB/LRG4plEQeZRQLw0Bpwih9KYoqmzaxF0OKSn6swzYi84e1/Q== +"@vue/runtime-core@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.5.41.tgz#a3e023c9f21809c81f24813dacb7ffa18a2e4161" + integrity sha512-Vcry58hiAKwGen9Z1jUZE0feFsNArPCMOImYI8el48A9Idf6DuQYD0U05zZIF2Iad1hGhPSvcbBbAOhNr55fhg== dependencies: - "@vue/reactivity" "3.5.26" - "@vue/shared" "3.5.26" + "@vue/reactivity" "3.5.41" + "@vue/shared" "3.5.41" -"@vue/runtime-dom@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.5.26.tgz#5954848614883948ecc1f631a67b32cc32f81936" - integrity sha512-XLLd/+4sPC2ZkN/6+V4O4gjJu6kSDbHAChvsyWgm1oGbdSO3efvGYnm25yCjtFm/K7rrSDvSfPDgN1pHgS4VNQ== +"@vue/runtime-dom@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.5.41.tgz#428f7a0420402385fae17d413d25169f98f64205" + integrity sha512-3vVBahVBS9+U6cmXBLyb8nE6/yYo4J/CGI9eVFs3KiMc0YHuudwKyShTD65jtJy/L9PUUxNAFu4cj4LiJ0UFbw== dependencies: - "@vue/reactivity" "3.5.26" - "@vue/runtime-core" "3.5.26" - "@vue/shared" "3.5.26" + "@vue/reactivity" "3.5.41" + "@vue/runtime-core" "3.5.41" + "@vue/shared" "3.5.41" csstype "^3.2.3" -"@vue/server-renderer@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.5.26.tgz#269055497fcc75b3984063f866f17c748b565ef4" - integrity sha512-TYKLXmrwWKSodyVuO1WAubucd+1XlLg4set0YoV+Hu8Lo79mp/YMwWV5mC5FgtsDxX3qo1ONrxFaTP1OQgy1uA== +"@vue/server-renderer@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.5.41.tgz#035a38c79182f154495238ea83acba24266ac200" + integrity sha512-n6hx/pNFfbD6SuyeuMVkvqox8bwf/ET9JlA/kAz/imw8sw++wkqKe2mHX5KutjPpbKE4Z56yTHszoOjGMI9igQ== dependencies: - "@vue/compiler-ssr" "3.5.26" - "@vue/shared" "3.5.26" + "@vue/compiler-ssr" "3.5.41" + "@vue/runtime-dom" "3.5.41" + "@vue/shared" "3.5.41" -"@vue/shared@3.5.26": - version "3.5.26" - resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.5.26.tgz#1e02ef2d64aced818cd31d81ce5175711dc90a9f" - integrity sha512-7Z6/y3uFI5PRoKeorTOSXKcDj0MSasfNNltcslbFrPpcw6aXRUALq4IfJlaTRspiWIUOEZbrpM+iQGmCOiWe4A== +"@vue/shared@3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.5.41.tgz#ac476497f74495f7525087270849841756555cf2" + integrity sha512-IOnwSCma8j+9xJT6b8H0dEYidC80NsYmNMlZxRsukYcSoGaDBohog5hDxzeUXdFeGWFA++vWvxqOmrr96VlqMA== + +"@wailsio/runtime@^3.0.0-beta.12": + version "3.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@wailsio/runtime/-/runtime-3.0.0-beta.12.tgz#0fb8347441271fae40f59641fd9f66b56561b5bc" + integrity sha512-2B456rspX5rDXYhNjRqXNDOPkRXjletGJ4R3beF2FGs7K67MTovLy9acXHYb8nolzL96kygyJ622RIjB45oumg== csstype@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.2.3.tgz#ec48c0f3e993e50648c86da559e2610995cf989a" integrity sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ== -entities@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-7.0.0.tgz#2ae4e443f3f17d152d3f5b0f79b932c1e59deb7a" - integrity sha512-FDWG5cmEYf2Z00IkYRhbFrwIwvdFKH07uV8dvNy0omp/Qb1xcyCWp2UDtcwJF4QZZvk0sLudP6/hAu42TaqVhQ== +entities@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-7.0.1.tgz#26e8a88889db63417dcb9a1e79a3f1bc92b5976b" + integrity sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA== esbuild@^0.18.10: version "0.18.20" @@ -282,29 +288,29 @@ magic-string@^0.30.21: dependencies: "@jridgewell/sourcemap-codec" "^1.5.5" -nanoid@^3.3.11: - version "3.3.11" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b" - integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w== +nanoid@^3.3.17: + version "3.3.18" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.18.tgz#f66a2de1199ffde0fcf21c8a5f13106b1c081913" + integrity sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w== picocolors@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== -postcss@^8.4.27, postcss@^8.5.6: - version "8.5.6" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c" - integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg== +postcss@^8.4.27, postcss@^8.5.19: + version "8.5.26" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.26.tgz#6e75135780c7e10df3433bf2266c552d35c8c620" + integrity sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ== dependencies: - nanoid "^3.3.11" + nanoid "^3.3.17" picocolors "^1.1.1" source-map-js "^1.2.1" rollup@^3.27.1: - version "3.29.5" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.5.tgz#8a2e477a758b520fb78daf04bca4c522c1da8a54" - integrity sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w== + version "3.30.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.30.0.tgz#3fa506fee2c5ba9d540a38da87067376cd55966d" + integrity sha512-kQvGasUgN+AlWGliFn2POSajRQEsULVYFGTvOZmK06d7vCD+YhZztt70kGk3qaeAXeWYL5eO7zx+rAubBc55eA== optionalDependencies: fsevents "~2.3.2" @@ -325,12 +331,12 @@ vite@^4.3.9: fsevents "~2.3.2" vue@^3.3.4: - version "3.5.26" - resolved "https://registry.yarnpkg.com/vue/-/vue-3.5.26.tgz#03a0b17311e0e593d34b9358fa249b85e3a6d9fb" - integrity sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA== + version "3.5.41" + resolved "https://registry.yarnpkg.com/vue/-/vue-3.5.41.tgz#8864bddfe59ce128a28c9bad219cd9248916af73" + integrity sha512-2laE0p+aK+/AOPG/XL/WepOs/GlK755LJ1XECi9kDUrz1FKNw8rb2Xzlw9JS1rqEV55nb0ttsKxVlTCcd+R5cg== dependencies: - "@vue/compiler-dom" "3.5.26" - "@vue/compiler-sfc" "3.5.26" - "@vue/runtime-dom" "3.5.26" - "@vue/server-renderer" "3.5.26" - "@vue/shared" "3.5.26" + "@vue/compiler-dom" "3.5.41" + "@vue/compiler-sfc" "3.5.41" + "@vue/runtime-dom" "3.5.41" + "@vue/server-renderer" "3.5.41" + "@vue/shared" "3.5.41" diff --git a/cmd/npc/npc-gui/go.mod b/cmd/npc/npc-gui/go.mod index eb42398..5b6cfde 100644 --- a/cmd/npc/npc-gui/go.mod +++ b/cmd/npc/npc-gui/go.mod @@ -1,15 +1,12 @@ module npc-gui -go 1.24.0 - -toolchain go1.24.9 +go 1.25.0 require ( ehang.io/nps v0.0.0-00010101000000-000000000000 github.com/astaxie/beego v1.12.3 - github.com/energye/systray v1.0.2 - github.com/wailsapp/wails/v2 v2.11.0 - golang.org/x/sys v0.30.0 + github.com/wailsapp/wails/v3 v3.0.0-beta.12 + golang.org/x/sys v0.46.0 ) // 使用本地路径替代依赖 @@ -19,50 +16,38 @@ replace ( ) require ( - github.com/bep/debounce v1.2.1 // indirect + github.com/adrg/xdg v0.5.3 // indirect + github.com/coder/websocket v1.8.14 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/godbus/dbus/v5 v5.2.2 // indirect github.com/golang/snappy v0.0.3 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/gorilla/websocket v1.5.3 // indirect - github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect - github.com/klauspost/cpuid/v2 v2.0.6 // indirect + github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/klauspost/reedsolomon v1.9.12 // indirect - github.com/labstack/echo/v4 v4.13.3 // indirect - github.com/labstack/gommon v0.4.2 // indirect - github.com/leaanthony/go-ansi-parser v1.6.1 // indirect - github.com/leaanthony/gosod v1.0.4 // indirect - github.com/leaanthony/slicer v1.6.0 // indirect - github.com/leaanthony/u v1.1.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/panjf2000/ants/v2 v2.4.2 // indirect github.com/pires/go-proxyproto v0.8.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect - github.com/rivo/uniseg v0.4.7 // indirect - github.com/samber/lo v1.49.1 // indirect github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect github.com/shirou/gopsutil/v3 v3.23.10 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect - github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c // indirect github.com/tjfoc/gmsm v1.4.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect - github.com/tkrajina/go-reflector v0.5.8 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasttemplate v1.2.2 // indirect - github.com/wailsapp/go-webview2 v1.0.22 // indirect - github.com/wailsapp/mimetype v1.4.1 // indirect github.com/xtaci/kcp-go v5.4.20+incompatible // indirect - github.com/yusufpapurcu/wmi v1.2.3 // indirect - golang.org/x/crypto v0.33.0 // indirect - golang.org/x/net v0.35.0 // indirect - golang.org/x/text v0.22.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + golang.org/x/crypto v0.53.0 // indirect + golang.org/x/net v0.56.0 // indirect + golang.org/x/text v0.39.0 // indirect golang.org/x/time v0.14.0 // indirect + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/cmd/npc/npc-gui/go.sum b/cmd/npc/npc-gui/go.sum index 0eb3f0f..ddc9b9b 100644 --- a/cmd/npc/npc-gui/go.sum +++ b/cmd/npc/npc-gui/go.sum @@ -2,19 +2,22 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= +github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= +github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ= github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU= -github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= -github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g= +github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U= github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c= github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -22,21 +25,20 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/energye/systray v1.0.2 h1:63R4prQkANtpM2CIA4UrDCuwZFt+FiygG77JYCsNmXc= -github.com/energye/systray v1.0.2/go.mod h1:sp7Q/q/I4/w5ebvpSuJVep71s9Bg7L9ZVp69gBASehM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/exfly/beego v1.12.0-export-init h1:VQNYKdXhAwZGUaFmQv8Aj921O3rQJZRIF8xeGrhsjrI= github.com/exfly/beego v1.12.0-export-init/go.mod h1:fysx+LZNZKnvh4GED/xND7jWtjCR6HzydR2Hh2Im57o= +github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e h1:Lf/gRkoycfOBPa42vU2bbgPurFong6zXeFtPoxholzU= +github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e/go.mod h1:uNVvRXArCGbZ508SxYYTC5v1JWoz2voff5pm25jU1Ok= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= +github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -59,44 +61,29 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= -github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= -github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= +github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1 h1:njuLRcjAuMKr7kI3D85AXWkw6/+v9PwtV6M6o11sWHQ= +github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/klauspost/cpuid/v2 v2.0.2/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.0.6 h1:dQ5ueTiftKxp0gyjKSx5+8BtPWkyQbd95m8Gys/RarI= -github.com/klauspost/cpuid/v2 v2.0.6/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/klauspost/reedsolomon v1.9.12 h1:EyOucRmcrLH+2hqKGdoA5SM8pwPKR6BJsf3r6zpYOA0= github.com/klauspost/reedsolomon v1.9.12/go.mod h1:nLvuzNvy1ZDNQW30IuMc2ZWCbiqrJgdLoUS2X8HAUVg= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY= -github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g= -github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= -github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= -github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc= -github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA= -github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed1YDKpEz01A= -github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU= -github.com/leaanthony/gosod v1.0.4 h1:YLAbVyd591MRffDgxUOU1NwLhT9T1/YiwjKZpkNFeaI= -github.com/leaanthony/gosod v1.0.4/go.mod h1:GKuIL0zzPj3O1SdWQOdgURSuhkF+Urizzxh26t9f1cw= -github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js= -github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8= -github.com/leaanthony/u v1.1.1 h1:TUFjwDGlNX+WuwVEzDqQwC2lOv0P4uhTQw7CMFdiK7M= -github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= @@ -107,8 +94,6 @@ github.com/panjf2000/ants/v2 v2.4.2/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OI github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKpXEe0= github.com/pires/go-proxyproto v0.8.0/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -117,11 +102,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew= -github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o= github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM= @@ -141,46 +121,35 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 h1:89CEmDvlq/F7SJEOqkIdNDGJXrQIhuIx9D2DBXjavSU= github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU= github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b h1:fj5tQ8acgNUr6O8LEplsxDhUIe2573iLkJc+PqnzZTI= github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4= -github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c h1:coVla7zpsycc+kA9NXpcvv2E4I7+ii6L5hZO2S6C3kw= -github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg= github.com/tjfoc/gmsm v1.4.0 h1:8nbaiZG+iVdh+fXVw0DZoZZa7a4TGm3Qab+xdrdzj8s= github.com/tjfoc/gmsm v1.4.0/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ= -github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= -github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6NZijQ58= -github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc= -github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= -github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= -github.com/wailsapp/wails/v2 v2.11.0 h1:seLacV8pqupq32IjS4Y7V8ucab0WZwtK6VvUVxSBtqQ= -github.com/wailsapp/wails/v2 v2.11.0/go.mod h1:jrf0ZaM6+GBc1wRmXsM8cIvzlg0karYin3erahI4+0k= +github.com/wailsapp/wails/v3 v3.0.0-beta.12 h1:Vema2kFgJvkwPovQ8GMBBrkZNm5cKVR4bYzSCMgU+PU= +github.com/wailsapp/wails/v3 v3.0.0-beta.12/go.mod h1:zKZYhB3WjrN5LhJWbnOAVMN0Xf8qTozbw2nf5micKl4= github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc= github.com/xtaci/kcp-go v5.4.20+incompatible h1:TN1uey3Raw0sTz0Fg8GkfM0uH3YwzhnZWQ1bABv5xAg= github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE= -github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -192,9 +161,8 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= -golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -203,26 +171,20 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus= +golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/cmd/npc/npc-gui/logger.go b/cmd/npc/npc-gui/logger.go new file mode 100644 index 0000000..6c55a15 --- /dev/null +++ b/cmd/npc/npc-gui/logger.go @@ -0,0 +1,310 @@ +package main + +import ( + "bufio" + "encoding/json" + "fmt" + "io" + "log/slog" + "os" + "path/filepath" + "strings" + "sync" + "time" + + "github.com/astaxie/beego/logs" +) + +const ( + // logBufferCap 每个客户端内存中最多保留的日志条数 + logBufferCap = 3000 + // logFileMaxSize 单个日志文件超过该大小后轮转(5MB) + logFileMaxSize = 5 << 20 + // logFileMaxBackups 轮转时最多保留的历史文件个数(.1 .2 .3) + logFileMaxBackups = 3 +) + +// initAppLogger 初始化 GUI 自身的日志系统。 +// - 全局 beego logger 仍切到 store,避免客户端库的全局日志刷屏控制台(保持原有行为) +// - 应用自身日志使用 slog(JSON),同时写入 logs/npc-gui.log 与控制台 +func initAppLogger() { + _ = logs.SetLogger("store") + logs.SetLevel(logs.LevelDebug) + + var w io.Writer = os.Stderr + if fw, err := newRotatingFileWriter(filepath.Join(getLogsPath(), "npc-gui.log")); err == nil { + w = io.MultiWriter(fw, os.Stderr) + } + logger := slog.New(slog.NewJSONHandler(w, &slog.HandlerOptions{Level: slog.LevelDebug})) + slog.SetDefault(logger) +} + +// rotatingFileWriter 带大小轮转的日志文件写入器(线程安全)。 +// 写入超过 maxSize 时把当前文件顺延为 .1 .2 ...,保留 maxBackups 份历史。 +type rotatingFileWriter struct { + mu sync.Mutex + path string + maxSize int64 + maxBackups int + file *os.File + size int64 +} + +func newRotatingFileWriter(path string) (*rotatingFileWriter, error) { + w := &rotatingFileWriter{path: path, maxSize: logFileMaxSize, maxBackups: logFileMaxBackups} + if err := w.open(); err != nil { + return nil, err + } + return w, nil +} + +func (w *rotatingFileWriter) open() error { + f, err := os.OpenFile(w.path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644) + if err != nil { + return err + } + st, err := f.Stat() + if err != nil { + _ = f.Close() + return err + } + w.file = f + w.size = st.Size() + return nil +} + +func (w *rotatingFileWriter) Write(p []byte) (int, error) { + w.mu.Lock() + defer w.mu.Unlock() + if w.file == nil { + if err := w.open(); err != nil { + return 0, err + } + } + if w.size > 0 && w.size+int64(len(p)) > w.maxSize { + w.rotateLocked() + } + n, err := w.file.Write(p) + w.size += int64(n) + return n, err +} + +func (w *rotatingFileWriter) rotateLocked() { + _ = w.file.Close() + w.file = nil + for i := w.maxBackups - 1; i >= 1; i-- { + src := fmt.Sprintf("%s.%d", w.path, i) + if _, err := os.Stat(src); err == nil { + _ = os.Remove(fmt.Sprintf("%s.%d", w.path, i+1)) + _ = os.Rename(src, fmt.Sprintf("%s.%d", w.path, i+1)) + } + } + _ = os.Remove(w.path + ".1") + _ = os.Rename(w.path, w.path+".1") + w.size = 0 + _ = w.open() +} + +// truncate 清空当前文件内容 +func (w *rotatingFileWriter) truncate() error { + w.mu.Lock() + defer w.mu.Unlock() + if w.file != nil { + _ = w.file.Close() + w.file = nil + } + f, err := os.Create(w.path) + if err != nil { + return err + } + w.file = f + w.size = 0 + return nil +} + +func (w *rotatingFileWriter) Close() error { + w.mu.Lock() + defer w.mu.Unlock() + if w.file != nil { + err := w.file.Close() + w.file = nil + return err + } + return nil +} + +// ringBuffer 固定容量的环形日志缓冲 +type ringBuffer struct { + buf []ConnectionLog + start int + count int +} + +func newRingBuffer(cap int) *ringBuffer { + return &ringBuffer{buf: make([]ConnectionLog, cap)} +} + +func (r *ringBuffer) add(e ConnectionLog) { + if r.count == len(r.buf) { + r.buf[r.start] = e + r.start = (r.start + 1) % len(r.buf) + } else { + r.buf[(r.start+r.count)%len(r.buf)] = e + r.count++ + } +} + +func (r *ringBuffer) all() []ConnectionLog { + out := make([]ConnectionLog, 0, r.count) + for i := 0; i < r.count; i++ { + out = append(out, r.buf[(r.start+i)%len(r.buf)]) + } + return out +} + +func (r *ringBuffer) reset() { + r.start = 0 + r.count = 0 +} + +// clientLogStore 单个客户端的日志存储:内存环形缓冲 + JSON Lines 文件持久化。 +// UI 直接读取内存缓冲,不再解析日志文件文本。 +type clientLogStore struct { + mu sync.Mutex + clientId string + ring *ringBuffer + file *rotatingFileWriter +} + +func newClientLogStore(clientId string) *clientLogStore { + s := &clientLogStore{ + clientId: clientId, + ring: newRingBuffer(logBufferCap), + } + if fw, err := newRotatingFileWriter(getClientLogFilePath(clientId)); err == nil { + s.file = fw + s.loadHistoryLocked() + } + return s +} + +// loadHistoryLocked 启动时把已有日志文件尾部的 JSON 行载入内存缓冲(跨重启保留历史)。 +func (s *clientLogStore) loadHistoryLocked() { + data, err := os.ReadFile(s.file.path) + if err != nil { + return + } + sc := bufio.NewScanner(strings.NewReader(string(data))) + sc.Buffer(make([]byte, 1024*1024), 1024*1024) + var lines []string + for sc.Scan() { + line := strings.TrimSpace(sc.Text()) + if line == "" { + continue + } + lines = append(lines, line) + } + if len(lines) > logBufferCap { + lines = lines[len(lines)-logBufferCap:] + } + for _, line := range lines { + var e ConnectionLog + if json.Unmarshal([]byte(line), &e) == nil && e.Message != "" { + s.ring.add(e) + } + } +} + +// log 写入一条日志:先入内存缓冲,再持久化到 JSON Lines 文件。 +func (s *clientLogStore) log(level, format string, v ...interface{}) { + msg := fmt.Sprintf(format, v...) + logType := level + if level == "info" && isSuccessMessage(msg) { + logType = "success" + } + e := ConnectionLog{ + Timestamp: time.Now().Format("2006-01-02 15:04:05"), + Message: msg, + Type: logType, + ClientId: s.clientId, + } + s.mu.Lock() + defer s.mu.Unlock() + s.ring.add(e) + if s.file != nil { + if line, err := json.Marshal(e); err == nil { + _, _ = s.file.Write(append(line, '\n')) + } + } +} + +func (s *clientLogStore) snapshot() []ConnectionLog { + s.mu.Lock() + defer s.mu.Unlock() + return s.ring.all() +} + +func (s *clientLogStore) clear() error { + s.mu.Lock() + defer s.mu.Unlock() + s.ring.reset() + if s.file != nil { + return s.file.truncate() + } + return nil +} + +func (s *clientLogStore) close() { + s.mu.Lock() + defer s.mu.Unlock() + if s.file != nil { + _ = s.file.Close() + s.file = nil + } +} + +var ( + logStoresMu sync.Mutex + logStores = make(map[string]*clientLogStore) +) + +// getClientLogStore 获取客户端的日志存储(懒创建,未启动也能查看历史日志) +func getClientLogStore(clientId string) *clientLogStore { + logStoresMu.Lock() + defer logStoresMu.Unlock() + if s, ok := logStores[clientId]; ok { + return s + } + s := newClientLogStore(clientId) + logStores[clientId] = s + return s +} + +// closeAllLogStores 应用退出时关闭所有日志文件 +func closeAllLogStores() { + logStoresMu.Lock() + defer logStoresMu.Unlock() + for id, s := range logStores { + s.close() + delete(logStores, id) + } +} + +// trpcLogger 把 client.Logger 桥接到 clientLogStore,供 TRPClient 使用。 +// Trace 级别与原先 beego(LevelDebug) 行为一致,不落盘。 +type trpcLogger struct { + store *clientLogStore +} + +func (l *trpcLogger) Info(format string, v ...interface{}) { l.store.log("info", format, v...) } +func (l *trpcLogger) Error(format string, v ...interface{}) { l.store.log("error", format, v...) } +func (l *trpcLogger) Warn(format string, v ...interface{}) { l.store.log("warning", format, v...) } +func (l *trpcLogger) Trace(format string, v ...interface{}) {} + +// isSuccessMessage 判断是否为“成功”类日志(用于 UI 高亮) +func isSuccessMessage(msg string) bool { + lower := strings.ToLower(msg) + return strings.Contains(msg, "成功") || + strings.Contains(lower, "success") || + strings.Contains(lower, "connected") +} diff --git a/cmd/npc/npc-gui/logger_test.go b/cmd/npc/npc-gui/logger_test.go new file mode 100644 index 0000000..f1de220 --- /dev/null +++ b/cmd/npc/npc-gui/logger_test.go @@ -0,0 +1,120 @@ +package main + +import ( + "os" + "path/filepath" + "testing" +) + +func TestRingBuffer(t *testing.T) { + r := newRingBuffer(3) + r.add(ConnectionLog{Message: "1"}) + r.add(ConnectionLog{Message: "2"}) + r.add(ConnectionLog{Message: "3"}) + r.add(ConnectionLog{Message: "4"}) + all := r.all() + if len(all) != 3 || all[0].Message != "2" || all[2].Message != "4" { + t.Fatalf("unexpected ring buffer contents: %v", all) + } + r.reset() + if len(r.all()) != 0 { + t.Fatal("reset failed") + } +} + +func TestRotatingFileWriterRotation(t *testing.T) { + path := filepath.Join(t.TempDir(), "test.log") + w, err := newRotatingFileWriter(path) + if err != nil { + t.Fatal(err) + } + defer w.Close() + w.maxSize = 10 + w.maxBackups = 2 + for i := 0; i < 20; i++ { + if _, err := w.Write([]byte("0123456789\n")); err != nil { + t.Fatal(err) + } + } + if _, err := os.Stat(path + ".1"); err != nil { + t.Fatal("missing .1 backup:", err) + } + if _, err := os.Stat(path + ".2"); err != nil { + t.Fatal("missing .2 backup:", err) + } + if err := w.truncate(); err != nil { + t.Fatal(err) + } + if st, err := os.Stat(path); err != nil || st.Size() != 0 { + t.Fatal("truncate failed") + } +} + +func TestClientLogStore(t *testing.T) { + path := filepath.Join(t.TempDir(), "client.log") + fw, err := newRotatingFileWriter(path) + if err != nil { + t.Fatal(err) + } + store := &clientLogStore{clientId: "test", ring: newRingBuffer(logBufferCap), file: fw} + defer fw.Close() + + store.log("info", "hello %s", "world") + store.log("error", "boom") + store.log("info", "连接成功") + + snap := store.snapshot() + if len(snap) != 3 { + t.Fatalf("expected 3 logs, got %d", len(snap)) + } + if snap[0].Type != "info" || snap[0].Message != "hello world" { + t.Fatalf("bad entry: %+v", snap[0]) + } + if snap[1].Type != "error" { + t.Fatalf("bad type: %+v", snap[1]) + } + if snap[2].Type != "success" { + t.Fatalf("expected success type, got %+v", snap[2]) + } + + // 从文件恢复历史 + fw2, err := newRotatingFileWriter(path) + if err != nil { + t.Fatal(err) + } + store2 := &clientLogStore{clientId: "test", ring: newRingBuffer(logBufferCap), file: fw2} + defer fw2.Close() + store2.loadHistoryLocked() + snap2 := store2.snapshot() + if len(snap2) != 3 { + t.Fatalf("expected 3 logs after reload, got %d", len(snap2)) + } + if snap2[0].Message != "hello world" || snap2[2].Type != "success" { + t.Fatalf("bad reloaded entries: %+v", snap2) + } + + // 清空 + if err := store.clear(); err != nil { + t.Fatal(err) + } + if len(store.snapshot()) != 0 { + t.Fatal("clear failed") + } + if st, err := os.Stat(path); err != nil || st.Size() != 0 { + t.Fatal("file not truncated after clear") + } +} + +func TestIsSuccessMessage(t *testing.T) { + cases := map[string]bool{ + "客户端连接成功": true, + "Successful connection with server": true, + "connection failed": false, + "启动 NPC 客户端": false, + } + for msg, want := range cases { + if got := isSuccessMessage(msg); got != want { + t.Fatalf("isSuccessMessage(%q) = %v, want %v", msg, got, want) + } + } +} diff --git a/cmd/npc/npc-gui/main.go b/cmd/npc/npc-gui/main.go index 958a06a..d114108 100644 --- a/cmd/npc/npc-gui/main.go +++ b/cmd/npc/npc-gui/main.go @@ -1,65 +1,58 @@ package main import ( - "context" "embed" - "io/fs" + "log" - "github.com/wailsapp/wails/v2" - "github.com/wailsapp/wails/v2/pkg/options" - - "github.com/wailsapp/wails/v2/pkg/options/assetserver" - "github.com/wailsapp/wails/v2/pkg/options/windows" - wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" + "github.com/wailsapp/wails/v3/pkg/application" + "github.com/wailsapp/wails/v3/pkg/events" ) //go:embed all:frontend/dist -var embeddedFiles embed.FS +var assets embed.FS //go:embed build/appicon.png var trayIcon []byte -//go:embed build/appicon.ico -var trayIconICO []byte - func main() { - app := NewApp() - - // Asset server expects the FS root to contain index.html — create a sub FS - assets, err := fs.Sub(embeddedFiles, "frontend/dist") - if err != nil { - panic(err) - } - - runErr := wails.Run(&options.App{ - Title: "NPS 客户端", - Width: 1000, - Height: 600, - MinWidth: 1000, - MinHeight: 600, - AssetServer: &assetserver.Options{ - Assets: assets, + app := application.New(application.Options{ + Name: "NPS 客户端", + Assets: application.AssetOptions{ + Handler: application.AssetFileServerFS(assets), }, - BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, - OnStartup: app.startup, - OnShutdown: app.shutdown, - OnBeforeClose: func(ctx context.Context) bool { - if isQuitting() { - return false - } - wailsRuntime.Hide(ctx) - return true + Windows: application.WindowsOptions{ + DisableQuitOnLastWindowClosed: true, }, - Bind: []interface{}{ - app, + Mac: application.MacOptions{ + ApplicationShouldTerminateAfterLastWindowClosed: false, }, - Windows: &windows.Options{ - WebviewIsTransparent: false, - WindowIsTranslucent: false, + Linux: application.LinuxOptions{ + DisableQuitOnLastWindowClosed: true, }, }) - if runErr != nil { - panic(runErr) + window := app.Window.NewWithOptions(application.WebviewWindowOptions{ + Name: "main", + Title: "NPS 客户端", + Width: 1000, + Height: 600, + MinWidth: 1000, + MinHeight: 600, + BackgroundColour: application.NewRGB(27, 38, 54), + }) + + // 点击关闭按钮时隐藏窗口而不是退出(托盘应用常驻) + window.RegisterHook(events.Common.WindowClosing, func(event *application.WindowEvent) { + if isQuitting() { + return + } + event.Cancel() + window.Hide() + }) + + app.RegisterService(application.NewService(NewApp(app, window))) + + if runErr := app.Run(); runErr != nil { + log.Fatal(runErr) } } diff --git a/cmd/npc/npc-gui/startup_darwin.go b/cmd/npc/npc-gui/startup_darwin.go index 66a6177..baf12f1 100644 --- a/cmd/npc/npc-gui/startup_darwin.go +++ b/cmd/npc/npc-gui/startup_darwin.go @@ -4,10 +4,9 @@ package main import ( "fmt" + "log/slog" "os" "path/filepath" - - "github.com/astaxie/beego/logs" ) const ( @@ -66,7 +65,7 @@ func enableStartupImpl() error { return fmt.Errorf("写入 plist 文件失败: %v", err) } - logs.Info("成功添加开机启动项: %s -> %s", appName, plistPath) + slog.Info("成功添加开机启动项", "app", appName, "path", plistPath) return nil } @@ -80,13 +79,13 @@ func disableStartupImpl() error { // 删除 plist 文件 if err := os.Remove(plistPath); err != nil { if os.IsNotExist(err) { - logs.Info("开机启动项不存在,无需删除") + slog.Info("开机启动项不存在,无需删除") return nil } return fmt.Errorf("删除 plist 文件失败: %v", err) } - logs.Info("成功删除开机启动项: %s", plistPath) + slog.Info("成功删除开机启动项", "path", plistPath) return nil } diff --git a/cmd/npc/npc-gui/startup_linux.go b/cmd/npc/npc-gui/startup_linux.go index ae23188..24c7a0f 100644 --- a/cmd/npc/npc-gui/startup_linux.go +++ b/cmd/npc/npc-gui/startup_linux.go @@ -4,10 +4,9 @@ package main import ( "fmt" + "log/slog" "os" "path/filepath" - - "github.com/astaxie/beego/logs" ) const ( @@ -65,7 +64,7 @@ func enableStartupImpl() error { return fmt.Errorf("写入 desktop 文件失败: %v", err) } - logs.Info("成功添加开机启动项: %s -> %s", appName, desktopPath) + slog.Info("成功添加开机启动项", "app", appName, "path", desktopPath) return nil } @@ -79,13 +78,13 @@ func disableStartupImpl() error { // 删除 .desktop 文件 if err := os.Remove(desktopPath); err != nil { if os.IsNotExist(err) { - logs.Info("开机启动项不存在,无需删除") + slog.Info("开机启动项不存在,无需删除") return nil } return fmt.Errorf("删除 desktop 文件失败: %v", err) } - logs.Info("成功删除开机启动项: %s", desktopPath) + slog.Info("成功删除开机启动项", "path", desktopPath) return nil } diff --git a/cmd/npc/npc-gui/startup_windows.go b/cmd/npc/npc-gui/startup_windows.go index 575e955..90425de 100644 --- a/cmd/npc/npc-gui/startup_windows.go +++ b/cmd/npc/npc-gui/startup_windows.go @@ -4,8 +4,8 @@ package main import ( "fmt" + "log/slog" - "github.com/astaxie/beego/logs" "golang.org/x/sys/windows/registry" ) @@ -32,7 +32,7 @@ func enableStartupImpl() error { return fmt.Errorf("设置注册表值失败: %v", err) } - logs.Info("成功添加开机启动项: %s -> %s", appName, exePath) + slog.Info("成功添加开机启动项", "app", appName, "path", exePath) return nil } @@ -50,13 +50,13 @@ func disableStartupImpl() error { if err != nil { // 如果键不存在,不算错误 if err == registry.ErrNotExist { - logs.Info("开机启动项不存在,无需删除") + slog.Info("开机启动项不存在,无需删除") return nil } return fmt.Errorf("删除注册表值失败: %v", err) } - logs.Info("成功删除开机启动项: %s", appName) + slog.Info("成功删除开机启动项", "app", appName) return nil } diff --git a/cmd/npc/npc-gui/tray.go b/cmd/npc/npc-gui/tray.go index 4040a67..98e2b3c 100644 --- a/cmd/npc/npc-gui/tray.go +++ b/cmd/npc/npc-gui/tray.go @@ -1,120 +1,45 @@ -//go:build !darwin - package main import ( - _ "image/png" - "log" - "os" - "runtime" - "sync" - "time" - - "github.com/energye/systray" - wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" + "github.com/wailsapp/wails/v3/pkg/application" ) -// QuitTray 退出托盘程序 -func QuitTray() { - systray.Quit() -} - -// startTray 初始化系统托盘 +// startTray 初始化系统托盘(使用 Wails v3 内置托盘,三平台统一) func (a *App) startTray() { - // 锁定 OS 线程,确保 Windows 消息循环稳定运行 - runtime.LockOSThread() - defer runtime.UnlockOSThread() + tray := a.app.SystemTray.New() - log.Println("systray: start") + // 使用 PNG 图标(wails3 各平台均支持) + if len(trayIcon) > 0 { + tray.SetIcon(trayIcon) + } + tray.SetTooltip("NPS 客户端") - // 使用 sync.WaitGroup 确保资源正确释放 - var wg sync.WaitGroup - wg.Add(1) - - systray.Run( - func() { - // onReady 回调 - 在主线程执行 - log.Println("systray: onReady start") - defer wg.Done() - - // 增加短暂延迟确保系统托盘完全初始化 - time.Sleep(200 * time.Millisecond) - - // 设置托盘图标 - 增加错误处理 - var iconSet bool - if runtime.GOOS == "windows" { - if len(trayIconICO) > 0 { - log.Println("systray: using embedded ICO icon") - systray.SetIcon(trayIconICO) - iconSet = true - } - } else { - log.Println("systray: using PNG icon for non-windows") - if len(trayIcon) > 0 { - systray.SetIcon(trayIcon) - iconSet = true - } - } - - if !iconSet { - log.Println("systray: no icon provided, using default") - } - - systray.SetTitle("NPS 客户端") - systray.SetTooltip("NPS 客户端") - - // 创建菜单项 - 确保在主线程创建 - showItem := systray.AddMenuItem("显示", "点击显示") - quitItem := systray.AddMenuItem("退出", "点击退出") - - log.Println("systray: menu items added") - - systray.SetOnClick(func(menu systray.IMenu) { - _ = menu - log.Println("[Tray] Left click") - if a.ctx != nil && !isQuitting() { - wailsRuntime.EventsEmit(a.ctx, "tray-show") - go func() { - wailsRuntime.Show(a.ctx) - }() - } - }) - - showItem.Click(func() { - log.Println("[Menu] Show item clicked") - if a.ctx != nil && !isQuitting() { - // 确保在主线程执行 UI 操作 - wailsRuntime.EventsEmit(a.ctx, "tray-show") - // 直接调用 Show 可能跨线程,改用异步调用 - go func() { - wailsRuntime.Show(a.ctx) - }() - } - }) - - quitItem.Click(func() { - log.Println("[Menu] Quit item clicked") - if !isQuitting() { - setQuitting() - - // 先关闭菜单 - systray.Quit() - - // 退出应用 - if a.ctx != nil { - wailsRuntime.Quit(a.ctx) - } else { - os.Exit(0) - } - } - }) - }, - func() { - // onExit 回调 - log.Println("systray: onExit") + menu := a.app.NewMenu() + menu.Add("显示").OnClick(func(_ *application.Context) { + a.showMainWindow() + }) + menu.Add("退出").OnClick(func(_ *application.Context) { + if !isQuitting() { setQuitting() - wg.Wait() - log.Println("systray: exited cleanly") - }, - ) + a.app.Quit() + } + }) + tray.SetMenu(menu) + + // 左键单击托盘图标也显示主窗口 + tray.OnClick(func() { + a.showMainWindow() + }) + + a.tray = tray +} + +// showMainWindow 显示主窗口 +func (a *App) showMainWindow() { + if isQuitting() || a.window == nil { + return + } + a.app.Event.Emit("tray-show") + a.window.Show() + a.window.Focus() } diff --git a/cmd/npc/npc-gui/tray_darwin.go b/cmd/npc/npc-gui/tray_darwin.go deleted file mode 100644 index bfec192..0000000 --- a/cmd/npc/npc-gui/tray_darwin.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build darwin - -package main - -import "log" - -// QuitTray no-op on macOS to avoid AppDelegate conflict with systray. -func QuitTray() {} - -// startTray on macOS: disable systray to avoid duplicate AppDelegate symbols. -func (a *App) startTray() { - log.Println("tray: disabled on darwin (systray AppDelegate conflict)") -} diff --git a/cmd/npc/npc-gui/update.go b/cmd/npc/npc-gui/update.go new file mode 100644 index 0000000..1f1d6ec --- /dev/null +++ b/cmd/npc/npc-gui/update.go @@ -0,0 +1,323 @@ +package main + +import ( + "archive/zip" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "os" + "os/exec" + "path/filepath" + "runtime" + "strconv" + "strings" + "time" + + "ehang.io/nps/lib/version" +) + +const ( + updateRepo = "yisier/nps" + updateAPIURL = "https://api.github.com/repos/" + updateRepo + "/releases/latest" + updateDownBase = "https://github.com/" + updateRepo + "/releases/download" +) + +// UpdateInfo 版本检查结果,供前端展示 +type UpdateInfo struct { + CurrentVersion string `json:"currentVersion"` + LatestVersion string `json:"latestVersion"` + UpdateAvailable bool `json:"updateAvailable"` + ReleaseNotes string `json:"releaseNotes"` + PublishedAt string `json:"publishedAt"` + DownloadURL string `json:"downloadUrl"` + AssetName string `json:"assetName"` +} + +type ghAsset struct { + Name string `json:"name"` + BrowserDownloadURL string `json:"browser_download_url"` +} + +type ghRelease struct { + TagName string `json:"tag_name"` + Body string `json:"body"` + PublishedAt string `json:"published_at"` + Assets []ghAsset `json:"assets"` +} + +// guiAssetName 当前平台对应的 GUI 发布包文件名 +func guiAssetName() string { + return fmt.Sprintf("npc-gui-%s-%s.zip", runtime.GOOS, runtime.GOARCH) +} + +// compareVersion 比较两个版本号(忽略前导 v)。ab 返回 1,相等返回 0 +func compareVersion(a, b string) int { + ai, _ := strconv.Atoi(strings.ReplaceAll(strings.TrimPrefix(strings.TrimSpace(a), "v"), ".", "")) + bi, _ := strconv.Atoi(strings.ReplaceAll(strings.TrimPrefix(strings.TrimSpace(b), "v"), ".", "")) + switch { + case ai < bi: + return -1 + case ai > bi: + return 1 + } + return 0 +} + +// fetchLatestRelease 拉取 GitHub 最新 release 信息 +func fetchLatestRelease() (*ghRelease, error) { + client := &http.Client{Timeout: 15 * time.Second} + req, err := http.NewRequest(http.MethodGet, updateAPIURL, nil) + if err != nil { + return nil, err + } + req.Header.Set("Accept", "application/vnd.github+json") + req.Header.Set("User-Agent", "npc-gui-updater") + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("获取版本信息失败: HTTP %d", resp.StatusCode) + } + rl := new(ghRelease) + if err := json.NewDecoder(resp.Body).Decode(rl); err != nil { + return nil, err + } + if rl.TagName == "" { + return nil, errors.New("无法解析最新版本号") + } + return rl, nil +} + +func findAsset(rl *ghRelease, name string) (*ghAsset, error) { + for i := range rl.Assets { + if rl.Assets[i].Name == name { + return &rl.Assets[i], nil + } + } + return nil, fmt.Errorf("发布资源中未找到 %s,当前平台暂不支持自动更新", name) +} + +// CheckForUpdate 检查是否有新版本可用(检测升级) +func (a *App) CheckForUpdate() (*UpdateInfo, error) { + rl, err := fetchLatestRelease() + if err != nil { + return nil, err + } + latest := strings.TrimPrefix(rl.TagName, "v") + current := version.VERSION + + assetName := guiAssetName() + downloadURL := "" + if asset, err := findAsset(rl, assetName); err == nil { + downloadURL = asset.BrowserDownloadURL + } + + return &UpdateInfo{ + CurrentVersion: current, + LatestVersion: latest, + UpdateAvailable: compareVersion(current, latest) < 0, + ReleaseNotes: rl.Body, + PublishedAt: rl.PublishedAt, + DownloadURL: downloadURL, + AssetName: assetName, + }, nil +} + +// DownloadAndInstallUpdate 下载最新版本并热替换当前可执行文件 +func (a *App) DownloadAndInstallUpdate() error { + rl, err := fetchLatestRelease() + if err != nil { + return err + } + latest := strings.TrimPrefix(rl.TagName, "v") + if compareVersion(version.VERSION, latest) >= 0 { + return fmt.Errorf("当前已是最新版本 %s,无需更新", version.VERSION) + } + + assetName := guiAssetName() + asset, err := findAsset(rl, assetName) + if err != nil { + return err + } + + slog.Info("开始下载更新包", "url", asset.BrowserDownloadURL) + + exePath, err := getExecutablePath() + if err != nil { + return fmt.Errorf("获取当前程序路径失败: %w", err) + } + + tempDir := filepath.Join(os.TempDir(), "npc-gui-update") + _ = os.RemoveAll(tempDir) + if err := os.MkdirAll(tempDir, 0o755); err != nil { + return err + } + + zipPath := filepath.Join(tempDir, assetName) + if err := downloadFile(asset.BrowserDownloadURL, zipPath); err != nil { + return err + } + + if err := replaceFromZip(zipPath, exePath, tempDir); err != nil { + return err + } + + slog.Info("更新完成,请重启程序生效") + return nil +} + +// RestartApp 重启当前程序(更新完成后调用) +func (a *App) RestartApp() error { + exePath, err := getExecutablePath() + if err != nil { + return fmt.Errorf("获取当前程序路径失败: %w", err) + } + cmd := exec.Command(exePath) + if err := cmd.Start(); err != nil { + return fmt.Errorf("启动新版本失败: %w", err) + } + // 延迟退出当前进程,确保新进程已启动 + go func() { + time.Sleep(800 * time.Millisecond) + if a.app != nil { + a.app.Quit() + } + }() + return nil +} + +func downloadFile(url, dest string) error { + client := &http.Client{Timeout: 10 * time.Minute} + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return err + } + req.Header.Set("User-Agent", "npc-gui-updater") + resp, err := client.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("下载更新包失败: HTTP %d", resp.StatusCode) + } + out, err := os.Create(dest) + if err != nil { + return err + } + defer out.Close() + _, err = io.Copy(out, resp.Body) + return err +} + +// replaceFromZip 从 zip 更新包中取出可执行文件并热替换正在运行的程序 +func replaceFromZip(zipPath, exePath, tempDir string) error { + zr, err := zip.OpenReader(zipPath) + if err != nil { + return fmt.Errorf("打开更新包失败: %w", err) + } + defer zr.Close() + + exeBase := filepath.Base(exePath) + var found *zip.File + for _, f := range zr.File { + name := filepath.Base(f.Name) + if strings.EqualFold(name, exeBase) || strings.EqualFold(name, "npc-gui") || strings.EqualFold(name, "npc-gui.exe") { + found = f + break + } + } + if found == nil { + return fmt.Errorf("更新包中未找到可执行文件 %s", exeBase) + } + + rc, err := found.Open() + if err != nil { + return err + } + defer rc.Close() + + newBin := filepath.Join(tempDir, "npc-gui"+guiExeExt()) + out, err := os.Create(newBin) + if err != nil { + return err + } + if _, err := io.Copy(out, rc); err != nil { + out.Close() + return err + } + out.Close() + chmodExecutable(newBin, 0o755) + + return replaceExecutableFile(newBin, exePath) +} + +func guiExeExt() string { + if runtime.GOOS == "windows" { + return ".exe" + } + return "" +} + +// replaceExecutableFile 用新文件替换正在运行的可执行文件。 +// Windows 下运行中的 exe 不能直接覆盖,先改名备份再替换。 +func replaceExecutableFile(srcBin, destBin string) error { + if srcFi, err := os.Stat(srcBin); err == nil { + if dstFi, err := os.Stat(destBin); err == nil { + if os.SameFile(srcFi, dstFi) { + return nil + } + } + } + if err := os.MkdirAll(filepath.Dir(destBin), 0o755); err != nil { + return err + } + + // 将当前程序改名为 .old 备份(Windows 上运行中的文件允许改名) + if _, err := os.Stat(destBin); err == nil { + bak := destBin + ".old" + _ = os.Remove(bak) + if err := os.Rename(destBin, bak); err != nil { + return fmt.Errorf("无法备份当前程序 %s: %w", destBin, err) + } + } + + // 同文件系统 rename 原子替换;跨卷回退为拷贝 + if err := os.Rename(srcBin, destBin); err != nil { + if _, copyErr := copyFileForUpdate(srcBin, destBin); copyErr != nil { + // 尽力恢复旧程序 + bak := destBin + ".old" + if _, statErr := os.Stat(bak); statErr == nil { + _ = os.Rename(bak, destBin) + } + return fmt.Errorf("替换可执行文件失败: %w", copyErr) + } + _ = os.Remove(srcBin) + } + return nil +} + +func copyFileForUpdate(src, dest string) (int64, error) { + srcF, err := os.Open(src) + if err != nil { + return 0, err + } + defer srcF.Close() + dstF, err := os.Create(dest) + if err != nil { + return 0, err + } + defer dstF.Close() + return io.Copy(dstF, srcF) +} + +func chmodExecutable(path string, mode os.FileMode) { + if runtime.GOOS != "windows" { + _ = os.Chmod(path, mode) + } +} diff --git a/cmd/npc/npc-gui/wails.json b/cmd/npc/npc-gui/wails.json deleted file mode 100644 index 6d90a21..0000000 --- a/cmd/npc/npc-gui/wails.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "NPS 客户端", - "outputtype": "desktop", - "frontend": { - "dir": "frontend", - "packageManager": "yarn", - "install": "yarn install", - "build": "yarn run build", - "dev": "yarn run dev", - "dev:serverUrl": "http://localhost:34115" - }, - "author": { - "name": "NPS" - }, - "info": { - "productName": "NPS Client", - "productVersion": "0.26.38", - "companyName": "NPS", - "copyright": "Copyright © 2026 NPS" - }, - "build": { - "nsis": { - "oneShotInstaller": true, - "allowToChangeInstallationDirectory": true, - "icon": "build/windows/icon.ico" - }, - "windows": { - "icon": "build/windows/icon.ico" - }, - "buildTags": "npcgui" - } -} \ No newline at end of file diff --git a/conf/clients.json b/conf/clients.json index e69de29..9c1dd63 100644 --- a/conf/clients.json +++ b/conf/clients.json @@ -0,0 +1,3 @@ +{"Cnf":{"U":"","P":"","Compress":false,"Crypt":false},"Id":2,"VerifyKey":"e9cba3f8a9","Addr":"127.0.0.1","LocalAddr":"172.16.10.6","Remark":"测试2","Status":true,"IsConnect":false,"RateLimit":0,"Flow":{"ExportFlow":1446223,"InletFlow":1446223,"FlowLimit":0},"Rate":{"NowRate":0},"NoStore":false,"NoDisplay":false,"MaxConn":0,"NowConn":0,"WebUserName":"","WebPassword":"","ConfigConnAllow":true,"MaxTunnelNum":0,"Version":"0.26.38","BlackIpList":[],"CreateTime":"2026-08-24 11:20:39","LastOnlineTime":"2026-08-24 17:48:47","IpWhite":false,"IpWhitePass":"","IpWhiteList":[],"ExpireTime":""} +*#*{"Cnf":{"U":"","P":"","Compress":false,"Crypt":false},"Id":4,"VerifyKey":"b6873d7af1","Addr":"127.0.0.1","LocalAddr":"172.16.10.6","Remark":"测试1","Status":true,"IsConnect":false,"RateLimit":0,"Flow":{"ExportFlow":0,"InletFlow":0,"FlowLimit":0},"Rate":{"NowRate":0},"NoStore":false,"NoDisplay":false,"MaxConn":0,"NowConn":0,"WebUserName":"","WebPassword":"","ConfigConnAllow":true,"MaxTunnelNum":0,"Version":"0.26.38","BlackIpList":[],"CreateTime":"2026-08-24 13:40:26","LastOnlineTime":"2026-08-24 17:48:47","IpWhite":false,"IpWhitePass":"","IpWhiteList":[],"ExpireTime":""} +*#* \ No newline at end of file diff --git a/conf/hosts.json b/conf/hosts.json index e69de29..14dc77b 100644 --- a/conf/hosts.json +++ b/conf/hosts.json @@ -0,0 +1,2 @@ +{"Id":1,"Host":"wmstest22.hn1.pp2pdf.com","HeaderChange":"","HostChange":"","Location":"/","Remark":"","Scheme":"https","CertFilePath":"","KeyFilePath":"","NoStore":false,"IsClose":false,"AutoHttps":false,"Flow":{"ExportFlow":1446223,"InletFlow":1446223,"FlowLimit":0},"Client":{"Cnf":{"U":"","P":"","Compress":false,"Crypt":false},"Id":2,"VerifyKey":"e9cba3f8a9","Addr":"127.0.0.1","LocalAddr":"172.16.10.6","Remark":"测试2","Status":true,"IsConnect":false,"RateLimit":0,"Flow":{"ExportFlow":1446223,"InletFlow":1446223,"FlowLimit":0},"Rate":{"NowRate":0},"NoStore":false,"NoDisplay":false,"MaxConn":0,"NowConn":0,"WebUserName":"","WebPassword":"","ConfigConnAllow":true,"MaxTunnelNum":0,"Version":"0.26.38","BlackIpList":[],"CreateTime":"2026-08-24 11:20:39","LastOnlineTime":"2026-08-24 17:48:47","IpWhite":false,"IpWhitePass":"","IpWhiteList":[],"ExpireTime":""},"Target":{"TargetStr":"127.0.0.1:8443","TargetArr":["127.0.0.1:8443"],"LocalProxy":false}} +*#* \ No newline at end of file diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 8c08b32..6984e1d 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -1,5 +1,8 @@ # 更新日志 - 2026-08-24 v0.26.38 + - 新增: + - GUI 客户端(npc-gui)迁移到 Wails v3 + - GUI 客户端新增版本自动更新:启动时自动检查 GitHub 最新 release,支持一键下载并热替换当前可执行文件后自动重启 - 修复: - 客户端内网地址为 192.169.x.x 等非标准私网段时,Web 面板客户端列表不显示本机 IP [#348](https://github.com/yisier/nps/issues/348)