feat: 去除构建时版控变量 + 窗口标题动态版控 + 退出登录保留缓存 (0.0.24)
版控体系重构(13 文件):
- 移除 build.mjs --personal/--enterprise 参数和 EDITION 环境变量
- 统一安装包文件名:船长-HeiXiu-{os}-{版本号}-Setup.{ext}
- 简化 package.json 构建脚本,移除 :enterprise 变体
- scripts/*.mjs 不再接受 edition 参数
- 移除 shared/constants/app.ts 的 parseEdition()
窗口标题动态版控:
- 新格式:船长-HeiXiu-{os}-{版本号}(登录前)/ ·{版控} 后缀(登录后)
- 链路:AppProvider(account_type) → useEffect → appRuntime IPC → main process
- 移除 updater.ts 更新检查 API 的 edition 查询参数
本地存储生命周期修正:
- 退出登录不再自动清空缓存(user_id 隔离,重新登录命中缓存)
- clearUserStorage 添加 isOpen() 竞态守卫
- 移除 closeDatabase() 避免退出→重新登录后数据库不可用
- 手动「清理缓存」按钮保留
文档:
- CHANGELOG.md 新增 0.0.24 条目
- TODO.md 新增已完成项
This commit is contained in:
60
build.mjs
60
build.mjs
@@ -8,10 +8,6 @@
|
||||
// --mac macOS
|
||||
// --linux Linux
|
||||
//
|
||||
// 版本(可选,默认 personal):
|
||||
// --personal 个人版
|
||||
// --enterprise 企业版
|
||||
//
|
||||
// 操作(可选组合,默认只执行 --build):
|
||||
// --build 仅构建(默认)
|
||||
// --clean 构建前清理 release/ dist/ dist-electron/
|
||||
@@ -25,10 +21,10 @@
|
||||
// --cert-password <p> 证书密码
|
||||
//
|
||||
// 示例:
|
||||
// node build.mjs --win --personal # 仅打包
|
||||
// node build.mjs --win --personal --upload --publish # 打包 + 上传 + 发布
|
||||
// node build.mjs --win --enterprise --all # 全流程
|
||||
// node build.mjs --win --personal --sign --cert ./cert.pfx --cert-password xxx
|
||||
// node build.mjs --win # 仅打包
|
||||
// node build.mjs --win --upload --publish # 打包 + 上传 + 发布
|
||||
// node build.mjs --win --all # 全流程
|
||||
// node build.mjs --win --sign --cert ./cert.pfx --cert-password xxx
|
||||
// ============================================================
|
||||
|
||||
import { spawn } from 'node:child_process';
|
||||
@@ -55,8 +51,6 @@ const opts = {
|
||||
win: false,
|
||||
mac: false,
|
||||
linux: false,
|
||||
personal: false,
|
||||
enterprise: false,
|
||||
clean: false,
|
||||
build: false,
|
||||
sign: false,
|
||||
@@ -73,8 +67,6 @@ while (i < args.length) {
|
||||
case '--win': opts.win = true; break;
|
||||
case '--mac': opts.mac = true; break;
|
||||
case '--linux': opts.linux = true; break;
|
||||
case '--personal': opts.personal = true; break;
|
||||
case '--enterprise': opts.enterprise = true; break;
|
||||
case '--clean': opts.clean = true; break;
|
||||
case '--build': opts.build = true; break;
|
||||
case '--sign': opts.sign = true; break;
|
||||
@@ -109,21 +101,12 @@ if (platformCount !== 1) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const editionCount = [opts.personal, opts.enterprise].filter(Boolean).length;
|
||||
if (editionCount === 0) {
|
||||
opts.personal = true; // 默认个人版
|
||||
} else if (editionCount > 1) {
|
||||
console.error('错误: --personal 和 --enterprise 不能同时使用');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 默认执行 build
|
||||
if (!opts.clean && !opts.build && !opts.sign && !opts.upload && !opts.publish) {
|
||||
opts.build = true;
|
||||
}
|
||||
|
||||
const platform = opts.win ? 'win32' : opts.mac ? 'darwin' : 'linux';
|
||||
const edition = opts.personal ? 'personal' : 'enterprise';
|
||||
|
||||
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
|
||||
const version = pkg.version;
|
||||
@@ -162,10 +145,9 @@ function step(title) {
|
||||
|
||||
async function main() {
|
||||
const electronBuilderPlatform = opts.win ? '--win' : opts.mac ? '--mac' : '--linux';
|
||||
const editionEnv = { EDITION: edition };
|
||||
|
||||
console.log('┌──────────────────────────────────────┐');
|
||||
console.log(`│ HeiXiu 构建 v${version} ${platform}/${edition}`.padEnd(45) + '│');
|
||||
console.log(`│ HeiXiu 构建 v${version} ${platform}`.padEnd(45) + '│');
|
||||
console.log('└──────────────────────────────────────┘');
|
||||
console.log(`操作: ${[
|
||||
opts.clean && '清理',
|
||||
@@ -195,33 +177,33 @@ async function main() {
|
||||
|
||||
// 2a. TypeScript 编译
|
||||
console.log('[tsc] 类型检查...');
|
||||
await run('npx', ['tsc'], { env: editionEnv });
|
||||
await run('npx', ['tsc']);
|
||||
|
||||
// 2b. Vite 构建
|
||||
console.log('[vite] 打包前端 + Electron...');
|
||||
await run('npx', ['vite', 'build'], { env: editionEnv });
|
||||
await run('npx', ['vite', 'build']);
|
||||
|
||||
// 2c. electron-builder 打包
|
||||
console.log(`[electron-builder] ${electronBuilderPlatform} 打包...`);
|
||||
await run('npx', ['electron-builder', electronBuilderPlatform], {
|
||||
env: { ...editionEnv, ...signEnv },
|
||||
env: { ...signEnv },
|
||||
});
|
||||
|
||||
// 2d. 生成 update-info.json
|
||||
console.log('[info] 生成 update-info.json...');
|
||||
await runScript('generate-update-info', platform, edition, version);
|
||||
await runScript('generate-update-info', platform, version);
|
||||
}
|
||||
|
||||
// ── Step 3: 上传 OSS ──
|
||||
if (opts.upload) {
|
||||
step('3/ 上传 OSS');
|
||||
await runScript('upload-oss', platform, edition, version);
|
||||
await runScript('upload-oss', platform, version);
|
||||
}
|
||||
|
||||
// ── Step 4: 发布到 API ──
|
||||
if (opts.publish) {
|
||||
step('4/ 发布版本到 API');
|
||||
await runScript('publish-release', platform, edition, version);
|
||||
await runScript('publish-release', platform, version);
|
||||
}
|
||||
|
||||
console.log('\n✅ 全部完成');
|
||||
@@ -256,11 +238,6 @@ function printHelp() {
|
||||
row('--mac', 'macOS');
|
||||
row('--linux', 'Linux');
|
||||
|
||||
// 版本
|
||||
hdr('版本(可选,默认 --personal)');
|
||||
row('--personal', '个人版');
|
||||
row('--enterprise', '企业版');
|
||||
|
||||
// 操作
|
||||
hdr('操作(可选组合,不指定则默认 --build)');
|
||||
row('--build', '构建应用(tsc + vite + electron-builder + info)');
|
||||
@@ -278,15 +255,15 @@ function printHelp() {
|
||||
|
||||
// 示例
|
||||
box('示例');
|
||||
console.log(` ${dim('# 日常开发')}`);
|
||||
console.log(` ${bold('node build.mjs --win --personal')}`);
|
||||
console.log(` ${dim('# 日常构建')}`);
|
||||
console.log(` ${bold('node build.mjs --win')}`);
|
||||
console.log(` ${bold('npm run build:win')} ${dim('— 等效')}`);
|
||||
console.log('');
|
||||
console.log(` ${dim('# 打包 + 上传 OSS + 发布到 API')}`);
|
||||
console.log(` ${bold('node build.mjs --win --personal --upload --publish')}`);
|
||||
console.log(` ${bold('node build.mjs --win --upload --publish')}`);
|
||||
console.log('');
|
||||
console.log(` ${dim('# 全流程(清理 → 构建 → 签名 → 上传 → 发布)')}`);
|
||||
console.log(` ${bold('node build.mjs --win --enterprise --all --cert ./cert.pfx --cert-password xxx')}`);
|
||||
console.log(` ${bold('node build.mjs --win --all --cert ./cert.pfx --cert-password xxx')}`);
|
||||
console.log('');
|
||||
console.log(` ${dim('# 仅清理')}`);
|
||||
console.log(` ${bold('npm run build:clean')}`);
|
||||
@@ -305,10 +282,9 @@ function printHelp() {
|
||||
|
||||
// 快捷命令
|
||||
box('npm 快捷命令');
|
||||
console.log(` ${bold('npm run build:win')} ${dim('→ node build.mjs --win --personal --build')}`);
|
||||
console.log(` ${bold('npm run build:win:enterprise')} ${dim('→ node build.mjs --win --enterprise --build')}`);
|
||||
console.log(` ${bold('npm run build:mac')} ${dim('→ node build.mjs --mac --personal --build')}`);
|
||||
console.log(` ${bold('npm run build:linux')} ${dim('→ node build.mjs --linux --personal --build')}`);
|
||||
console.log(` ${bold('npm run build:win')} ${dim('→ node build.mjs --win --build')}`);
|
||||
console.log(` ${bold('npm run build:mac')} ${dim('→ node build.mjs --mac --build')}`);
|
||||
console.log(` ${bold('npm run build:linux')} ${dim('→ node build.mjs --linux --build')}`);
|
||||
console.log(` ${bold('npm run build:clean')} ${dim('→ node scripts/clean.mjs')}`);
|
||||
console.log(` ${bold('npm run upload:oss')} ${dim('→ node scripts/upload-oss.mjs')}`);
|
||||
console.log(` ${bold('npm run publish:release')} ${dim('→ node scripts/publish-release.mjs')}`);
|
||||
|
||||
Reference in New Issue
Block a user