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:
5
electron/electron-env.d.ts
vendored
5
electron/electron-env.d.ts
vendored
@@ -29,4 +29,9 @@ declare interface Window {
|
||||
encrypt(plaintext: string): Promise<string | null>;
|
||||
decrypt(encryptedBase64: string): Promise<string | null>;
|
||||
};
|
||||
/** 应用运行时 API */
|
||||
appRuntime: {
|
||||
/** 登录/登出后更新窗口标题中的版控后缀 */
|
||||
setWindowEdition(edition: string | null): void;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,15 +5,15 @@ import path from 'node:path';
|
||||
|
||||
import {getPlatform, isMacOS} from './main/utils/platform';
|
||||
import {getWindowIconPath} from './main/utils/logo';
|
||||
import {buildWindowTitle, parseEdition} from '../shared/constants/app';
|
||||
import {buildWindowTitle} from '../shared/constants/app';
|
||||
import {loadEnvFile} from './main/load-env';
|
||||
import {initUpdater, registerUpdateIpcHandlers} from './main/updater';
|
||||
import {setupAppMenu} from './main/menu';
|
||||
import {initLogger, flushLogger, logger} from './main/logger';
|
||||
import {registerLogIpcHandlers} from './main/log-ipc';
|
||||
import {registerSafeStorageIpcHandlers} from './main/safe-storage-ipc';
|
||||
import {registerStorageIpcHandlers} from './main/storage-ipc';
|
||||
import {BIDIRECTIONAL} from '../shared/constants/ipc-channels';
|
||||
import {registerLogIpcHandlers} from './main/ipc/log-ipc';
|
||||
import {registerSafeStorageIpcHandlers} from './main/ipc/safe-storage-ipc';
|
||||
import {registerStorageIpcHandlers} from './main/ipc/storage-ipc';
|
||||
import {BIDIRECTIONAL, RENDERER_TO_MAIN} from '../shared/constants/ipc-channels';
|
||||
|
||||
createRequire(import.meta.url);
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
@@ -34,8 +34,8 @@ process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL
|
||||
|
||||
// ---------- 平台 & 版本信息 ----------
|
||||
const currentPlatform = getPlatform();
|
||||
const currentEdition = parseEdition(process.env.EDITION);
|
||||
const WINDOW_TITLE = buildWindowTitle(currentPlatform, currentEdition);
|
||||
/** 基础标题(无版控后缀),登录后通过 IPC 追加 */
|
||||
const WINDOW_TITLE = buildWindowTitle(currentPlatform);
|
||||
|
||||
// ============================================================
|
||||
// 全局未捕获异常(主进程兜底记录)
|
||||
@@ -174,6 +174,15 @@ app.whenReady().then(() => {
|
||||
});
|
||||
});
|
||||
|
||||
// 窗口标题版控后缀(渲染进程登录/登出后调用)
|
||||
ipcMain.on(RENDERER_TO_MAIN.SET_WINDOW_TITLE, (_event, edition: string | null) => {
|
||||
if (!mainWindow) return;
|
||||
const title = edition
|
||||
? buildWindowTitle(currentPlatform, undefined, edition as 'personal' | 'enterprise')
|
||||
: buildWindowTitle(currentPlatform);
|
||||
mainWindow.setTitle(title);
|
||||
});
|
||||
|
||||
// 始终打开主窗口
|
||||
// 登录/注册由渲染进程内的 Modal 弹层处理,不再新开窗口
|
||||
const win = createMainWindow();
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// ============================================================
|
||||
|
||||
import { ipcMain } from 'electron';
|
||||
import { RENDERER_TO_MAIN } from '../../shared/constants/ipc-channels';
|
||||
import { writeRendererLog } from './logger';
|
||||
import type { LogEntry } from '../../shared/types/logging';
|
||||
import { RENDERER_TO_MAIN } from '../../../shared/constants/ipc-channels';
|
||||
import { writeRendererLog } from '../logger';
|
||||
import type { LogEntry } from '../../../shared/types/logging';
|
||||
|
||||
/**
|
||||
* 注册日志 IPC 监听器
|
||||
@@ -16,8 +16,8 @@
|
||||
// ============================================================
|
||||
|
||||
import { ipcMain, safeStorage } from 'electron';
|
||||
import { BIDIRECTIONAL } from '../../shared/constants/ipc-channels';
|
||||
import { logger } from './logger';
|
||||
import { BIDIRECTIONAL } from '../../../shared/constants/ipc-channels';
|
||||
import { logger } from '../logger';
|
||||
|
||||
/** 检查 safeStorage 是否可用,不可用时记录警告 */
|
||||
function checkAvailability(): boolean {
|
||||
@@ -16,8 +16,8 @@
|
||||
import { ipcMain, shell, app } from 'electron';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { BIDIRECTIONAL } from '../../shared/constants/ipc-channels';
|
||||
import { logger } from './logger';
|
||||
import { BIDIRECTIONAL } from '../../../shared/constants/ipc-channels';
|
||||
import { logger } from '../logger';
|
||||
|
||||
// ---------- 内部工具 ----------
|
||||
|
||||
@@ -77,7 +77,6 @@ class HeiXiuProvider extends Provider<UpdateInfo> {
|
||||
params: {
|
||||
platform: process.platform,
|
||||
version: APP_VERSION,
|
||||
edition: process.env.EDITION || 'personal',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ipcRenderer, contextBridge } from 'electron';
|
||||
import { BIDIRECTIONAL } from '../shared/constants/ipc-channels';
|
||||
import { BIDIRECTIONAL, RENDERER_TO_MAIN } from '../shared/constants/ipc-channels';
|
||||
|
||||
// --------- Expose some API to the Renderer process ---------
|
||||
contextBridge.exposeInMainWorld('ipcRenderer', {
|
||||
@@ -87,3 +87,14 @@ contextBridge.exposeInMainWorld('fileStorage', {
|
||||
.then((r: { success: boolean; data: boolean }) => r?.success ? r.data : false);
|
||||
},
|
||||
});
|
||||
|
||||
// --------- 应用运行时 API ---------
|
||||
contextBridge.exposeInMainWorld('appRuntime', {
|
||||
/**
|
||||
* 登录/登出后更新窗口标题中的版控后缀
|
||||
* @param edition - 'personal' | 'enterprise' | null(null 清除后缀)
|
||||
*/
|
||||
setWindowEdition(edition: string | null): void {
|
||||
ipcRenderer.send(RENDERER_TO_MAIN.SET_WINDOW_TITLE, edition);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user