Skip to content

feat: 添加 Electron 自动构建工作流与更新通知功能#564

Merged
phantom5099 merged 7 commits into1024XEngineer:mainfrom
Yumiue:html_gui_build
May 6, 2026
Merged

feat: 添加 Electron 自动构建工作流与更新通知功能#564
phantom5099 merged 7 commits into1024XEngineer:mainfrom
Yumiue:html_gui_build

Conversation

@Yumiue
Copy link
Copy Markdown
Collaborator

@Yumiue Yumiue commented May 6, 2026

变更概述

本 PR 为 NeoCode 添加了 Electron 应用的自动化构建工作流,并实现了应用内更新通知功能。

主要变更

1. 自动构建工作流

  • 新增 .github/workflows/release-electron.yml GitHub Actions 工作流
  • 配置 Electron 应用的自动化打包和发布流程
  • 支持多平台构建(Windows/macOS/Linux)

2. Web 资源嵌入支持

  • 新增 internal/webassets/assets_embed.goassets_noembed.go
  • 新增 web/dist_embed.godist_noembed.go
  • 支持静态资源的嵌入与非嵌入两种模式

3. Electron 应用增强

  • 修改 web/electron/main.ts:增强主进程功能
  • 新增 web/electron/preload.ts:添加预加载脚本
  • 修改 web/electron-builder.config.cjs:更新构建配置
  • 新增 web/src/components/UpdateNotification.tsx:实现更新通知 UI 组件
  • 更新 web/src/types/electron.d.ts:补充 TypeScript 类型定义

4. 网关与 CLI 改进

  • 优化 internal/cli/gateway_commands.go:改进网关命令处理
  • 优化 internal/cli/web_command.go:改进 Web 命令处理
  • 修改 internal/gateway/network_server.go:增强网络服务器功能
  • 修改 internal/gateway/static_files.go:改进静态文件服务

5. 构建脚本更新

  • 修改 web/scripts/build-gateway.js:优化网关构建流程
  • 更新 web/package.jsonweb/package-lock.json:依赖版本更新

统计

  • 18 个文件变更
  • 535 行新增
  • 44 行删除

测试建议

  • 验证 GitHub Actions 工作流是否正常触发
  • 测试 Electron 应用打包是否成功
  • 验证更新通知功能是否正常工作
  • 测试网关和 Web 命令是否正常

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 2 issues worth addressing before this lands.

Comment thread web/package.json Outdated
"dev:electron": "node scripts/clean-electron.js && node scripts/build-gateway.js && vite --mode electron",
"build": "tsc -b && vite build",
"build:electron": "node scripts/clean-electron.js && node scripts/build-gateway.js && vite build --mode electron && node scripts/verify-electron-preload.js && electron-builder",
"build:electron": "node scripts/clean-electron.js && node scripts/build-gateway.js && vite build --mode electron && node scripts/verify-electron-preload.js && electron-builder --config electron-builder.config.cjs",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: build:electron now builds neocode-gateway before running vite build --mode electron, but scripts/build-gateway.js compiles the gateway with -tags webembed. That means the packaged binary embeds whatever happens to already be in web/dist (or nothing, if dist/ is absent) instead of the renderer output produced later in this script. Any frontend changes in the same release can therefore be missing from the shipped Electron app. Build the renderer before the gateway, or rebuild the gateway after Vite finishes.

arch: ['x64'],
},
{
target: 'portable',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: this adds a Windows portable artifact while web/electron/main.ts enables electron-updater for every production build. Portable builds are not supported by the standard NSIS/GitHub self-update flow, so that package will still check/download updates and show a restart prompt even though it cannot install them correctly. Either stop publishing the portable target on the auto-update channel or gate the updater off when running as a portable build.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Yumiue and others added 2 commits May 6, 2026 15:40
- 调整 build:electron 脚本顺序:先 vite build 生成 dist 产物,再编译网关,
  保证 webembed 嵌入的是最新前端资源
- 在 setupAutoUpdater() 中检测 PORTABLE_EXECUTABLE_DIR,portable 模式下
  跳过自动更新检查,避免 NSIS 不支持的更新流程误导用户

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@phantom5099 phantom5099 merged commit 622abaf into 1024XEngineer:main May 6, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants