feat(desktop-client): 阶段4-6 Electron EXE 客户端(登录/课表/作业/通知/成绩/设置 + Socket.IO 实时 + IndexedDB 离线缓存与自动同步 + electron-builder 打包)

This commit is contained in:
LoveChengke committed 2026-09-11 22:46:31 +08:00
1 parent 4566d7cd5e
commit 6e4c7c1050
42 files changed
+5767 -60

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
/**
* Electron 冒烟验证:以 ELECTRON_SMOKE_TEST=1 启动应用(不弹窗),
* 主进程会依次校验 preload 桥接、渲染进程挂载、登录页 DOM、
* IPC 往返、IndexedDB 缓存读写、断网回退缓存,然后自动退出。
*
* 前置条件:已执行 npm run build(需要 dist/main 与 dist/renderer)。
*/
import { spawn } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import electronPath from 'electron';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const required = [path.join(root, 'dist/main/index.js'), path.join(root, 'dist/renderer/index.html')];
const missing = required.filter((file) => !fs.existsSync(file));
if (missing.length > 0) {
console.error('[smoke] 缺少构建产物,请先执行构建:');
console.error(' pnpm --filter @classhelper/desktop-client build');
for (const file of missing) console.error(` 缺失: ${path.relative(root, file)}`);
process.exit(2);
}
console.log('[smoke] 启动 Electron 冒烟验证...\n');
const child = spawn(electronPath, ['.'], {
cwd: root,
stdio: 'inherit',
env: { ...process.env, ELECTRON_SMOKE_TEST: '1' },
});
child.on('exit', (code) => {
console.log(`\n[smoke] Electron 退出,code=${code ?? 1}`);
process.exit(code ?? 1);
});