feat(server,web,desktop,shared,deploy,docs): Linux 一键安装与 classhelper 运维命令、更新检查、图表去 echarts,版本统一 1.1.0
Linux 交付链(新增)
- deploy/install.sh:一键安装器(CLASSHELPER 大字 TUI、native/docker 双形态、向导选安装目录/
端口/数据库/初始管理员密码);识别 apt/yum/dnf 只补缺的依赖、建独立系统用户、下载内置 Node
运行时(glibc < 2.28 的 CentOS 7 自动改用 unofficial-builds 的 glibc-217 构建)、幂等覆盖安装
(保留 config.env 与 data/,不重置密钥)、全程写 /var/log/classhelper/install.log;
`--check` 只体检(不需要 root)、`--yes` 无人值守、`--package` 支持内网离线分发。
- deploy/classhelper:运维命令 —— status / doctor / password / backup(list,restore,schedule) /
upgrade / rollback / start|stop|restart|reload / logs / config / port / key rotate / uninstall /
completion / help。特权操作一律校验 EUID,关键动作写 /var/log/classhelper/audit.log。
- deploy/tools/admin-cli.mjs:离线账号工具(改密、列账号、VACUUM INTO 一致性快照、哈希回滚),
直连数据库 —— 服务停机也能救急,不需要先有一个能登录的账号。
- deploy/{classhelper.service,profile.d,logrotate.d,systemd}/ 模板 + Dockerfile.linux-package。
- scripts/dist-server.mjs 增加 --platform linux(根脚本 `pnpm dist:server:linux`),产物
classhelper-server-linux-x64-<版本>.tar.gz + 同名 .sha256;新增 GitHub Actions workflow 在
ubuntu runner 上构建并挂 Release(@libsql/linux-* 这类平台相关依赖只能在 Linux 上装)。
- docs/linux-deploy.md:安装 / 运维命令 / 升级回滚 / 备份恢复 / 排障 / 安全清单 /
Ubuntu 22.04 与 Rocky 9 的验收清单。deploy/install-linux.sh 改为转发壳,不留两份实现。
三处必须知道的取舍(已写进 AGENTS.md §5 第 59 条)
- 配置真身在 /etc/classhelper/config.env,安装目录里的 .env 是指向它的软链:Web 端
「数据库管理 → 一键切换」改写的是 <安装目录>/.env,而 systemd 注入的是同一份配置 ——
两处不是同一个文件时,切换会「看起来成功、重启后又连回旧库」。classhelper doctor 有专门断言。
- 升级/回滚替换程序文件用「改名 + 就位」而不是 rm+cp:升级时正在运行的就是 bin/classhelper
自己,直接删掉同名文件会让 bash 读到半个脚本。
- 交叉构建(在非 Linux 机器上打 Linux 包)会在包内写 .cross-built 标记、doctor 据此提示:
已核对 @libsql/linux-x64-gnu 与 -musl 就位且无 win32 残留,但 prisma CLI 的原生 schema engine
是宿主平台的,Web 端「数据库一键切换」那一步存疑;正式产物一律走 CI。
更新检查(此前只在工作区,本次一并提交)
- 服务端 modules/update:由服务端转发 GitHub Releases(Web 端 CSP 不允许直连),离线/限流/超时
一律收敛成 ok:false + 一句人话,失败结果同样进缓存;?force=1 只对管理员生效(避免刷爆匿名限流)。
- 版本比较放 @classhelper/shared(compareVersions / isNewerVersion),三端共用;服务端版本号
改由 lib/version.ts 读 package.json,不再在 app.ts 里写字面量。
- Web 端顶栏「检查更新」弹窗、客户端「关于」页的检查更新与诊断信息。
Web 端 / 客户端
- 成绩图表改用自包含的轻量组件(ScoreBarChart / ScoreLineChart),不再全量引入 echarts
(原先 echarts 占桌面端渲染产物 1.12MB、Web 端 1.13MB);柱状图是纯 HTML/CSS,折线图是
viewBox SVG,均无 resize 监听。
- Element Plus 图标改为按需注册(两端各一份 icons.ts),新增 scripts/check-icons.mjs 静态门禁
并挂进两端 build —— 漏注册的后果是界面静默渲染空白,只在控制台一条 warning。
版本号统一 1.1.0
- 5 份 package.json、deploy/package.runtime.json、.env.example 的 APP_VERSION、
docker-compose 与两个 Dockerfile 的镜像标签、Linux 安装包名示例、README 首页版本;
- ClassIsland 插件 manifest.yml 与 BridgeService.PluginVersion 同步(verify:classisland-plugin
有 manifest ↔ code 的一致性断言);
- 刻意保持不变的是**历史性表述与举例**:docs/mysql.md 的「自 v1.0.0 起内置 MySQL 适配器」、
shared/utils.ts 讲版本比较用的 1.0.0 / 1.0.0-fix、README 验收表里的实测记录。
This commit is contained in:
1 parent
aad22df4fd
commit
9a38f86cd3
77 files changed
+8021
-899
No files matched your search
@@ -265,6 +265,72 @@ async function runAdminTeacherChecks(win) {
|
||||
Boolean(removed?.ok),
|
||||
`${removed?.ok ? `已删除 ${username}` : `原因=${removed?.reason ?? '-'}`}`,
|
||||
);
|
||||
|
||||
// 4) 更新检查:顶栏用户菜单 →「检查更新」→ 弹窗渲染出结果
|
||||
//
|
||||
// 只断言"入口可用 + 弹窗给出了结论",**刻意不断言一定有新版本** ——
|
||||
// 那会把用例绑死在外网可达上(机房服务器查不到 GitHub 是常态,"暂时无法检查更新"是设计内的结果)。
|
||||
// 判据用弹窗内的文案(与本脚本其余用例一致):data-test 打在 el-dialog / el-alert 上,
|
||||
// 是否透传到根元素取决于组件实现,不如文案直接。
|
||||
const updateCheck = await win.webContents.executeJavaScript(`(async () => {
|
||||
const chip = document.querySelector('[data-tour="user-chip"]');
|
||||
if (!chip) return { ok: false, reason: '顶栏找不到用户菜单' };
|
||||
chip.click();
|
||||
|
||||
const menuDeadline = Date.now() + 5000;
|
||||
let entry = null;
|
||||
while (Date.now() < menuDeadline && !entry) {
|
||||
entry = Array.from(document.querySelectorAll('.el-dropdown-menu__item')).find((node) =>
|
||||
(node.textContent ?? '').includes('检查更新'),
|
||||
);
|
||||
if (!entry) await new Promise((resolve) => setTimeout(resolve, 80));
|
||||
}
|
||||
if (!entry) return { ok: false, reason: '用户下拉菜单里没有「检查更新」' };
|
||||
entry.click();
|
||||
|
||||
const findDialog = () =>
|
||||
Array.from(document.querySelectorAll('.el-dialog')).find((node) =>
|
||||
(node.querySelector('.el-dialog__title')?.textContent ?? '').includes('检查更新'),
|
||||
);
|
||||
|
||||
const deadline = Date.now() + 25000;
|
||||
let state = '';
|
||||
while (Date.now() < deadline && !state) {
|
||||
const dialog = findDialog();
|
||||
const text = (dialog?.innerText ?? '').replace(/\\s+/g, ' ');
|
||||
if (text.includes('发现新版本')) state = '发现新版本';
|
||||
else if (text.includes('已是最新版本')) state = '已是最新版本';
|
||||
else if (text.includes('暂时无法检查更新')) state = '暂时无法检查更新';
|
||||
if (!state) await new Promise((resolve) => setTimeout(resolve, 150));
|
||||
}
|
||||
|
||||
// 收尾关闭,避免影响后续用例。Element Plus 关闭后 DOM 仍在(只把 .el-overlay 置成 display:none),
|
||||
// 而且淡出有过渡 —— 所以要轮询等遮罩真的隐藏,不能点完 sleep 一下就看(会误报"没关上")。
|
||||
const dialog = findDialog();
|
||||
const closeButton = Array.from(dialog?.querySelectorAll('.el-dialog__footer button') ?? []).find(
|
||||
(node) => (node.textContent ?? '').trim() === '关闭',
|
||||
);
|
||||
closeButton?.click();
|
||||
|
||||
const closeDeadline = Date.now() + 5000;
|
||||
let closed = false;
|
||||
while (Date.now() < closeDeadline && !closed) {
|
||||
const overlay = findDialog()?.closest('.el-overlay');
|
||||
closed = !overlay || getComputedStyle(overlay).display === 'none';
|
||||
if (!closed) await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
|
||||
return state
|
||||
? { ok: true, state, closed }
|
||||
: { ok: false, reason: '弹窗 25 秒内没有渲染出结论' };
|
||||
})()`);
|
||||
record(
|
||||
'更新检查(管理员入口):顶栏菜单 → 弹窗给出结论并可关闭',
|
||||
Boolean(updateCheck?.ok) && updateCheck?.closed !== false,
|
||||
`结论=${updateCheck?.state ?? '-'} 已关闭=${updateCheck?.closed ?? '-'}${
|
||||
updateCheck?.reason ? ` 原因=${updateCheck.reason}` : ''
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
@@ -743,6 +809,53 @@ async function main() {
|
||||
})()`);
|
||||
await sleep(300);
|
||||
|
||||
// 7.66 成绩图表:内置 SVG/CSS 图表(替换 echarts 后的回归)
|
||||
// echarts 全量引入曾让 GradesView 分块有 1.1MB;换成两个自包含组件后
|
||||
// 分块降到十几 KB。这里断言的是"真的画出来了":柱子有实际高度、
|
||||
// 折线有路径、数据点落在不同的纵坐标上(否则说明比例换算写错了)。
|
||||
const gradeCharts = await win.webContents.executeJavaScript(`(() => {
|
||||
const bar = document.querySelector('.bar-chart');
|
||||
const line = document.querySelector('.line-chart');
|
||||
if (!bar || !line) return { ok: false, reason: '成绩页没有渲染图表容器' };
|
||||
const empty = Boolean(bar.querySelector('.bar-chart-empty'));
|
||||
const heights = Array.from(bar.querySelectorAll('.bar')).map(
|
||||
(node) => node.getBoundingClientRect().height,
|
||||
);
|
||||
const points = Array.from(line.querySelectorAll('.point'));
|
||||
const tops = new Set(points.map((node) => Math.round(node.getBoundingClientRect().top)));
|
||||
// 柱高比例要跟数据对上:最高的柱应接近绘图区高度,而不是全都贴地或全都顶格
|
||||
const track = bar.querySelector('.bar-track')?.getBoundingClientRect().height ?? 0;
|
||||
return {
|
||||
ok: true,
|
||||
empty,
|
||||
barCount: heights.length,
|
||||
drawnBars: heights.filter((h) => h > 0).length,
|
||||
distinctHeights: new Set(heights.map((h) => Math.round(h))).size,
|
||||
tallestRatio: track > 0 ? Number((Math.max(0, ...heights) / track).toFixed(2)) : 0,
|
||||
linePaths: line.querySelectorAll('svg path').length,
|
||||
pointCount: points.length,
|
||||
distinctTops: tops.size,
|
||||
};
|
||||
})()`);
|
||||
// 注意:某个等级人数为 0 时它的柱高本来就是 0(echarts 也一样),
|
||||
// 所以判据是「至少画出一根、且柱高有区分度」,不是「每根都有高度」。
|
||||
record(
|
||||
'成绩图表为内置 SVG/CSS(柱子按数据出高度、折线有路径与数据点)',
|
||||
Boolean(gradeCharts?.ok) &&
|
||||
gradeCharts?.empty === false &&
|
||||
gradeCharts?.barCount > 0 &&
|
||||
gradeCharts?.drawnBars >= 1 &&
|
||||
gradeCharts?.distinctHeights > 1 &&
|
||||
gradeCharts?.tallestRatio > 0.3 &&
|
||||
gradeCharts?.tallestRatio <= 1.01 &&
|
||||
gradeCharts?.linePaths >= 1 &&
|
||||
gradeCharts?.pointCount > 0 &&
|
||||
gradeCharts?.distinctTops > 1,
|
||||
`柱=${gradeCharts?.drawnBars}/${gradeCharts?.barCount}(高度种类=${gradeCharts?.distinctHeights} 最高占绘图区=${gradeCharts?.tallestRatio})` +
|
||||
` 折线路径=${gradeCharts?.linePaths} 数据点=${gradeCharts?.pointCount} 纵坐标种类=${gradeCharts?.distinctTops}` +
|
||||
`${gradeCharts?.reason ? ` 原因=${gradeCharts.reason}` : ''}`,
|
||||
);
|
||||
|
||||
// 7.7 ClassIsland 时间配置导入弹窗(班主任可见:粘贴 JSON → 解析预览 → 确认导入)
|
||||
// 7.7 ClassIsland 课程表导入弹窗(班主任可见:粘贴 JSON → 解析预览 → 单双周识别)
|
||||
// 注:需求调整后课表页只保留「导入 ClassIsland 课程表」入口("导入时间配置"按钮已下线,
|
||||
|
||||
Reference in new issue
Block a user