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:
2026-06-22 13:36:42 +08:00
parent e4d66a2ac0
commit 8b697e775d
95 changed files with 1158 additions and 1295 deletions

View File

@@ -2,14 +2,14 @@
// 打包后自动生成 update-info.json
//
// 用法:
// node scripts/generate-update-info.mjs <platform> <edition> [version] [--url <url>]
// node scripts/generate-update-info.mjs <platform> [version] [--url <url>]
//
// 两种用法:
// 方式 A预判 URL打包后自动拼接 URL → 适用于 OSS 路径可预测时
// node scripts/generate-update-info.mjs win32 personal
// node scripts/generate-update-info.mjs win32
//
// 方式 B指定 URL上传后用实际 URL 重新生成 → 适用于上传后才知道 URL 时
// node scripts/generate-update-info.mjs win32 personal 0.1.0 --url "https://oss.../xxx.exe"
// node scripts/generate-update-info.mjs win32 0.1.0 --url "https://oss.../xxx.exe"
//
// 环境变量(可选):
// UPDATE_DOWNLOAD_BASE — 方式 A 的 URL 基地址,默认 https://heixiu.oss-cn-hangzhou.aliyuncs.com/releases
@@ -45,17 +45,16 @@ for (let i = 0; i < args.length; i++) {
}
const platform = positional[0];
const edition = positional[1];
if (!platform || !edition) {
console.error('用法: node scripts/generate-update-info.mjs <platform> <edition> [version] [--url <url>]');
console.error('示例: node scripts/generate-update-info.mjs win32 personal');
console.error(' node scripts/generate-update-info.mjs win32 personal 0.1.0 --url "https://..."');
if (!platform) {
console.error('用法: node scripts/generate-update-info.mjs <platform> [version] [--url <url>]');
console.error('示例: node scripts/generate-update-info.mjs win32');
console.error(' node scripts/generate-update-info.mjs win32 0.1.0 --url "https://..."');
process.exit(1);
}
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
const version = positional[2] || pkg.version;
const version = positional[1] || pkg.version;
const productName = pkg.build?.productName || '船长·HeiXiu';
// ---------- 查找安装包 ----------
@@ -190,7 +189,6 @@ const updateInfo = {
// --- 附加:方便后端录入 ---
_meta: {
platform,
edition,
fileName,
blockmap: blockMapUrl ? { url: blockMapUrl, size: blockMapSize } : null,
generatedAt: new Date().toISOString(),
@@ -199,7 +197,7 @@ const updateInfo = {
const outputPath = join(
releaseDir,
`${productName}-${platform}-${edition}-v${version}-update-info.json`,
`${productName}-${platform}-v${version}-update-info.json`,
);
writeFileSync(outputPath, JSON.stringify(updateInfo, null, 2), 'utf-8');

View File

@@ -2,7 +2,7 @@
// 发布版本信息到后端 API
//
// 用法:
// node scripts/publish-release.mjs <platform> <edition> [version] [--url <url>]
// node scripts/publish-release.mjs <platform> [version] [--url <url>]
//
// 环境变量:
// UPDATE_API_URL — API 基地址(默认 https://www.heixiu.com
@@ -35,16 +35,15 @@ for (let i = 0; i < args.length; i++) {
}
const platform = positional[0];
const edition = positional[1];
if (!platform || !edition) {
console.error('用法: node scripts/publish-release.mjs <platform> <edition> [version] [--url <url>]');
console.error('示例: node scripts/publish-release.mjs win32 personal 0.1.0');
if (!platform) {
console.error('用法: node scripts/publish-release.mjs <platform> [version] [--url <url>]');
console.error('示例: node scripts/publish-release.mjs win32 0.1.0');
process.exit(1);
}
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
const version = positional[2] || pkg.version;
const version = positional[1] || pkg.version;
// ---------- 读取 update-info.json ----------
@@ -63,9 +62,9 @@ if (jsonOverride) {
try {
const all = readdirSync(releaseDir);
infoFile = all.find((f) =>
f.includes(platform) && f.includes(edition) && f.endsWith('-update-info.json'),
f.includes(platform) && f.endsWith('-update-info.json'),
);
if (!infoFile) console.error(`未找到 ${platform}+${edition} 的 update-info.json`);
if (!infoFile) console.error(`未找到 ${platform} 的 update-info.json`);
} catch (err) {
console.error(`错误: ${releaseDir}${err.message}`);
process.exit(1);
@@ -81,7 +80,6 @@ const apiKey = process.env.UPDATE_API_KEY || '';
const payload = {
platform,
edition,
latestVersion: updateInfo.latestVersion || version,
downloadUrl: updateInfo.downloadUrl,
fileSize: updateInfo.fileSize,
@@ -98,7 +96,7 @@ console.log('━━━━━━━━━━━━━━━━━━━━━━
console.log('📡 发布版本到 API');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log(`POST ${endpoint}`);
console.log(`版本: ${version} (${platform}/${edition})`);
console.log(`版本: ${version} (${platform})`);
console.log(`URL: ${payload.downloadUrl}\n`);
try {

View File

@@ -2,7 +2,7 @@
// 上传安装包 + blockmap 文件到阿里云 OSS
//
// 用法:
// node scripts/upload-oss.mjs <platform> <edition> [version]
// node scripts/upload-oss.mjs <platform> [version]
//
// 环境变量(使用 Node.js 直传时需要):
// OSS_ENDPOINT — OSS endpoint如 oss-cn-hangzhou.aliyuncs.com
@@ -15,12 +15,12 @@
//
// 示例:
// # 仅打印上传命令
// node scripts/upload-oss.mjs win32 personal 0.1.0
// node scripts/upload-oss.mjs win32 0.1.0
//
// # 直接上传
// OSS_BUCKET=heixiu OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com \
// OSS_ACCESS_KEY_ID=xxx OSS_ACCESS_KEY_SECRET=xxx \
// node scripts/upload-oss.mjs win32 personal 0.1.0
// node scripts/upload-oss.mjs win32 0.1.0
// ============================================================
import {readFileSync, readdirSync} from 'node:fs';
@@ -34,16 +34,15 @@ const ROOT = join(__dirname, '..');
// ---------- 参数 ----------
const platform = process.argv[2];
const edition = process.argv[3];
if (!platform || !edition) {
console.error('用法: node scripts/upload-oss.mjs <platform> <edition> [version]');
console.error('示例: node scripts/upload-oss.mjs win32 personal 0.1.0');
if (!platform) {
console.error('用法: node scripts/upload-oss.mjs <platform> [version]');
console.error('示例: node scripts/upload-oss.mjs win32 0.1.0');
process.exit(1);
}
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
const version = process.argv[4] || pkg.version;
const version = process.argv[3] || pkg.version;
// ---------- 查找安装包 ----------
@@ -132,15 +131,15 @@ if (!OSS_ENDPOINT || !OSS_BUCKET || !OSS_ACCESS_KEY_ID) {
console.log('上传后执行以下命令,用实际 URL 重新生成 info');
if (blockmapUrl) {
console.log(` node scripts/generate-update-info.mjs ${platform} ${edition} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
console.log(` node scripts/generate-update-info.mjs ${platform} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
console.log('');
console.log('或直接发布到后端 API');
console.log(` node scripts/publish-release.mjs ${platform} ${edition} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
console.log(` node scripts/publish-release.mjs ${platform} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
} else {
console.log(` node scripts/generate-update-info.mjs ${platform} ${edition} ${version} --url "${downloadUrl}"`);
console.log(` node scripts/generate-update-info.mjs ${platform} ${version} --url "${downloadUrl}"`);
console.log('');
console.log('或直接发布到后端 API');
console.log(` node scripts/publish-release.mjs ${platform} ${edition} ${version} --url "${downloadUrl}"`);
console.log(` node scripts/publish-release.mjs ${platform} ${version} --url "${downloadUrl}"`);
}
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
process.exit(0);
@@ -238,11 +237,11 @@ if (blockmapPath) {
// 后续步骤提示
console.log('\n接下来 — 重新生成 update-info.json');
if (blockmapUrl) {
console.log(` node scripts/generate-update-info.mjs ${platform} ${edition} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
console.log(` node scripts/generate-update-info.mjs ${platform} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
console.log('\n或直接发布到后端 API');
console.log(` node scripts/publish-release.mjs ${platform} ${edition} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
console.log(` node scripts/publish-release.mjs ${platform} ${version} --url "${downloadUrl}" --blockmap-url "${blockmapUrl}"`);
} else {
console.log(` node scripts/generate-update-info.mjs ${platform} ${edition} ${version} --url "${downloadUrl}"`);
console.log(` node scripts/generate-update-info.mjs ${platform} ${version} --url "${downloadUrl}"`);
console.log('\n或直接发布到后端 API');
console.log(` node scripts/publish-release.mjs ${platform} ${edition} ${version} --url "${downloadUrl}"`);
console.log(` node scripts/publish-release.mjs ${platform} ${version} --url "${downloadUrl}"`);
}