Files
ele-HeiXiu/shared/constants/app.ts
YoungestSongMo 8b697e775d 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 新增已完成项
2026-06-22 13:36:42 +08:00

59 lines
2.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ============================================================
// 应用常量 —— 版本号、版本类型、窗口标题
// 主进程 & 渲染进程共享
// ============================================================
import type { Edition, Platform } from '../types';
import { APP_VERSION } from './version';
/** 应用显示名称(文件/标题通用前缀) */
export const APP_NAME = '船长-HeiXiu';
// APP_VERSION 从 ./version.ts 导入(读取 package.json不再硬编码
// ============================================================
// 版本类型(企业版 / 个人版)
//
// 注意edition 由后端 account_type 运行时决定,不由构建变量控制。
// 不再需要 parseEdition() —— 构建时 EDITION 环境变量已移除。
// ============================================================
/** 版本中文名称 */
export function getEditionName(edition: Edition): string {
return edition === 'enterprise' ? '企业版' : '个人版';
}
// ============================================================
// 窗口标题构建
// ============================================================
/** 平台中文名称(简写) */
function platformShortName(platform: Platform): string {
if (platform === 'darwin') return 'MAC';
if (platform === 'win32') return 'Windows';
return 'Linux';
}
/**
* 构建窗口标题
*
* 格式(无版控):船长-HeiXiu-{平台}-{版本号}
* 示例:船长-HeiXiu-Windows-0.0.23
*
* 格式(含版控):船长-HeiXiu-{平台}-{版本号}·{版控}
* 示例:船长-HeiXiu-Windows-0.0.23·企业版
*
* @param platform - 当前操作系统平台
* @param version - 可选覆盖版本号(默认 APP_VERSION
* @param edition - 可选版本类型(登录后追加,未登录不显示)
*/
export function buildWindowTitle(platform: Platform, version?: string, edition?: Edition): string {
const ver = version ?? APP_VERSION;
const os = platformShortName(platform);
const base = `${APP_NAME}-${os}-${ver}`;
if (edition) {
return `${base}·${getEditionName(edition)}`;
}
return base;
}