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:
LoveChengke committed 2026-10-05 16:39:38 +08:00
1 parent aad22df4fd
commit 9a38f86cd3
77 files changed
+8021 -899

No files matched your search

@@ -0,0 +1,268 @@
<script setup lang="ts">
import { computed } from 'vue';
/**
* 轻量折线图(内联 SVG + HTML 数据点,不依赖任何图表库)。
*
* 为什么不用 echarts:成绩页只需要一条「各科平均得分率」折线,
* 而 `import * as echarts from 'echarts'` 会给构建产物加 1.1MB。
*
* 实现要点:
* - 线画在 `viewBox="0 0 100 100"` + `preserveAspectRatio="none"` 的 SVG 里,
* 于是 viewBox 坐标 (x, y) 精确对应绘图区的 (x%, y%);`vector-effect="non-scaling-stroke"`
* 保证非等比拉伸时线宽仍是 2px;
* - 数据点用**绝对定位的 HTML 圆点**(而不是 SVG `<circle>`),这样非等比拉伸下仍是正圆;
* 点位与线的坐标共用同一套百分比,天然对齐;
* - 横轴分类点落在**每个分组的中心**(`(i + 0.5) / n`),与 echarts 的 category 轴一致;
* - 全程零 resize 监听。
*/
interface LineItem {
label: string;
value: number;
}
const props = withDefaults(
defineProps<{
items: LineItem[];
color?: string;
/** 纵轴上限;不传时按数据最大值向上取整 */
max?: number;
unit?: string;
height?: number;
}>(),
{ color: '#67c23a', max: undefined, unit: '%', height: 220 },
);
function niceCeil(value: number): number {
if (value <= 0) return 1;
const base = 10 ** Math.floor(Math.log10(value));
const normalized = value / base;
const step = normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;
return step * base;
}
const axisMax = computed(() => {
if (props.max !== undefined) return props.max;
const dataMax = props.items.reduce((max, item) => Math.max(max, item.value), 0);
return niceCeil(dataMax);
});
const ticks = computed(() => {
const values = [1, 0.75, 0.5, 0.25, 0].map((ratio) => Math.round(axisMax.value * ratio));
return [...new Set(values)];
});
/** 数据点:x / y 都是绘图区的百分比坐标(0~100) */
const points = computed(() => {
const count = props.items.length;
const max = axisMax.value;
return props.items.map((item, index) => {
const ratio = max > 0 ? item.value / max : 0;
return {
label: item.label,
value: item.value,
x: ((index + 0.5) / count) * 100,
y: (1 - Math.min(1, Math.max(0, ratio))) * 100,
};
});
});
/**
* Catmull-Rom 转三次贝塞尔,复刻 echarts `smooth: true` 的观感。
* tension 0.2 与 echarts 的默认平滑强度接近。
*/
const linePath = computed(() => {
const list = points.value;
if (list.length < 2) return '';
const tension = 0.2;
const round = (value: number) => Number(value.toFixed(2));
let path = `M ${round(list[0]!.x)} ${round(list[0]!.y)}`;
for (let index = 0; index < list.length - 1; index += 1) {
const previous = list[index - 1] ?? list[index]!;
const current = list[index]!;
const next = list[index + 1]!;
const afterNext = list[index + 2] ?? next;
const control1x = current.x + (next.x - previous.x) * tension;
const control1y = current.y + (next.y - previous.y) * tension;
const control2x = next.x - (afterNext.x - current.x) * tension;
const control2y = next.y - (afterNext.y - current.y) * tension;
path += ` C ${round(control1x)} ${round(control1y)}, ${round(control2x)} ${round(control2y)}, ${round(
next.x,
)} ${round(next.y)}`;
}
return path;
});
/** 折线下方的面积:从终点垂到基线,再沿基线回到起点 */
const areaPath = computed(() => {
const list = points.value;
if (list.length < 2) return '';
const first = list[0]!;
const last = list[list.length - 1]!;
return `${linePath.value} L ${Number(last.x.toFixed(2))} 100 L ${Number(first.x.toFixed(2))} 100 Z`;
});
function formatValue(value: number): string {
return `${Number.isInteger(value) ? value : value.toFixed(1)}${props.unit}`;
}
</script>
<template>
<div class="line-chart" :style="{ height: `${height}px` }">
<div v-if="items.length === 0" class="line-chart-empty">暂无数据</div>
<template v-else>
<div class="axis-y" aria-hidden="true">
<span v-for="tick in ticks" :key="tick" class="tick">{{ tick }}{{ unit }}</span>
</div>
<div class="plot">
<div class="gridlines" aria-hidden="true">
<span v-for="tick in ticks" :key="tick" class="gridline"></span>
</div>
<svg class="lines" viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true">
<path v-if="areaPath" :d="areaPath" :fill="color" fill-opacity="0.12" />
<path
v-if="linePath"
:d="linePath"
fill="none"
:stroke="color"
stroke-width="2"
stroke-linejoin="round"
stroke-linecap="round"
vector-effect="non-scaling-stroke"
/>
</svg>
<div class="points">
<div v-for="point in points" :key="point.label" class="point-col">
<span
class="point"
:style="{ top: `${point.y}%`, background: color }"
:title="`${point.label}:${formatValue(point.value)}`"
></span>
</div>
</div>
<div class="x-labels" aria-hidden="true">
<span v-for="point in points" :key="point.label" class="x-label" :title="point.label">
{{ point.label }}
</span>
</div>
</div>
</template>
</div>
</template>
<style scoped>
.line-chart {
display: grid;
grid-template-columns: 40px 1fr;
width: 100%;
}
.line-chart-empty {
grid-column: 1 / -1;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 13px;
color: var(--el-text-color-placeholder);
}
/* 上下留白与绘图区(.gridlines / .lines / .points 的 inset)严格一致 */
.axis-y {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 18px 0 28px;
}
.tick {
height: 0;
display: flex;
align-items: center;
justify-content: flex-end;
padding-right: 8px;
font-size: 11px;
line-height: 1;
white-space: nowrap;
color: var(--el-text-color-secondary);
}
.plot {
position: relative;
min-width: 0;
}
.gridlines,
.lines,
.points {
position: absolute;
inset: 18px 0 28px;
}
.gridlines {
display: flex;
flex-direction: column;
justify-content: space-between;
pointer-events: none;
}
.gridline {
height: 0;
border-top: 1px solid var(--el-border-color-lighter);
}
.lines {
/* 尺寸完全由上面的 inset 决定(left/right/top/bottom 都给了),不要再写 width/height,
否则会和 inset 打架 */
pointer-events: none;
}
.points {
display: flex;
}
.point-col {
flex: 1 1 0;
min-width: 0;
position: relative;
}
.point {
position: absolute;
left: 50%;
width: 8px;
height: 8px;
border-radius: 50%;
transform: translate(-50%, -50%);
}
.x-labels {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 28px;
display: flex;
pointer-events: none;
}
.x-label {
flex: 1 1 0;
min-width: 0;
padding-top: 6px;
font-size: 11px;
line-height: 1.3;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: var(--el-text-color-secondary);
}
</style>