Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4449fbd0a1 | ||
|
|
195ee3b90a | ||
|
|
0b57e926bd | ||
|
|
9351203deb | ||
|
|
cdb64c5499 | ||
|
|
0b35a58f07 |
No files matched your search
@@ -26,6 +26,10 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
type: boolean
|
type: boolean
|
||||||
|
source_ref:
|
||||||
|
description: '同版本重建的源码提交;留空按 tag 检出'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
@@ -53,7 +57,7 @@ jobs:
|
|||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ steps.ref.outputs.tag }}
|
ref: ${{ inputs.source_ref || steps.ref.outputs.tag }}
|
||||||
|
|
||||||
- name: 安装 Node 22
|
- name: 安装 Node 22
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pnpm monorepo,根 `package.json` 是版本单一来源。文档、注释、界
|
|||||||
|
|
||||||
| 目录 | 用途 |
|
| 目录 | 用途 |
|
||||||
| -------------------------- | --------------------------------------------------------- |
|
| -------------------------- | --------------------------------------------------------- |
|
||||||
|
| `packages/ui/src/` | Web 与桌面端共享 Vue 控件、主题、日期选择器与全屏引导 |
|
||||||
| `packages/shared/src/` | 三端共享类型、权限、常量、动效、岛方案与课件契约 |
|
| `packages/shared/src/` | 三端共享类型、权限、常量、动效、岛方案与课件契约 |
|
||||||
| `packages/server/` | Express、Prisma、Socket.IO;API 前缀 `/api` |
|
| `packages/server/` | Express、Prisma、Socket.IO;API 前缀 `/api` |
|
||||||
| `packages/web-admin/` | Vue Web 管理端,PWA |
|
| `packages/web-admin/` | Vue Web 管理端,PWA |
|
||||||
@@ -39,7 +40,8 @@ pnpm monorepo,根 `package.json` 是版本单一来源。文档、注释、界
|
|||||||
- 作业和通知按本地 `assignDate` 归类,使用 `dayKeyLocal/isDayKey/shiftDayKey`,不用 UTC 日期切片。
|
- 作业和通知按本地 `assignDate` 归类,使用 `dayKeyLocal/isDayKey/shiftDayKey`,不用 UTC 日期切片。
|
||||||
- 批量通知/作业逐班返回结果;跨班作业按科目名匹配既有课程,找不到则该班失败,不自动把发布者设为任课老师。
|
- 批量通知/作业逐班返回结果;跨班作业按科目名匹配既有课程,找不到则该班失败,不自动把发布者设为任课老师。
|
||||||
- 两个登录接口共用登录限流。附件链接校验 scheme;表格文件上限 8 MB、JSON 请求体 12 MB,超限映射 413。
|
- 两个登录接口共用登录限流。附件链接校验 scheme;表格文件上限 8 MB、JSON 请求体 12 MB,超限映射 413。
|
||||||
- AI 助手只解析待确认动作,前端确认后调既有发布接口;参数重新校验,Key 加密存储且不回传。自动化用 mock,不访问外网。
|
- AI 查询和模型上下文按原业务权限读取;写操作由动作目录生成计划,用户确认后调用既有业务接口,入口绑定操作者、参数和步骤并持久去重。数据库维护、服务器运维与密钥操作不注册为 AI 动作。密码经专用表单提交,计划参数加密保存;自动化用 mock,不访问外网。
|
||||||
|
- AI 可管理客户端安装包缓存:写入仅 ADMIN + `client:update`,要求专门确认,固定复用 `/update/client/fetch` 和 `/update/client/releases`。预览和执行核对版本、文件及已有登记;不开放服务器更新或任意下载地址,不自动推送或运行安装器。
|
||||||
|
|
||||||
## 3. 课表、周次、成绩与学年
|
## 3. 课表、周次、成绩与学年
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ pnpm monorepo,根 `package.json` 是版本单一来源。文档、注释、界
|
|||||||
- 事件名与房间名取 shared 常量。班级房间为 `class:{id}:{channel}`,教师按每域读键及范围订阅,班级端仅本班全部通道;握手回查数据库身份。业务用 `emitToClass/emitToSession`,由总线选择事件域。
|
- 事件名与房间名取 shared 常量。班级房间为 `class:{id}:{channel}`,教师按每域读键及范围订阅,班级端仅本班全部通道;握手回查数据库身份。业务用 `emitToClass/emitToSession`,由总线选择事件域。
|
||||||
- 会话房间为 `session:{id}`;教师/管理员 id 为账号 id,班级端为班级 id。`students` 是班级端广播房间,不是个人学生账号房间。
|
- 会话房间为 `session:{id}`;教师/管理员 id 为账号 id,班级端为班级 id。`students` 是班级端广播房间,不是个人学生账号房间。
|
||||||
- 新实时事件同步服务端、Web 订阅、客户端订阅。成绩实时载荷不可泄漏个人成绩。
|
- 新实时事件同步服务端、Web 订阅、客户端订阅。成绩实时载荷不可泄漏个人成绩。
|
||||||
|
- 两端基础控件、主题、日期圆点与全屏引导维护在 `packages/ui`。日期统计跟随当前筛选和日历可见范围,缓存按服务器与班级隔离;业务日期使用本地日期工具。
|
||||||
- Web 菜单分组在 `config/navigation.ts`,标题/图标/权限取路由;守卫与服务端都检查权限,前端隐藏不能代替鉴权。
|
- Web 菜单分组在 `config/navigation.ts`,标题/图标/权限取路由;守卫与服务端都检查权限,前端隐藏不能代替鉴权。
|
||||||
- 侧栏折叠用 CSS 保持 DOM,关怀模式放大字号/控件,不改变几何令牌。使用语义色,动效统一 shared 令牌;图标新增后检查注册表。
|
- 侧栏折叠用 CSS 保持 DOM,关怀模式放大字号/控件,不改变几何令牌。使用语义色,动效统一 shared 令牌;图标新增后检查注册表。
|
||||||
- 图标源是 `build/classhelper.png` 与设计导出的 `.ico`,`pnpm icons` 派生其余资源。ICO 原样透传,客户端兜底 `build/icon.*` 同步保留。
|
- 图标源是 `build/classhelper.png` 与设计导出的 `.ico`,`pnpm icons` 派生其余资源。ICO 原样透传,客户端兜底 `build/icon.*` 同步保留。
|
||||||
@@ -112,6 +115,7 @@ Prisma 使用 driver adapter;本机优先应用已有迁移,不用 `migrate
|
|||||||
| `pnpm lint` / `pnpm typecheck` / `pnpm check:icons` | 代码静态门禁;按改动范围执行 |
|
| `pnpm lint` / `pnpm typecheck` / `pnpm check:icons` | 代码静态门禁;按改动范围执行 |
|
||||||
| `pnpm docs:check` | 文档严格构建,警告即失败 |
|
| `pnpm docs:check` | 文档严格构建,警告即失败 |
|
||||||
| `pnpm verify:e2e` | 自动创建临时 SQLite 和账号,无需先开开发服务,禁止外网 |
|
| `pnpm verify:e2e` | 自动创建临时 SQLite 和账号,无需先开开发服务,禁止外网 |
|
||||||
|
| `pnpm verify:ai` | AI 白名单、计划确认、权限与附件隔离验收 |
|
||||||
| `pnpm verify:authz` / `pnpm verify:audit` | 隔离授权攻击矩阵;审计事务、竞态、模型操作计数和 PWA |
|
| `pnpm verify:authz` / `pnpm verify:audit` | 隔离授权攻击矩阵;审计事务、竞态、模型操作计数和 PWA |
|
||||||
| `pnpm verify:web:isolated` | 构建 Web 后运行隔离服务和隐藏 UI 回归 |
|
| `pnpm verify:web:isolated` | 构建 Web 后运行隔离服务和隐藏 UI 回归 |
|
||||||
| `pnpm verify:courseware` / `pnpm verify:v14` | 课件/课表等隔离专项 |
|
| `pnpm verify:courseware` / `pnpm verify:v14` | 课件/课表等隔离专项 |
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ services:
|
|||||||
context: ..
|
context: ..
|
||||||
dockerfile: deploy/Dockerfile
|
dockerfile: deploy/Dockerfile
|
||||||
target: runtime
|
target: runtime
|
||||||
image: classhelper-server:${APP_VERSION:-1.4.3}
|
image: classhelper-server:${APP_VERSION:-1.4.5}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ services:
|
|||||||
context: ..
|
context: ..
|
||||||
dockerfile: deploy/Dockerfile
|
dockerfile: deploy/Dockerfile
|
||||||
target: runtime
|
target: runtime
|
||||||
image: classhelper-server:${APP_VERSION:-1.4.3}
|
image: classhelper-server:${APP_VERSION:-1.4.5}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "classhelper-server-runtime",
|
"name": "classhelper-server-runtime",
|
||||||
"version": "1.4.3",
|
"version": "1.4.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "ClassHelper 服务端运行时(安装包 / 容器内置)",
|
"description": "ClassHelper 服务端运行时(安装包 / 容器内置)",
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"socket.io": "^4.8.3",
|
"socket.io": "^4.8.3",
|
||||||
"typescript": "~5.9.3",
|
"typescript": "~5.9.3",
|
||||||
"xlsx": "0.18.5",
|
"xlsx": "0.18.5",
|
||||||
|
"yaml": "^2.9.1",
|
||||||
"zod": "^4.6.2"
|
"zod": "^4.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ description: 深浅色主题、界面风格、设计令牌与动效语言,以
|
|||||||
|
|
||||||
## 深浅色主题
|
## 深浅色主题
|
||||||
|
|
||||||
**两端都有深色主题,机制完全一致**:在 `<html>` 上挂 `.dark` 类,由各自的样式表覆盖**语义色令牌**,
|
**两端都有深色主题,机制完全一致**:在 `<html>` 上挂 `.dark` 类,由共享 UI 主题覆盖**语义色令牌**,
|
||||||
Element Plus 的深色变量提供组件层的默认值。两端的 `main.ts` 都在挂载之前就把主题落好,
|
Element Plus 的深色变量提供组件层的默认值。两端的 `main.ts` 都在挂载之前就把主题落好,
|
||||||
所以深色用户打开时不会"先白后黑"闪一下。
|
所以深色用户打开时不会"先白后黑"闪一下。
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Element Plus 的深色变量提供组件层的默认值。两端的 `main.ts`
|
|||||||
| 切换效果 | 从点击位置**扩散的圆**铺满整页换肤 |
|
| 切换效果 | 从点击位置**扩散的圆**铺满整页换肤 |
|
||||||
|
|
||||||
**刻意不随主题的区域**:登录页的深色渐变底、桌面端的启动过渡页与全屏作业看板、灵动岛自身、
|
**刻意不随主题的区域**:登录页的深色渐变底、桌面端的启动过渡页与全屏作业看板、灵动岛自身、
|
||||||
Web 管理端的侧边栏(本来就是深色),以及深色底上的白色文字。
|
以及深色底上的白色文字。
|
||||||
|
|
||||||
Web 端还会同步 `<meta name="theme-color">`,并设 `color-scheme` 让**原生控件**
|
Web 端还会同步 `<meta name="theme-color">`,并设 `color-scheme` 让**原生控件**
|
||||||
(滚动条、日期选择器弹层、自动填充底色)也跟着走 —— 只改 CSS 变量的话它们会仍是浅色。
|
(滚动条、日期选择器弹层、自动填充底色)也跟着走 —— 只改 CSS 变量的话它们会仍是浅色。
|
||||||
@@ -44,13 +44,15 @@ Web 端还会同步 `<meta name="theme-color">`,并设 `color-scheme` 让**原
|
|||||||
|
|
||||||
## 界面风格
|
## 界面风格
|
||||||
|
|
||||||
- 浅色底 `#f3f3f3` + 半透明卡片(`rgba(255,255,255,.7)` + `backdrop-filter: blur(20px)`);
|
Web 和桌面主窗口共用简洁的管理界面:浅灰底、实色卡片、统一描边与紫蓝强调色。标题、筛选、操作栏和表单按同一套控件与间距规范呈现;深浅色切换保持相同几何。
|
||||||
- 强调色 `#0F6CBD`(悬停 `#115EA3`);选中的导航项 = 强调色淡底 + 左侧 3px 强调条;
|
|
||||||
- 圆角统一:卡片 8px / 控件 4px;描边用半透明黑代替灰线;阴影极轻;
|
|
||||||
- 字体 `Segoe UI Variable / 微软雅黑 UI`;Element Plus 的变量整体对齐这套规范。
|
|
||||||
|
|
||||||
Web 管理端走的是另一套(1Panel 风格:深色侧边栏 + 白色圆角卡片),
|
共享主题和控件由 UI 包维护,灵动岛只引入共用语义令牌,保留透明窗口和各模式的布局规则。
|
||||||
圆角与投影集中定义在它的 `:root` 令牌里。
|
|
||||||
|
日期统一通过日历选择。有记录的日期下方显示圆点,统计随当前筛选和可见月份更新。日期目录与日期下拉列表已改为日历,教师和文件夹仍可独立筛选。
|
||||||
|
|
||||||
|
Web 的作业、通知日期统计保留在当前会话缓存中,按服务器、操作者、权限范围和筛选条件隔离;退出或收到授权失败时清理。桌面端复用按服务器和班级隔离的离线缓存。只有网络不可达时才回退缓存,缓存故障不阻断在线读取。
|
||||||
|
|
||||||
|
首次进入新版会显示全屏分步引导,可以返回、跳过或完成;账号菜单、客户端登录页和通用设置保留重看入口。引导中的内容为示意,不创建业务数据。
|
||||||
|
|
||||||
## 动效语言
|
## 动效语言
|
||||||
|
|
||||||
@@ -94,6 +96,6 @@ beUI 的组件本身是 React,用不到这里,但它的动效语言与框架
|
|||||||
| 灵动岛 | 尺寸、字号、主题色、视觉风格、停靠、边距、空闲细缝(详见[灵动岛](island.md)) |
|
| 灵动岛 | 尺寸、字号、主题色、视觉风格、停靠、边距、空闲细缝(详见[灵动岛](island.md)) |
|
||||||
| 提醒 | 本机课程等提醒开关与行为 |
|
| 提醒 | 本机课程等提醒开关与行为 |
|
||||||
| 账号 | 当前班级信息、退出登录 |
|
| 账号 | 当前班级信息、退出登录 |
|
||||||
| 关于 | 版本 / Electron / Chromium / Node、诊断信息、检查更新、鸣谢 |
|
| 关于 | 版本 / Electron / Chromium / Node、诊断信息、云端下发更新的进度、鸣谢 |
|
||||||
|
|
||||||
`/settings` 会自动跳到「通用」。设置页的改动会**立刻生效并写进本机配置**,重启后仍保留。
|
`/settings` 会自动跳到「通用」。设置页的改动会**立刻生效并写进本机配置**,重启后仍保留。
|
||||||
@@ -1,26 +1,54 @@
|
|||||||
---
|
---
|
||||||
title: AI 助手
|
title: AI 助手
|
||||||
description: 将自然语言解析成待确认动作,核对后通过现有业务接口发布。
|
description: 多轮对话、文件处理与操作计划,核对后通过现有业务接口执行。
|
||||||
---
|
---
|
||||||
|
|
||||||
# AI 助手
|
# AI 助手
|
||||||
|
|
||||||
AI 助手位于 Web 管理端工作台。输入要发布的作业、通知或叫人请求,助手会展示解析出的班级、科目、内容与提醒级别;核对并确认后才发布。内容仍通过原有业务接口,继续校验当前账号的功能权限、班级范围及任课关系。
|
在 Web 管理端描述任务、补充条件或添加文件,助手会查询所需信息并生成操作计划。查询直接显示结果;任何发布、修改、导入和设备操作,都要核对计划并确认后执行。
|
||||||
|
|
||||||
## 配置与使用
|
## 使用
|
||||||
|
|
||||||
管理员在大模型设置中开启助手,选择服务地址和模型并保存 API Key。密钥加密存储,读取设置只返回是否已配置及末尾提示,不返回完整密钥。修改服务端 JWT 密钥后,原有加密 Key 需要重新配置。
|
1. 可先选择目标班级,再输入任务;文件也可以直接拖入对话区。
|
||||||
|
2. 信息不足时补充说明。核对目标、文件、修改前内容和本次变更;表格导入可调整字段对应。
|
||||||
|
3. 确认执行后逐步显示结果。跨班发布按班显示进度,成功班级不会重复执行。失败时只重试尚未成功的步骤;结果不明时先在对应业务页面核对。
|
||||||
|
|
||||||
1. 在助手页面描述操作与目标班级,等待解析预览。
|
文件推送复用课件上传、哈希校验和设备回执,普通课件上限 512 MB。结构化导入支持现有 CSV、Excel、JSON、YAML 格式,上限 8 MB,先解析预览,确认后才写入业务数据。
|
||||||
2. 核对班级、科目、标题、正文和提醒级别;有歧义时修改后重新解析。
|
|
||||||
3. 点击确认发布。紧急通知在上课期间仍需完成额外确认;批量操作逐班返回结果。
|
|
||||||
|
|
||||||
解析成功不代表已经发布,也不代表拥有对应班级或科目的写权限。缺少任课关系时,请由管理员配置;助手不能替用户建立授权。
|
## 权限
|
||||||
|
|
||||||
## 离线示例与审计
|
助手权限跟随操作者。教学业务、课表时间表、名单成绩、账号岗位和设备操作均使用原业务接口的授权规则;管理员专用功能仍限管理员。确认期间撤权、调班或任课关系变化后会重新校验。
|
||||||
|
|
||||||
`mock` 提供确定性的离线示例解析,用于自动化验收,不访问外网;预览会提示当前为示例结果。真实模型调用失败时页面保留可操作的错误说明,不会自动改用发布接口。
|
数据库备份、恢复、清空、切换、SQL,以及服务器配置、启停、升级和密钥维护不向助手开放。删除、权限调整、升学和远控保留专门确认;上课时的紧急通知仍需二次确认。
|
||||||
|
|
||||||
有管理权限的账号可查看助手审计。审计记录解析意图和状态,不代替作业、通知或叫人的最终发布结果;请结合对应业务页面核对。
|
管理员可让助手抓取、登记或删除客户端安装包缓存,核对版本、文件与替换信息并专门确认后执行。缓存管理不会自动推送、运行安装器或升级服务器。助手也可按设备权限处理远控、更新推送和移除设备登记。
|
||||||
|
|
||||||
相关规则:[作业](homeworks.md)、[通知](notifications.md)、[叫人](calls.md)、[角色与权限](../dev/permissions.md)。
|
密码通过操作卡片中的专用表单输入,不提供给模型。用户指令与任务所需的已授权业务信息由学校配置的模型服务解析;普通课件只提供文件元数据。
|
||||||
|
|
||||||
|
任务提交后在服务端后台运行,切换页面或关闭浏览器不取消规划及已确认的执行。重新进入助手可恢复最近任务、处理过程和结果;未确认的变更始终等待确认。停止按钮才会主动停止任务;已经发出的当前业务请求可能完成,后续步骤停止。服务重启后保留任务及步骤状态,核对后继续,未知执行结果不会自动重做。
|
||||||
|
|
||||||
|
附件须先上传完整并通过 SHA256 校验,之后才进入后台。关闭页面会中断尚未完成的本地上传,此时重新选择原文件;暂存不发布课件。临时附件在完成后清理,过期一天的暂存会在创建新任务时回收。后台输入、结果和进度加密保存;恢复查询时重新检查当前权限。计划与执行结果记入服务端审计。
|
||||||
|
|
||||||
|
处理过程实时显示权限检查、查询、自动校正、预览和执行阶段。空白或截断回复自动重试,兼容 JSON 代码块包装;业务参数仍须通过原接口校验。若模型持续不可用,任务保留为未完成并提供重试,不伪报成功或自动执行未确认操作。
|
||||||
|
|
||||||
|
## 模型配置与验收
|
||||||
|
|
||||||
|
管理员在大模型设置中配置服务地址、模型和 API Key。Key 加密保存且不回传;改变服务器 JWT 密钥后需重新配置 Key。
|
||||||
|
|
||||||
|
服务地址既可填写基础地址(如 `https://api.deepseek.com`、`https://api.openai.com/v1`),也可填写完整 `/chat/completions` 端点,系统不会重复拼接路径。DeepSeek 例如填写 `https://api.deepseek.com/chat/completions`,模型名须使用该服务实际支持的模型。
|
||||||
|
|
||||||
|
填好地址和密钥后自动获取可用模型,也可点击“获取模型”刷新或手动填写。推理强度支持自动及模型提供的档位;服务未提供能力信息时使用通用档位,自动不附加推理参数。模型列表和强度遵循[服务商接口](https://api-docs.deepseek.com/api/list-models/),不会把密钥返回浏览器。
|
||||||
|
|
||||||
|
`mock` 用于离线示例和自动化验收,真实服务失败不会自动切换为 mock 或发布内容。`pnpm verify:ai` 使用临时数据库和模型 stub 验证权限、计划、附件和重复提交,不访问外网。
|
||||||
|
|
||||||
|
相关功能:[课件](courseware.md)、[课表](schedules.md)、[作业](homeworks.md)、[通知](notifications.md)、[角色与权限](../dev/permissions.md)。
|
||||||
|
|
||||||
|
## 对话与轮次
|
||||||
|
|
||||||
|
对话历史按账号保存在服务器。每次发送是一轮,右侧横条可跳转轮次,新对话独立保存。助手缺少必要信息时会弹出提问窗口,可选答案或自由回答。关闭窗口后可通过历史消息中的“回答问题”再次打开,刷新页面也能恢复待回答的问题;追问阶段不执行写入。格式自动修正每轮至多一次,失败后保留明确的重试入口。
|
||||||
|
|
||||||
|
勾选“本轮明确替换当前待确认计划”后,新计划形成时只使选中的旧计划失效,历史记录保留。不勾选时保留旧计划;新建对话不影响其他对话的计划。
|
||||||
|
|
||||||
|
删除课表等危险操作时,目标明确后会先生成变更预览,点击“确认执行”才弹出危险操作确认窗口。聊天中的“确认”回答只用于继续生成预览,不代替最终执行确认。
|
||||||
|
|
||||||
|
在对话历史中选择对话后,可点击“删除对话”。确认后清除该对话的轮次和暂存附件,未完成计划失效;已执行的业务操作及审计记录保留。仍有后台任务时,请先停止或等待完成再删除。
|
||||||
@@ -40,3 +40,7 @@
|
|||||||
使用反向代理时,需允许课件上传大小和足够的读写超时。仓库的 Nginx 样例单独为 `/api/courseware/` 配置 512 MB 和 1800 秒超时,其他接口维持原有大小限制。
|
使用反向代理时,需允许课件上传大小和足够的读写超时。仓库的 Nginx 样例单独为 `/api/courseware/` 配置 512 MB 和 1800 秒超时,其他接口维持原有大小限制。
|
||||||
|
|
||||||
开发验收:`pnpm verify:courseware` 自动使用隔离数据库和临时文件目录,不读取或向真实班级发送课件。
|
开发验收:`pnpm verify:courseware` 自动使用隔离数据库和临时文件目录,不读取或向真实班级发送课件。
|
||||||
|
|
||||||
|
## 文件夹浏览
|
||||||
|
|
||||||
|
课件默认按文件夹逐层浏览,只显示当前层文件和直属子目录。使用面包屑或返回上级切换目录;多位教师的目录按教师身份区分。上传与新建目录默认使用当前位置,未分类文件位于根目录。日期归档视图仍可用于按日期查找文件。
|
||||||
@@ -16,13 +16,13 @@ description: 表格预览、名单与成绩校验,以及完整离线档案导
|
|||||||
|
|
||||||
- 学生成绩按学号匹配,姓名兜底要求同班唯一;转出学生不参与匹配,重复记录和写入模式由服务校验。
|
- 学生成绩按学号匹配,姓名兜底要求同班唯一;转出学生不参与匹配,重复记录和写入模式由服务校验。
|
||||||
- 学生模板使用学号、姓名、班级、性别、家长电话,无密码;学号 1–32 位字母/数字/._-,在 Student 表查重。
|
- 学生模板使用学号、姓名、班级、性别、家长电话,无密码;学号 1–32 位字母/数字/._-,在 Student 表查重。
|
||||||
- 教师模板使用工号、姓名、手机号、初始密码、角色;学生/教师名单导入仍要求管理员和导入权限。
|
- 教师模板使用工号、姓名、手机号、角色;每个新建教师分别生成随机初始密码,导入结果提供一次性查看和 CSV 下载,关闭前请保存分发。重复导入已有教师不修改密码,旧表格中的密码列不再用于设置密码。任课关系导入中新建的教师采用相同规则;学生/教师名单导入仍要求管理员和导入权限。
|
||||||
- 成绩表格导入当前先要求管理员或本班班主任,再校验每行科目任课关系;科任老师的单条/批量成绩写入权限不代表能走表格导入。
|
- 成绩表格导入当前先要求管理员或本班班主任,再校验每行科目任课关系;科任老师的单条/批量成绩写入权限不代表能走表格导入。
|
||||||
- 任课关系导入用于既有班级、科目和教师的对应关系,不把档案中的 TeacherName 当账号授权。
|
- 任课关系导入用于既有班级、科目和教师的对应关系,不把档案中的 TeacherName 当账号授权。
|
||||||
|
|
||||||
## 完整 ClassIsland 档案
|
## 完整 ClassIsland 档案
|
||||||
|
|
||||||
在“课表档案 → 导入档案”选择或粘贴 JSON,先预览再导入。
|
在“课表档案 → 导入/导出 → 导入课表(JSON / YAML)”选择或粘贴 JSON,先预览再导入。
|
||||||
完整输入包含 TimeLayouts、ClassPlans、Subjects 字典,可包含 ClassPlanGroups 和 OrderedSchedules 等配置。
|
完整输入包含 TimeLayouts、ClassPlans、Subjects 字典,可包含 ClassPlanGroups 和 OrderedSchedules 等配置。
|
||||||
JSON 只作为离线文件导入,不依赖在线联动插件。
|
JSON 只作为离线文件导入,不依赖在线联动插件。
|
||||||
|
|
||||||
@@ -44,6 +44,37 @@ JSON 只作为离线文件导入,不依赖在线联动插件。
|
|||||||
不完整展示群组/空课/停用等结构;提交直接调用完整导入,不能把预览的单双周列当作实际数据模型。
|
不完整展示群组/空课/停用等结构;提交直接调用完整导入,不能把预览的单双周列当作实际数据模型。
|
||||||
完整导入失败时事务回滚;部分缺失引用可能返回 warnings,须检查导入结果和日课表编辑器。
|
完整导入失败时事务回滚;部分缺失引用可能返回 warnings,须检查导入结果和日课表编辑器。
|
||||||
|
|
||||||
|
## YAML 课表
|
||||||
|
|
||||||
|
同一导入窗口支持 `.yaml` / `.yml` 文件和粘贴内容,提供示例下载。先解析预览,再选择合并或覆盖。
|
||||||
|
文件上限 8 MB。格式如下:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: 1
|
||||||
|
subjects:
|
||||||
|
- name: 数学
|
||||||
|
simplified_name: 数
|
||||||
|
teacher: 李梅
|
||||||
|
room: '101'
|
||||||
|
schedules:
|
||||||
|
- name: 星期一
|
||||||
|
enable_day: 1
|
||||||
|
weeks: all
|
||||||
|
classes:
|
||||||
|
- subject: 数学
|
||||||
|
start_time: '080000'
|
||||||
|
end_time: '090000'
|
||||||
|
```
|
||||||
|
|
||||||
|
`enable_day` 为 1–7(周一至周日);`weeks` 支持 `all`(每周)、`odd`(单周)、`even`(双周)。
|
||||||
|
同一天的单周与双周分开填写,同一天同一相位不可重复,也不能混用每周与单双周课表。
|
||||||
|
时间支持 `HHMMSS`、`HH:mm`、`HH:mm:ss`,秒必须为 `00`;未加引号的六位数字也可识别。
|
||||||
|
兼容以 `version 1` 开头、字段省略冒号的示例写法,并在预览中提示;新文件建议采用上述标准 YAML。
|
||||||
|
|
||||||
|
`simplified_name` 保存为科目简称,`room` 保存为课次地点;`teacher` 只在预览中展示,不创建教师账号或改变任课关系。
|
||||||
|
缺失科目按完整档案规则补建。YAML 归一化为关系化时间点和日课表后复用完整导入的权限、事务和实时更新。
|
||||||
|
合并按星期与单双周更新同一套 YAML 对象;覆盖会替换该班已有日课表。语法或字段校验失败时不会写库。
|
||||||
|
|
||||||
## 时间配置兼容入口
|
## 时间配置兼容入口
|
||||||
|
|
||||||
旧 /imports/time-layout 接口保留,写入和删除需 timetable:manage,现行写入同步关系化时间点。
|
旧 /imports/time-layout 接口保留,写入和删除需 timetable:manage,现行写入同步关系化时间点。
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ description: 经典提醒、自定义常驻方案、课程与课件传输。
|
|||||||
|
|
||||||
“设置 → 灵动岛 → 自定义 → 编辑岛内组件”进入主窗口设置页。
|
“设置 → 灵动岛 → 自定义 → 编辑岛内组件”进入主窗口设置页。
|
||||||
页面上方排列当前组件,右上角选择配置方案;刷新图标重置当前方案,加号新建方案,文件夹菜单提供方案设置、复制、删除及 JSON 导入导出。
|
页面上方排列当前组件,右上角选择配置方案;刷新图标重置当前方案,加号新建方案,文件夹菜单提供方案设置、复制、删除及 JSON 导入导出。
|
||||||
下方组件库常驻显示文本、分割线、课程表、日期、时钟、天气简报、倒计时和组合容器,并保留班级通知、作业和叫人组件。
|
下方组件库常驻显示文本、分割线、课程表、日期、时钟、天气简报、倒计时和组合容器。通知、作业和叫人通过岛内铃铛及共用消息面板展示,组件库不再提供这些消息选项;已有方案中的消息节点仍兼容。
|
||||||
从组件库拖入上方的行或容器以添加,拖动已有组件调整顺序或跨行移动;也可点击组件库添加到选中的容器或当前行。
|
从组件库拖入上方的行或容器以添加,拖动已有组件调整顺序或跨行移动;也可点击组件库添加到选中的容器或当前行。
|
||||||
分别编辑常态 rows 与无消息展开 expandedRows,点选组件打开内容、外观、尺寸与隐藏条件设置;行可以新增、排序、设为主要行或删除。
|
分别编辑常态 rows 与无消息展开 expandedRows,点选组件打开内容、外观、尺寸与隐藏条件设置;行可以新增、排序、设为主要行或删除。
|
||||||
“进入编辑模式”切换为实际内容预览,支持预览缩放;退出后回到组件标签排列。轮播和滚动容器在编辑时展示全部子组件,便于选择和排列。
|
“进入编辑模式”切换为实际内容预览,支持预览缩放;退出后回到组件标签排列。轮播和滚动容器在编辑时展示全部子组件,便于选择和排列。
|
||||||
@@ -50,7 +50,8 @@ description: 经典提醒、自定义常驻方案、课程与课件传输。
|
|||||||
## 外观、位置与输入
|
## 外观、位置与输入
|
||||||
|
|
||||||
经典模式可调宽高、字号、主题色、黑色/半透明/渐变、停靠与边距;自定义内容根据实际测量适配工作区。
|
经典模式可调宽高、字号、主题色、黑色/半透明/渐变、停靠与边距;自定义内容根据实际测量适配工作区。
|
||||||
自定义方案可配置缩放、圆角、颜色和行间距,默认值与范围在 shared/island-layout.ts。
|
自定义方案可配置缩放、四档字号、字重、圆角、背景/前景色和行间距,默认值与范围在 shared/island-layout.ts。四档字号输入范围是 1–40px,可按组件或单行覆盖;关闭行级覆盖后只回落该行,不影响其他行。
|
||||||
|
强调色支持自定义、壁纸调色板、跟随系统和屏幕调色板四种来源;自定义背景与前景可分别关闭,关闭后回落当前亮/暗主题。前景色会派生 100% / 85.5% / 77.3% / 52.9% / 36.5% 五级文字 alpha。外观页的圆角滑块同步修改当前自定义方案的常态圆角,与编辑器设置一致。
|
||||||
左右边距只在左/右停靠时生效,居中锚点仍在屏幕中线。
|
左右边距只在左/右停靠时生效,居中锚点仍在屏幕中线。
|
||||||
触摸屏自动进入触摸模式,保留触摸命中和失焦宽限;鼠标模式按光标控制输入穿透。
|
触摸屏自动进入触摸模式,保留触摸命中和失焦宽限;鼠标模式按光标控制输入穿透。
|
||||||
自定义常驻内容支持鼠标避让淡化及反转,交互入口、展开/编辑和触摸操作按实现暂停避让。
|
自定义常驻内容支持鼠标避让淡化及反转,交互入口、展开/编辑和触摸操作按实现暂停避让。
|
||||||
@@ -65,9 +66,9 @@ description: 经典提醒、自定义常驻方案、课程与课件传输。
|
|||||||
自定义常驻岛的「课程表」组件可选「当前时间点 / 下一节课 / 今日时间点」:
|
自定义常驻岛的「课程表」组件可选「当前时间点 / 下一节课 / 今日时间点」:
|
||||||
「今日时间点」显示当天全部时间点,只有当前项展开显示起止时间,其余折叠只显示课程名;
|
「今日时间点」显示当天全部时间点,只有当前项展开显示起止时间,其余折叠只显示课程名;
|
||||||
课间休息与「默认隐藏」的上课时间点折叠时完全隐藏,轮到它们时才展开;分割线显示一条竖线,行动不显示。
|
课间休息与「默认隐藏」的上课时间点折叠时完全隐藏,轮到它们时才展开;分割线显示一条竖线,行动不显示。
|
||||||
课中课程表不再常驻显示倒计时,只在最后一分钟由既有的「下课提醒」页显示「距下课还剩」;
|
临近下课时,当前课程名右侧显示蓝色圆形秒数徽标,例如剩余一秒显示 `-1`,不显示“即将下课”遮罩,也不替换自定义岛的常态组件。
|
||||||
倒计时阈值沿用本机提醒设置(默认 60 秒)。没有时间点数据时退回按课表条目显示课程。
|
倒计时阈值沿用本机提醒设置(默认 60 秒),关闭即将下课倒数后不显示徽标。没有时间点数据时退回按课表条目显示课程。
|
||||||
经典 fixed 岛的课中提醒条保持原有倒计时行为。
|
经典 fixed 岛的临近下课提醒也使用课程名右侧的秒数徽标,其余上下课提醒保留。
|
||||||
|
|
||||||
课件接收时显示文件名、类型、教师、字节和进度,覆盖当前固定/自定义内容;完成后校验 SHA256 并回执。
|
课件接收时显示文件名、类型、教师、字节和进度,覆盖当前固定/自定义内容;完成后校验 SHA256 并回执。
|
||||||
客户端不会自动执行收到的文件,见[课件](courseware.md)。
|
客户端不会自动执行收到的文件,见[课件](courseware.md)。
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ Web 管理端统一从「教学事务 → 课表档案」查看周课表并编
|
|||||||
|
|
||||||
完整档案可在页头「导入/导出」中导入或导出 JSON,保留轮换、时间点类型、空课、停用、群组和预定。月视图提供日期导航,点击日期后由服务端解析教学周并进入周视图。
|
完整档案可在页头「导入/导出」中导入或导出 JSON,保留轮换、时间点类型、空课、停用、群组和预定。月视图提供日期导航,点击日期后由服务端解析教学周并进入周视图。
|
||||||
|
|
||||||
|
「导入课表(JSON / YAML)」还支持简化的 YAML 课表,包含星期、单双周、科目和起止时间;字段与示例见[表格与课表导入](imports.md)。
|
||||||
|
|
||||||
## 日课表与时间表
|
## 日课表与时间表
|
||||||
|
|
||||||
时间表保存时间点:上课、课间、分割线、行动;日课表引用时间表,每节课程通过外键关联时间点。
|
时间表保存时间点:上课、课间、分割线、行动;日课表引用时间表,每节课程通过外键关联时间点。
|
||||||
@@ -49,3 +51,9 @@ Web 管理端统一从「教学事务 → 课表档案」查看周课表并编
|
|||||||
离线导入完整 ClassIsland 档案可创建班级自有作息,不依赖在线联动插件。
|
离线导入完整 ClassIsland 档案可创建班级自有作息,不依赖在线联动插件。
|
||||||
完整导入保留 1–9 周轮换、空课、停用、群组和预定;旧预览界面的单双周展示不代表新模型只能表达双周。
|
完整导入保留 1–9 周轮换、空课、停用、群组和预定;旧预览界面的单双周展示不代表新模型只能表达双周。
|
||||||
见[表格与课表导入](imports.md)。修改后广播 schedule:updated,客户端刷新。
|
见[表格与课表导入](imports.md)。修改后广播 schedule:updated,客户端刷新。
|
||||||
|
|
||||||
|
## 每日作息差异
|
||||||
|
|
||||||
|
导入的每日作息不一致时,时间表按日期生成独立子表,同日单双周也可分别维护。子表独立保存完整作息,父级用于归组。周视图按课时对齐;点击日期或课程后,时间列显示对应日期的作息,点击时间列标题清除选择后显示带星期标记的差异时间。切换子表保留可对应的课程,节数不足时阻止切换并保留原草稿。
|
||||||
|
|
||||||
|
导入或保存时间表时自动补齐两节课之间的空白,包括午休。已有命名休息、活动及显式空课保留,不在最后一节之后追加休息。旧混合时间表请使用原文件预览后重新导入,不自动猜测空课归属。
|
||||||
@@ -28,7 +28,7 @@ API 前缀 /api,JWT 使用 Authorization: Bearer。成功/失败结构以 `lib
|
|||||||
## 教学与文件
|
## 教学与文件
|
||||||
|
|
||||||
| 路径/动作 | 行为及边界 |
|
| 路径/动作 | 行为及边界 |
|
||||||
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||||
| /courses | 班级科目与任课关系 |
|
| /courses | 班级科目与任课关系 |
|
||||||
| GET /schedules、/grid、/current、/active-week | 新关系模型的兼容投影,按班级范围读取 |
|
| GET /schedules、/grid、/current、/active-week | 新关系模型的兼容投影,按班级范围读取 |
|
||||||
| POST/PATCH/DELETE /schedules[/:id] | 兼容 CRUD,写新模型,不双写旧 Schedule |
|
| POST/PATCH/DELETE /schedules[/:id] | 兼容 CRUD,写新模型,不双写旧 Schedule |
|
||||||
@@ -43,6 +43,7 @@ API 前缀 /api,JWT 使用 Authorization: Bearer。成功/失败结构以 `lib
|
|||||||
| /grades、/grades/bulk、/stats、/levels、/my、/overview、/collective、/student/:studentNo、/exams、/ranking | [成绩与隐私](../app/grades.md),查询列表参数用 studentId,写入仍按科目 |
|
| /grades、/grades/bulk、/stats、/levels、/my、/overview、/collective、/student/:studentNo、/exams、/ranking | [成绩与隐私](../app/grades.md),查询列表参数用 studentId,写入仍按科目 |
|
||||||
| /imports/template、/table/preview、/table/commit | 表格导入,按 kind 再检查对应导入键、管理键、班级和科目 |
|
| /imports/template、/table/preview、/table/commit | 表格导入,按 kind 再检查对应导入键、管理键、班级和科目 |
|
||||||
| /imports/class-plan/preview、/imports/class-plan | 预览与提交均需 import:schedule + schedule:write;提交走关系化导入 |
|
| /imports/class-plan/preview、/imports/class-plan | 预览与提交均需 import:schedule + schedule:write;提交走关系化导入 |
|
||||||
|
| POST /imports/class-plan/yaml/preview、/imports/class-plan/yaml | YAML 预览/导入;同课表导入权限与班级范围,支持 all/odd/even 与 HHMMSS,提交复用完整档案事务 |
|
||||||
| /imports/time-layout[/:id]、/time-layout/preview | 时间配置兼容入口,导入需 import:schedule + timetable:manage,删除需 timetable:manage |
|
| /imports/time-layout[/:id]、/time-layout/preview | 时间配置兼容入口,导入需 import:schedule + timetable:manage,删除需 timetable:manage |
|
||||||
| GET /class-plans/profile?classId= | 完整档案导出,按班级范围读取,保留时间点与课表关联 |
|
| GET /class-plans/profile?classId= | 完整档案导出,按班级范围读取,保留时间点与课表关联 |
|
||||||
| GET /courseware、/courseware/:id、/:id/download | 课件目录/详情/下载;员工需 courseware:read,班级端按可见范围 |
|
| GET /courseware、/courseware/:id、/:id/download | 课件目录/详情/下载;员工需 courseware:read,班级端按可见范围 |
|
||||||
@@ -68,7 +69,7 @@ API 前缀 /api,JWT 使用 Authorization: Bearer。成功/失败结构以 `lib
|
|||||||
| /archives、/archives/transferred、/archives/transferred/:id/restore | 历史归档需 archive:manage 全校范围;撤回转出需 roster:manage;不提供手动创建归档 |
|
| /archives、/archives/transferred、/archives/transferred/:id/restore | 历史归档需 archive:manage 全校范围;撤回转出需 roster:manage;不提供手动创建归档 |
|
||||||
| /database/status、/test-connection、/backups、/export、/import、/sqlite-file、/backup-schedule、/switch | database:manage;目标空库、快照及换库子进程保护 |
|
| /database/status、/test-connection、/backups、/export、/import、/sqlite-file、/backup-schedule、/switch | database:manage;目标空库、快照及换库子进程保护 |
|
||||||
| /system/settings、/autostart、/diagnostics | system:manage,非安装形态自启动返回不可用原因 |
|
| /system/settings、/autostart、/diagnostics | system:manage,非安装形态自启动返回不可用原因 |
|
||||||
| /ai/settings、/interpret、/audit | ai:manage/ai:use;只解析待确认动作,密钥只进不出 |
|
| /ai/settings、/interpret、/audit、/capabilities、/plans/:id | ai:manage/ai:use;查询遵循业务权限,写入计划确认后调用原接口,密钥只进不出 |
|
||||||
| /dashboard/summary、/dashboard/term | 按范围读取看板与周次 |
|
| /dashboard/summary、/dashboard/term | 按范围读取看板与周次 |
|
||||||
|
|
||||||
探针 /healthz 和 /readyz 不带 API 前缀;/api/health 提供版本与模块详情。
|
探针 /healthz 和 /readyz 不带 API 前缀;/api/health 提供版本与模块详情。
|
||||||
@@ -117,3 +118,32 @@ API 前缀 /api,JWT 使用 Authorization: Bearer。成功/失败结构以 `lib
|
|||||||
成绩 overview/collective/exams/ranking 显式检查 grade:read,班级端由服务断言限本班并执行查询开关。设备 heartbeat/update-progress/commands/:id/ack 仅接受绑定本班的 CLASS_DEVICE,不接受教师个人设备。
|
成绩 overview/collective/exams/ranking 显式检查 grade:read,班级端由服务断言限本班并执行查询开关。设备 heartbeat/update-progress/commands/:id/ack 仅接受绑定本班的 CLASS_DEVICE,不接受教师个人设备。
|
||||||
|
|
||||||
`GET /permissions/me` 同时返回 classScopes、manageScopes、allScopeKeys,供 Web 按钮与班级选择器显示实际能力范围;manageScopes 对名单、日课表、导入和考试配置叠加班主任或显式组织范围规则。界面范围提示不替代服务端断言。
|
`GET /permissions/me` 同时返回 classScopes、manageScopes、allScopeKeys,供 Web 按钮与班级选择器显示实际能力范围;manageScopes 对名单、日课表、导入和考试配置叠加班主任或显式组织范围规则。界面范围提示不替代服务端断言。
|
||||||
|
|
||||||
|
## AI 操作计划
|
||||||
|
|
||||||
|
跨班作业与通知会归一为逐班步骤,分别调用单班业务接口。成功班级保持成功状态,后续重试跳过这些步骤。
|
||||||
|
|
||||||
|
客户端安装包缓存允许 `clients.releases` 查询,以及仅限 ADMIN + `client:update` 的 `clients.release-fetch/register/delete`。写入均要求专门确认,并核对版本、已有登记及缓存文件状态。更新模块只开放固定的 `/update/client/releases` 查询、`/update/client/fetch` 抓取、`/update/client/releases` 登记及按版本删除;没有服务器更新、配置或任意下载地址入口。抓取复用现有官方项目下载地址与流式校验,不推送或安装。
|
||||||
|
|
||||||
|
`POST /ai/interpret` 接收 `text`、可选班级、当前会话的 `messages` 和附件元数据 `attachments`,返回 `planId/message/steps/results`,并保留旧响应字段的兼容形状。附件包含 id、文件名、大小与 SHA256;普通课件内容不发送给模型。
|
||||||
|
|
||||||
|
`POST /ai/models` 仅管理员可用,接收可选 `baseUrl/apiKey`(未传时使用已保存配置),通过兼容 `/models` 获取模型及支持的推理档位,密钥不回传。设置增加 `reasoningEffort`:`auto/none/low/medium/high/max`,`auto` 不附加推理参数。
|
||||||
|
|
||||||
|
后台任务接口均要求 `ai:use`,并校验归属及实际业务权限:
|
||||||
|
|
||||||
|
- `POST /ai/tasks` 创建任务;`PUT /ai/tasks/:id/files/:attachmentId` 以二进制暂存已声明附件,校验大小与 SHA256,不发布课件。
|
||||||
|
- `POST /ai/tasks/:id/start` 提交后台规划,完整附件上传后才允许开始。
|
||||||
|
- `GET /ai/tasks` 列出本人最近任务;`GET /ai/tasks/:id` 读取状态并重新授权结果数据。
|
||||||
|
- `GET /ai/tasks/:id/events` 以 SSE 返回 `status/message/result/error`,关闭连接仅停止订阅,不取消任务。
|
||||||
|
- `POST /ai/tasks/:id/execute` 接收与计划确认相同的确认字段,后台逐步调用白名单业务接口,使用持久步骤去重。失败停止后续依赖项,重试不重做成功步骤。
|
||||||
|
- `POST /ai/tasks/:id/stop` 主动停止后台任务;已发出的业务请求可完成,后续步骤停止。
|
||||||
|
|
||||||
|
后台任务保存在 `AiTask`,输入、结果与进度加密,纳入快照并兼容旧快照缺表。助手页面统一使用后台任务接口。服务重启保留任务,未知业务执行结果须核对后继续。
|
||||||
|
|
||||||
|
- `GET /ai/capabilities`:当前操作者可用的动作及参数契约,目录不包含数据库维护、服务器运维和密钥操作。
|
||||||
|
- `GET /ai/plans/:id`:本人计划和分步状态;业务权限及范围重新校验。
|
||||||
|
- `POST /ai/plans/:id/prepare`:结构化附件经哈希核对后复用原导入解析器生成预览,不发布业务数据。
|
||||||
|
- `POST /ai/plans/:id/confirm`:提交明确确认、必要的高影响操作确认和专用敏感字段;返回绑定后的业务请求。
|
||||||
|
- `DELETE /ai/plans/:id`:取消尚未执行的步骤。
|
||||||
|
|
||||||
|
前端以 `x-classhelper-ai-step` 关联既有业务接口。服务端核对操作者、方法、路径、查询和正文后原子领取步骤,再由原接口执行完整鉴权。上传另核对文件哈希;已成功步骤返回保存的结果,不重复操作。连接中断或结果不明的步骤需先核对业务状态。自动化入口为 `pnpm verify:ai`,仅使用隔离库和模型 stub。
|
||||||
@@ -71,6 +71,7 @@ gh release upload v<版本> <三个已按上传名暂存的EXE> releases/SHA256S
|
|||||||
推送 v* tag 触发 release-linux-server.yml,按 tag 检出,在 Ubuntu 构建并上传 Linux 包、独立 .sha256,合并跨组件清单。
|
推送 v* tag 触发 release-linux-server.yml,按 tag 检出,在 Ubuntu 构建并上传 Linux 包、独立 .sha256,合并跨组件清单。
|
||||||
等待 Actions 成功,再下载 Linux 文件和最终 SHA256SUMS 同步回本地;检查清单的 Windows 行仍与本次文件一致。
|
等待 Actions 成功,再下载 Linux 文件和最终 SHA256SUMS 同步回本地;检查清单的 Windows 行仍与本次文件一致。
|
||||||
如需重跑,可手动运行该 workflow,指定准确 tag 和 attach=true。master 修复不会自动改变旧 tag 指向。
|
如需重跑,可手动运行该 workflow,指定准确 tag 和 attach=true。master 修复不会自动改变旧 tag 指向。
|
||||||
|
用户明确要求同版本更新远端服务端资产时,可额外指定 `source_ref` 为经过验证的完整提交 SHA;版本仍须与目标 tag 一致。保留原标签,在发布说明注明服务端重建提交及客户端沿用原批次,更新两个平台的服务端包与摘要。
|
||||||
|
|
||||||
官网和文档站由 pages.yml 拼装同一个站点:官网根、文档 /docs/。文档版本徽标读根 package.json,
|
官网和文档站由 pages.yml 拼装同一个站点:官网根、文档 /docs/。文档版本徽标读根 package.json,
|
||||||
官网和下载页兜底版本由 version 脚本维护。Linux workflow 与 Pages 是独立流水线,分别确认结果。
|
官网和下载页兜底版本由 version 脚本维护。Linux workflow 与 Pages 是独立流水线,分别确认结果。
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ description: 本地经典/自定义岛的几何、外观与动画入口。
|
|||||||
## 经典几何与外观
|
## 经典几何与外观
|
||||||
|
|
||||||
| 来源 | 内容 |
|
| 来源 | 内容 |
|
||||||
| ---------------------------------------------------- | ----------------------------------------------------- |
|
| ---------------------------------------------------- | --------------------------------------------------------------------- |
|
||||||
| shared/src/constants.ts 的 DEFAULT_ISLAND_APPEARANCE | 默认宽 268、高 44、圆角 20、字号 13、边距 8,顶部居中 |
|
| shared/src/constants.ts 的 DEFAULT_ISLAND_APPEARANCE | 默认宽 268、高 44、圆角 20、字号 13、边距 8,顶部居中 |
|
||||||
|
| shared/src/constants.ts 的 CLASSISLAND_TOKENS | 岛层颜色、字体、字号、圆角、间距、阴影、层级与 DPI 的 TypeScript 来源 |
|
||||||
| ISLAND_APPEARANCE_RANGES | 滑块与主进程归一化共用的范围 |
|
| ISLAND_APPEARANCE_RANGES | 滑块与主进程归一化共用的范围 |
|
||||||
| ISLAND_SIZE_DELTA | 展开、紧急与叫人相对尺寸 |
|
| ISLAND_SIZE_DELTA | 展开、紧急与叫人相对尺寸 |
|
||||||
| ISLAND_SHADOW_PAD | 窗口边界的透明留白 |
|
| ISLAND_SHADOW_PAD | 窗口边界的透明留白 |
|
||||||
| ISLAND_LIST_METRICS / islandListLayout | 主进程和渲染层共用列表度量,控制行数与工作区高度 |
|
| ISLAND_LIST_METRICS / islandListLayout | 主进程和渲染层共用列表度量,控制行数与工作区高度 |
|
||||||
| desktop-client/src/island/squircle.ts | 超椭圆路径 |
|
| desktop-client/src/island/squircle.ts | 超椭圆路径 |
|
||||||
| desktop-client/src/island/classic-island.css | 经典底色、文字、图形与状态样式 |
|
| desktop-client/src/island/classic-island.css | 经典底色、文字、图形与状态样式 |
|
||||||
|
| ui/src/tokens.css | `--ci-*` 亮/暗两套 CSS 变量,以及五级文字工具类 |
|
||||||
|
|
||||||
classic 的 black/glass/tinted 是本地 CSS 外观;glass 使用半透明色,不采样桌面模糊。
|
classic 的 black/glass/tinted 是本地 CSS 外观;glass 使用半透明色,不采样桌面模糊。
|
||||||
不要对透明岛调用 setBackgroundMaterial:系统材质作用于整窗矩形,可能破坏逐像素透明。
|
不要对透明岛调用 setBackgroundMaterial:系统材质作用于整窗矩形,可能破坏逐像素透明。
|
||||||
@@ -41,6 +43,47 @@ CLASSISLAND_ISLAND_METRICS 位于 shared/src/island-layout.ts:
|
|||||||
方案有常态 rows 和无通知展开 expandedRows,运行时由 CustomIslandRuntime.vue 测量自然内容,
|
方案有常态 rows 和无通知展开 expandedRows,运行时由 CustomIslandRuntime.vue 测量自然内容,
|
||||||
再按屏幕工作区与方案缩放适配。字体与外观覆盖按组件契约生效,不能拿经典固定宽高解释自定义内容尺寸。
|
再按屏幕工作区与方案缩放适配。字体与外观覆盖按组件契约生效,不能拿经典固定宽高解释自定义内容尺寸。
|
||||||
|
|
||||||
|
自定义岛默认使用 CSS `border-radius`;经典岛继续保留连续圆角。圆角同时作用于自绘背景与内容裁切,
|
||||||
|
默认 8px、范围 0–20px、步进 0.5px。背景色只通过 `--resident-background` 派生,背景 alpha 与整行
|
||||||
|
`opacity` 分开计算,避免整行不透明度连带淡化投影和覆盖层。
|
||||||
|
|
||||||
|
### ClassIsland token 层
|
||||||
|
|
||||||
|
`CLASSISLAND_TOKENS` 与 `--ci-*` 一一对应,应用外壳继续使用 `--ch-*` / `--ch-ui-*`。
|
||||||
|
ClassIsland 源值中的颜色采用 Avalonia `AARRGGBB`,写入 CSS 时统一转换为
|
||||||
|
`RRGGBBAA`,alpha 数值不变。
|
||||||
|
|
||||||
|
| 类别 | 关键值 |
|
||||||
|
| -------- | ------------------------------------------------------------------------ |
|
||||||
|
| 强调色 | PrimaryColor / DeepSkyBlue、SecondaryColor / Aquamarine、DodgerBlue 兜底 |
|
||||||
|
| 五级前景 | 100% / 85.5% / 77.3% / 52.9% / 36.5%,开启自定义前景时写进颜色 alpha |
|
||||||
|
| 四档字号 | 14 / 16 / 18 / 20px,设置范围 1–40px,步进 0.5px |
|
||||||
|
| 字重 | 100–900 逐值映射,默认 500;其他值回落 400 |
|
||||||
|
| 圆角 | 岛 8、弹窗 6、卡片与控件 4、抽屉 8 8 0 0、胶囊 999px |
|
||||||
|
| 间距 | 行高 40、左右 12、组件间距 12、行距 5、进度条 3px |
|
||||||
|
| 层级 | 遮罩/拖拽 1、抽屉 10、时间轴装饰 9999、哨兵 2147483647 |
|
||||||
|
| DPI | 96 DPI 基准、缩放 0.75–2.5、Fluent 竖直安全区 20px |
|
||||||
|
|
||||||
|
四档字号可写在组件自身、单个行或方案根元素。行级与组件级都通过 CSS 变量覆盖;关闭覆盖时删除
|
||||||
|
对应内联变量并回落到方案或 `:root`。自定义前景关闭时同样删除行内五级变量,由 `html.dark` 切换
|
||||||
|
主题默认值。
|
||||||
|
|
||||||
|
强调色来源严格区分自定义、壁纸调色板、跟随系统与屏幕调色板;主进程输出 `resolvedAccent`,设置页
|
||||||
|
仍保留用户选择的 `accent`,避免切换来源时覆盖原自定义色。主题切换通过岛桥接的 `island:theme`
|
||||||
|
事件实时同步 `html.dark`,不依赖主窗口的 DOM。
|
||||||
|
|
||||||
|
### 主界面对照
|
||||||
|
|
||||||
|
| ClassIsland 概念 | ClassHelper 实体 |
|
||||||
|
| ----------------------- | ------------------------------------------------------------------ |
|
||||||
|
| MainWindow | 独立 `island.html` + 主进程透明 `BrowserWindow` |
|
||||||
|
| MainWindowLine | `CustomIslandRuntime.vue` 的 `.layout-row` 与行级 CSS 变量 |
|
||||||
|
| ComponentPresenter | `ComponentNode.vue` 根节点的宽高、透明度、隐藏与裁剪 |
|
||||||
|
| 日期/时钟/天气/课程组件 | `ComponentNode.vue`、`WeatherBrief.vue` 等共享组件 |
|
||||||
|
| Fluent/Classic 主题 | `custom-runtime.css` / `custom-island.css` / `classic-island.css` |
|
||||||
|
| 编辑模式视图 | 主窗口 `IslandEditorView.vue`、`IslandEditorNode.vue` 与右侧检查器 |
|
||||||
|
| 提醒宿主 | `ClassicNotifications.vue`,嵌入自定义岛或经典岛 |
|
||||||
|
|
||||||
## 动画与命中
|
## 动画与命中
|
||||||
|
|
||||||
经典与自定义岛的形变都使用 src/island/spring.ts 的 SpringValue;默认 stiffness=0.10、damping=0.68,
|
经典与自定义岛的形变都使用 src/island/spring.ts 的 SpringValue;默认 stiffness=0.10、damping=0.68,
|
||||||
@@ -56,4 +99,5 @@ CLASSISLAND_ISLAND_METRICS 位于 shared/src/island-layout.ts:
|
|||||||
|
|
||||||
外观范围改 shared,经典样式改 classic-island.css,自定义样式改 custom-runtime.css 和 custom-island.css,
|
外观范围改 shared,经典样式改 classic-island.css,自定义样式改 custom-runtime.css 和 custom-island.css,
|
||||||
原生窗口与命中改 main/island.ts。组件结构/设置改 shared/island-layout.ts 并同步编辑器和运行时。
|
原生窗口与命中改 main/island.ts。组件结构/设置改 shared/island-layout.ts 并同步编辑器和运行时。
|
||||||
|
改 token 后运行 `pnpm check:design-tokens`,它会校验亮/暗键集合、必备 token、kebab-case 与岛内裸颜色。
|
||||||
展示行为见[灵动岛](../app/island.md),测试见[验收与测试](testing.md)。
|
展示行为见[灵动岛](../app/island.md),测试见[验收与测试](testing.md)。
|
||||||
@@ -308,7 +308,7 @@ pnpm --filter @classhelper/server start # 或 node packages/server/dist/ind
|
|||||||
## 五、环境变量清单
|
## 五、环境变量清单
|
||||||
|
|
||||||
| 变量 | 默认 | 说明 |
|
| 变量 | 默认 | 说明 |
|
||||||
| --------------------------------------------------- | ---------------------- | ----------------------------------------------------------- |
|
| --------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------- |
|
||||||
| `NODE_ENV` | `development` | `production` 会启用生产校验、HSTS、更严的限流 |
|
| `NODE_ENV` | `development` | `production` 会启用生产校验、HSTS、更严的限流 |
|
||||||
| `HOST` / `PORT` | `0.0.0.0` / `4000` | 监听地址与端口 |
|
| `HOST` / `PORT` | `0.0.0.0` / `4000` | 监听地址与端口 |
|
||||||
| `DATABASE_PROVIDER` | `sqlite` | `sqlite` 或 `mysql` |
|
| `DATABASE_PROVIDER` | `sqlite` | `sqlite` 或 `mysql` |
|
||||||
@@ -318,7 +318,7 @@ pnpm --filter @classhelper/server start # 或 node packages/server/dist/ind
|
|||||||
| `JWT_EXPIRES_IN` | `7d` | 令牌有效期 |
|
| `JWT_EXPIRES_IN` | `7d` | 令牌有效期 |
|
||||||
| `CORS_ORIGIN` | `*` | 允许来源,多个用逗号分隔;生产建议写具体域名 |
|
| `CORS_ORIGIN` | `*` | 允许来源,多个用逗号分隔;生产建议写具体域名 |
|
||||||
| `TRUST_PROXY` | `false` | 反向代理层数(Nginx 填 `1`),影响限流与日志中的真实 IP |
|
| `TRUST_PROXY` | `false` | 反向代理层数(Nginx 填 `1`),影响限流与日志中的真实 IP |
|
||||||
| `RATE_LIMIT_ENABLED` | `true` | 通用限流(生产 600 次/5 分钟)+ 登录限流(20 次/10 分钟) |
|
| `RATE_LIMIT_ENABLED` | `true` | 通用限流(生产 600 次/5 分钟);同一来源 IP 连续五次登录失败后封禁 5 分钟,成功登录清零,两种登录入口共用计数 |
|
||||||
| `STARTUP_DB_CHECK` | `true` | 启动校验数据库;生产不可用时直接退出 |
|
| `STARTUP_DB_CHECK` | `true` | 启动校验数据库;生产不可用时直接退出 |
|
||||||
| `PID_FILE` | — | PID 文件路径(安装包启停脚本依赖),相对 `server` 根 |
|
| `PID_FILE` | — | PID 文件路径(安装包启停脚本依赖),相对 `server` 根 |
|
||||||
| `WEB_DIST_DIR` | 自动探测 | Web 管理端产物目录(`../web-admin/dist` 或 `./web`) |
|
| `WEB_DIST_DIR` | 自动探测 | Web 管理端产物目录(`../web-admin/dist` 或 `./web`) |
|
||||||
|
|||||||
@@ -18,17 +18,11 @@ description: 检查更新与各形态的升级步骤、Linux 的升级回滚链
|
|||||||
## 检查更新
|
## 检查更新
|
||||||
|
|
||||||
| 端 | 入口 | 检查路径 |
|
| 端 | 入口 | 检查路径 |
|
||||||
| ------------------- | --------------------------------------------------------------- | ------------------------------------------------ |
|
| ------------------- | ---------------------------------------------- | ------------------------------------------------ |
|
||||||
| 服务端 / Web 管理端 | 顶栏用户菜单 →「检查更新」 | 浏览器 → 服务端 `GET /api/update/check` → GitHub |
|
| 服务端 / Web 管理端 | 顶栏用户菜单 →「检查更新」 | 浏览器 → 服务端 `GET /api/update/check` → GitHub |
|
||||||
| 桌面客户端 | 启动后自动一次(延迟 5 秒)+「设置 → 关于」里的「检查更新」按钮 | 主进程 → GitHub(不经后端) |
|
| 桌面客户端 | 管理端「客户端管理」登记安装包并向班级下发更新 | 客户端只从当前服务端领取更新策略与安装包 |
|
||||||
|
|
||||||
两端的路径不同是**被约束逼出来的**:
|
Web 管理端经服务端查询 GitHub Release。客户端不再主动检查 GitHub,也不提供手动检查入口;更新由管理端统一下发,仍校验 SHA256 并遵循本机自动更新开关和服务端策略。
|
||||||
|
|
||||||
- **Web 端不能直连 GitHub**。服务端下发的 CSP 里 `connect-src` 只放行 `'self'` 与 WebSocket,
|
|
||||||
浏览器发往 `api.github.com` 的请求会直接被拦掉。走服务端转发还有个好处:所有管理员共享同一份缓存
|
|
||||||
(GitHub 匿名限流是 60 次/小时/IP)。
|
|
||||||
- **客户端在主进程做**。渲染进程的 CSP 与导航防线是安全模型里最要紧的一层,
|
|
||||||
不让它去连外部域名、解析外部 JSON。
|
|
||||||
|
|
||||||
### "查不到"是设计内的结果
|
### "查不到"是设计内的结果
|
||||||
|
|
||||||
@@ -39,12 +33,11 @@ description: 检查更新与各形态的升级步骤、Linux 的升级回滚链
|
|||||||
失败结果同样进缓存 —— 否则断网时每点一次按钮都要白等一个超时。
|
失败结果同样进缓存 —— 否则断网时每点一次按钮都要白等一个超时。
|
||||||
|
|
||||||
| 细节 | 说明 |
|
| 细节 | 说明 |
|
||||||
| ---------- | ----------------------------------------------------------------------------------------------------- |
|
| ---- | ----------------------------------------------------------------------------------------------------- |
|
||||||
| 缓存 | 两端各缓存 30 分钟;`?force=1` 绕过服务端缓存,但**仅管理员生效**(否则任意登录用户都能刷爆匿名限流) |
|
| 缓存 | 服务端缓存 30 分钟;`?force=1` 绕过服务端缓存,但**仅管理员生效**(否则任意登录用户都能刷爆匿名限流) |
|
||||||
| 权限 | 任何已登录用户都能查(信息来自公开仓库);`force` 除外 |
|
| 权限 | 任何已登录用户都能查(信息来自公开仓库);`force` 除外 |
|
||||||
| 只提示一次 | 客户端启动检查发现新版才推提示;点「忽略此版本」记进配置,同一版本不再提示 |
|
|
||||||
|
|
||||||
更新**只提示,不自动下载、不自动安装**。安装包仍由人从 [Releases](https://github.com/LoveChengke/classhelper/releases)
|
服务端的更新检查只提示,不自动安装。管理员可从 [Releases](https://github.com/LoveChengke/classhelper/releases)
|
||||||
页面取,可用 `SHA256SUMS-<版本>.txt` 核对。
|
页面取,可用 `SHA256SUMS-<版本>.txt` 核对。
|
||||||
|
|
||||||
## 升级步骤
|
## 升级步骤
|
||||||
|
|||||||
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 69 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "class-helper",
|
"name": "class-helper",
|
||||||
"version": "1.4.3",
|
"version": "1.4.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "ClassHelper - 班级信息管理系统(Web 管理端 + 后端服务 + 桌面客户端)",
|
"description": "ClassHelper - 班级信息管理系统(Web 管理端 + 后端服务 + 桌面客户端)",
|
||||||
"packageManager": "pnpm@11.8.0",
|
"packageManager": "pnpm@11.8.0",
|
||||||
@@ -16,8 +16,9 @@
|
|||||||
"build": "pnpm build:shared && pnpm --filter @classhelper/server build && pnpm --filter @classhelper/web-admin build && pnpm --filter @classhelper/desktop-client build",
|
"build": "pnpm build:shared && pnpm --filter @classhelper/server build && pnpm --filter @classhelper/web-admin build && pnpm --filter @classhelper/desktop-client build",
|
||||||
"build:desktop": "pnpm build:shared && pnpm --filter @classhelper/desktop-client build",
|
"build:desktop": "pnpm build:shared && pnpm --filter @classhelper/desktop-client build",
|
||||||
"check:icons": "node scripts/check-icons.mjs",
|
"check:icons": "node scripts/check-icons.mjs",
|
||||||
|
"check:design-tokens": "node scripts/check-design-tokens.mjs",
|
||||||
"typecheck": "pnpm build:shared && pnpm -r --workspace-concurrency=1 --no-bail typecheck",
|
"typecheck": "pnpm build:shared && pnpm -r --workspace-concurrency=1 --no-bail typecheck",
|
||||||
"lint": "node scripts/check-authz.mjs && eslint .",
|
"lint": "node scripts/check-authz.mjs && node scripts/check-design-tokens.mjs && eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"format": "prettier --write \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
|
"format": "prettier --write \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
|
||||||
"format:check": "prettier --check \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
|
"format:check": "prettier --check \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
"db:switch:mysql": "node scripts/use-database.mjs mysql",
|
"db:switch:mysql": "node scripts/use-database.mjs mysql",
|
||||||
"db:switch:sqlite": "node scripts/use-database.mjs sqlite",
|
"db:switch:sqlite": "node scripts/use-database.mjs sqlite",
|
||||||
"verify:e2e": "node scripts/verify-e2e-isolated.mjs",
|
"verify:e2e": "node scripts/verify-e2e-isolated.mjs",
|
||||||
|
"verify:ai": "node scripts/verify-ai.mjs",
|
||||||
"verify:courseware": "node scripts/verify-courseware.mjs",
|
"verify:courseware": "node scripts/verify-courseware.mjs",
|
||||||
"verify:v14": "node scripts/verify-v14.mjs",
|
"verify:v14": "node scripts/verify-v14.mjs",
|
||||||
"verify:lifecycle": "node scripts/verify-lifecycle.mjs",
|
"verify:lifecycle": "node scripts/verify-lifecycle.mjs",
|
||||||
@@ -37,6 +39,8 @@
|
|||||||
"verify:update-installer": "node scripts/verify-update-installer.mjs",
|
"verify:update-installer": "node scripts/verify-update-installer.mjs",
|
||||||
"verify:client-update:real": "node scripts/verify-client-update-real.mjs --real-install",
|
"verify:client-update:real": "node scripts/verify-client-update-real.mjs --real-install",
|
||||||
"verify:review-client": "node scripts/verify-review-client.mjs",
|
"verify:review-client": "node scripts/verify-review-client.mjs",
|
||||||
|
"verify:panel-security": "node scripts/verify-panel-security.mjs",
|
||||||
|
"verify:island-editor": "node scripts/verify-island-editor.mjs",
|
||||||
"verify:review-api": "node scripts/verify-e2e-isolated.mjs --review-api",
|
"verify:review-api": "node scripts/verify-e2e-isolated.mjs --review-api",
|
||||||
"verify:clients-api": "node scripts/verify-e2e-isolated.mjs --clients-api",
|
"verify:clients-api": "node scripts/verify-e2e-isolated.mjs --clients-api",
|
||||||
"verify:client-migrations": "node scripts/verify-client-migrations.mjs",
|
"verify:client-migrations": "node scripts/verify-client-migrations.mjs",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@classhelper/desktop-client",
|
"name": "@classhelper/desktop-client",
|
||||||
"version": "1.4.3",
|
"version": "1.4.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "ClassHelper EXE 客户端(Electron + Vue 3 + Element Plus + Socket.IO + IndexedDB 离线缓存)",
|
"description": "ClassHelper EXE 客户端(Electron + Vue 3 + Element Plus + Socket.IO + IndexedDB 离线缓存)",
|
||||||
"author": "Class Helper",
|
"author": "Class Helper",
|
||||||
@@ -24,7 +24,8 @@
|
|||||||
"pinia": "^4.0.3",
|
"pinia": "^4.0.3",
|
||||||
"socket.io-client": "^4.8.3",
|
"socket.io-client": "^4.8.3",
|
||||||
"vue": "^3.5.42",
|
"vue": "^3.5.42",
|
||||||
"vue-router": "^5.3.1"
|
"vue-router": "^5.3.1",
|
||||||
|
"@classhelper/ui": "workspace:*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.20.2",
|
"@types/node": "^22.20.2",
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ function launchSmoke(extraEnv) {
|
|||||||
child.kill();
|
child.kill();
|
||||||
resolve(124);
|
resolve(124);
|
||||||
},
|
},
|
||||||
// 快速套件已包含本地 HTTP、校验下载和布局编辑;保留冷启动余量,单项断言不放宽。
|
// 快速套件包含两种布局的完整上下课时序、本地下载和编辑;总时限保留冷启动余量。
|
||||||
mode === 'visual' ? 360_000 : 90_000,
|
mode === 'visual' ? 360_000 : 120_000,
|
||||||
);
|
);
|
||||||
child.once('exit', (code) => {
|
child.once('exit', (code) => {
|
||||||
clearTimeout(deadline);
|
clearTimeout(deadline);
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ const current = computed(() => today.value.find((s) => s.id === status.value.cur
|
|||||||
const next = computed(() => today.value.find((s) => s.id === status.value.next?.scheduleId));
|
const next = computed(() => today.value.find((s) => s.id === status.value.next?.scheduleId));
|
||||||
function timeAt(time: string) {
|
function timeAt(time: string) {
|
||||||
const d = new Date(props.now);
|
const d = new Date(props.now);
|
||||||
const [h, m] = time.split(':').map(Number);
|
const [h, m, s = 0] = time.split(':').map(Number);
|
||||||
d.setHours(h!, m!, 0, 0);
|
d.setHours(h!, m!, s, 0);
|
||||||
return d.getTime();
|
return d.getTime();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -106,6 +106,7 @@ const remaining = computed(() =>
|
|||||||
currentLesson.value ? Math.max(0, Math.ceil((timeAt(currentLesson.value.endTime) - props.now) / 1000)) : 0,
|
currentLesson.value ? Math.max(0, Math.ceil((timeAt(currentLesson.value.endTime) - props.now) / 1000)) : 0,
|
||||||
);
|
);
|
||||||
const hidden = computed(
|
const hidden = computed(
|
||||||
|
// 临近下课仍使用真实时间点,不因提醒切换而替换课程组件。
|
||||||
() =>
|
() =>
|
||||||
!props.editing &&
|
!props.editing &&
|
||||||
((['notification', 'homework', 'call'].includes(props.node.kind) &&
|
((['notification', 'homework', 'call'].includes(props.node.kind) &&
|
||||||
@@ -179,11 +180,18 @@ const style = computed<CSSProperties>(() => {
|
|||||||
const n = props.node,
|
const n = props.node,
|
||||||
a = n.appearance,
|
a = n.appearance,
|
||||||
override = a.resourceOverridingEnabled;
|
override = a.resourceOverridingEnabled;
|
||||||
const color =
|
const alpha = a.customBackgroundOpacityEnabled ? a.backgroundOpacity : 1;
|
||||||
a.background +
|
const color = `color-mix(in srgb, ${a.background} ${alpha * 100}%, transparent)`;
|
||||||
Math.round((a.customBackgroundOpacityEnabled ? a.backgroundOpacity : 1) * 255)
|
const customText: Record<string, string> =
|
||||||
.toString(16)
|
override && a.customForegroundEnabled
|
||||||
.padStart(2, '0');
|
? {
|
||||||
|
'--ci-text-1': a.foreground,
|
||||||
|
'--ci-text-2': `color-mix(in srgb, ${a.foreground} 85.5%, transparent)`,
|
||||||
|
'--ci-text-3': `color-mix(in srgb, ${a.foreground} 77.3%, transparent)`,
|
||||||
|
'--ci-text-4': `color-mix(in srgb, ${a.foreground} 52.9%, transparent)`,
|
||||||
|
'--ci-text-5': `color-mix(in srgb, ${a.foreground} 36.5%, transparent)`,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
return {
|
return {
|
||||||
opacity: a.opacity,
|
opacity: a.opacity,
|
||||||
width: n.advanced.width ? `${n.advanced.width}px` : undefined,
|
width: n.advanced.width ? `${n.advanced.width}px` : undefined,
|
||||||
@@ -194,17 +202,19 @@ const style = computed<CSSProperties>(() => {
|
|||||||
n.advanced.align
|
n.advanced.align
|
||||||
],
|
],
|
||||||
textAlign: n.advanced.align === 'start' ? 'start' : n.advanced.align === 'end' ? 'end' : 'center',
|
textAlign: n.advanced.align === 'start' ? 'start' : n.advanced.align === 'end' ? 'end' : 'center',
|
||||||
color: override && a.customForegroundEnabled ? a.foreground : undefined,
|
color: 'var(--ci-text-1)',
|
||||||
background: override && a.customBackgroundEnabled ? color : undefined,
|
background: override && a.customBackgroundEnabled ? color : undefined,
|
||||||
borderRadius: override && a.customCornerRadiusEnabled ? `${a.cornerRadius}px` : undefined,
|
borderRadius: override && a.customCornerRadiusEnabled ? `${a.cornerRadius}px` : undefined,
|
||||||
fontSize: override ? `${a.bodyFontSize}px` : undefined,
|
fontSize: override ? `${a.bodyFontSize}px` : undefined,
|
||||||
'--secondary': override ? `${a.secondaryFontSize}px` : undefined,
|
'--ci-fs-secondary': override ? `${a.secondaryFontSize}px` : undefined,
|
||||||
'--emphasized': override ? `${a.emphasizedFontSize}px` : undefined,
|
'--ci-fs-body': override ? `${a.bodyFontSize}px` : undefined,
|
||||||
'--large': override ? `${a.largeFontSize}px` : undefined,
|
'--ci-fs-emphasized': override ? `${a.emphasizedFontSize}px` : undefined,
|
||||||
|
'--ci-fs-large': override ? `${a.largeFontSize}px` : undefined,
|
||||||
'--rolling-duration': `${Math.max(1, 200 / n.settings.speed)}s`,
|
'--rolling-duration': `${Math.max(1, 200 / n.settings.speed)}s`,
|
||||||
flexDirection: container.value ? (n.settings.direction === 'vertical' ? 'column' : 'row') : undefined,
|
flexDirection: container.value ? (n.settings.direction === 'vertical' ? 'column' : 'row') : undefined,
|
||||||
gap: container.value ? `${n.settings.gap}px` : undefined,
|
gap: container.value ? `${n.settings.gap}px` : undefined,
|
||||||
display: container.value ? 'flex' : undefined,
|
display: container.value ? 'flex' : undefined,
|
||||||
|
...customText,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -256,6 +266,13 @@ const style = computed<CSSProperties>(() => {
|
|||||||
:class="{ current: p.id === currentPoint?.id, break: p.timeType === 'BREAK' }"
|
:class="{ current: p.id === currentPoint?.id, break: p.timeType === 'BREAK' }"
|
||||||
>
|
>
|
||||||
<strong>{{ p.courseName || p.name || '—' }}</strong>
|
<strong>{{ p.courseName || p.name || '—' }}</strong>
|
||||||
|
<span
|
||||||
|
v-if="p.id === currentLesson?.id && state.lessonReminder?.kind === 'ending' && remaining > 0"
|
||||||
|
class="lesson-ending-badge"
|
||||||
|
:aria-label="`距下课${remaining}秒`"
|
||||||
|
>
|
||||||
|
-{{ remaining }}
|
||||||
|
</span>
|
||||||
<small v-if="p.id === currentPoint?.id && node.settings.showPeriod" class="lesson-time">
|
<small v-if="p.id === currentPoint?.id && node.settings.showPeriod" class="lesson-time">
|
||||||
{{ p.startTime }}–{{ p.endTime }}
|
{{ p.startTime }}–{{ p.endTime }}
|
||||||
</small>
|
</small>
|
||||||
@@ -290,9 +307,10 @@ const style = computed<CSSProperties>(() => {
|
|||||||
padding: 6px;
|
padding: 6px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
color: var(--ci-text-1);
|
||||||
}
|
}
|
||||||
.component-node:not(.node-editing) {
|
.component-node:not(.node-editing) {
|
||||||
line-height: 1.4;
|
line-height: var(--ci-line-height-body);
|
||||||
}
|
}
|
||||||
.clock {
|
.clock {
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
@@ -308,7 +326,7 @@ const style = computed<CSSProperties>(() => {
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 6px;
|
gap: calc(var(--ci-component-gap) / 2);
|
||||||
padding-bottom: 3px;
|
padding-bottom: 3px;
|
||||||
}
|
}
|
||||||
.lesson-line strong {
|
.lesson-line strong {
|
||||||
@@ -318,10 +336,10 @@ const style = computed<CSSProperties>(() => {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.lesson-line.current strong {
|
.lesson-line.current strong {
|
||||||
color: #fff;
|
color: var(--ci-text-1);
|
||||||
}
|
}
|
||||||
.lesson-line.break {
|
.lesson-line.break {
|
||||||
opacity: 0.86;
|
color: var(--ci-text-3);
|
||||||
}
|
}
|
||||||
.time-divider {
|
.time-divider {
|
||||||
display: block;
|
display: block;
|
||||||
@@ -336,24 +354,29 @@ const style = computed<CSSProperties>(() => {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
color: var(--ci-text-3);
|
||||||
|
font-size: var(--ci-fs-secondary);
|
||||||
}
|
}
|
||||||
.lesson-progress {
|
.lesson-progress {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: auto 0 0;
|
inset: auto 0 0;
|
||||||
height: 2px;
|
height: var(--ci-progress-height);
|
||||||
background: #ffffff24;
|
background: var(--ci-fill-strong);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 1px;
|
border-radius: calc(var(--ci-progress-height) / 3);
|
||||||
}
|
}
|
||||||
.lesson-progress i {
|
.lesson-progress i {
|
||||||
display: block;
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: var(--island-accent, #60a5fa);
|
background: var(--island-accent, var(--ci-accent));
|
||||||
transform-origin: left;
|
transform-origin: left;
|
||||||
transition: transform 1s linear;
|
transition: transform 1s linear;
|
||||||
}
|
}
|
||||||
.schedule > .lesson-line + .lesson-line {
|
.schedule {
|
||||||
margin-top: 8px;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
.separator > span {
|
.separator > span {
|
||||||
display: block;
|
display: block;
|
||||||
@@ -380,28 +403,26 @@ const style = computed<CSSProperties>(() => {
|
|||||||
animation: none;
|
animation: none;
|
||||||
}
|
}
|
||||||
.selected {
|
.selected {
|
||||||
outline: 2px solid #85aaff;
|
outline: 2px solid var(--ci-stroke-drag);
|
||||||
border-radius: 8px;
|
border-radius: var(--ci-radius-island);
|
||||||
background: #759cff14;
|
background: var(--ci-accent-fill-tertiary);
|
||||||
}
|
}
|
||||||
.node-handle {
|
.node-handle {
|
||||||
touch-action: none;
|
touch-action: none;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
display: block;
|
display: block;
|
||||||
font:
|
font: var(--ci-fw-normal) var(--ci-fs-version) / 1.2 var(--ci-font);
|
||||||
10px 'Microsoft YaHei',
|
|
||||||
sans-serif;
|
|
||||||
padding: 3px 6px;
|
padding: 3px 6px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 4px;
|
border-radius: var(--ci-radius-control);
|
||||||
min-height: 24px;
|
min-height: 24px;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
color: #ffffff80;
|
color: var(--ci-text-3);
|
||||||
background: #ffffff0d;
|
background: var(--ci-fill-secondary);
|
||||||
}
|
}
|
||||||
.node-handle:hover {
|
.node-handle:hover {
|
||||||
background: #ffffff20;
|
background: var(--ci-accent-soft);
|
||||||
color: #fff;
|
color: var(--ci-text-1);
|
||||||
}
|
}
|
||||||
.notification,
|
.notification,
|
||||||
.homework,
|
.homework,
|
||||||
@@ -418,19 +439,19 @@ const style = computed<CSSProperties>(() => {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.node-editing:hover {
|
.node-editing:hover {
|
||||||
box-shadow: inset 0 0 0 1px #ffffff28;
|
box-shadow: inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-control);
|
||||||
border-radius: 8px;
|
border-radius: var(--ci-radius-island);
|
||||||
}
|
}
|
||||||
small {
|
small {
|
||||||
font-size: var(--secondary, 12px);
|
color: var(--ci-text-3);
|
||||||
opacity: 0.7;
|
font-size: var(--ci-fs-secondary);
|
||||||
}
|
}
|
||||||
strong,
|
strong,
|
||||||
.emphasized {
|
.emphasized {
|
||||||
font-size: var(--emphasized, 20px);
|
font-size: var(--ci-fs-emphasized);
|
||||||
}
|
}
|
||||||
.large {
|
.large {
|
||||||
font-size: var(--large, 28px);
|
font-size: var(--ci-fs-large);
|
||||||
}
|
}
|
||||||
@keyframes rolling {
|
@keyframes rolling {
|
||||||
from {
|
from {
|
||||||
@@ -441,3 +462,4 @@ strong,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<style src="./lesson-ending.css"></style>
|
||||||
@@ -20,7 +20,8 @@ const style = computed(() => {
|
|||||||
: position.endsWith('right')
|
: position.endsWith('right')
|
||||||
? { right: `${ISLAND_SHADOW_PAD}px` }
|
? { right: `${ISLAND_SHADOW_PAD}px` }
|
||||||
: { left: '50%', transform: 'translateX(-50%)' }),
|
: { left: '50%', transform: 'translateX(-50%)' }),
|
||||||
'--transfer-accent': props.appearance.accent,
|
'--ci-accent': props.appearance.resolvedAccent ?? props.appearance.accent,
|
||||||
|
'--transfer-accent': 'var(--ci-accent)',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const status = computed(
|
const status = computed(
|
||||||
@@ -68,15 +69,12 @@ onUnmounted(() => window.removeEventListener('resize', report));
|
|||||||
.courseware-transfer {
|
.courseware-transfer {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 17px 24px;
|
padding: calc(var(--ci-popup-pad) + var(--ci-line-gap)) calc(var(--ci-popup-pad) * 2);
|
||||||
border-radius: 24px;
|
border-radius: var(--ci-radius-oobe-btn);
|
||||||
color: white;
|
color: var(--ci-text-1);
|
||||||
background: rgba(20, 20, 24, 0.97);
|
background: color-mix(in srgb, var(--ci-bg-secondary) 97%, transparent);
|
||||||
box-shadow: 0 2px 8px #0004;
|
box-shadow: var(--ci-shadow-island);
|
||||||
font:
|
font: var(--ci-fw-normal) var(--ci-fs-control-base) / 1.4 var(--ci-font);
|
||||||
13px/1.4 'Segoe UI',
|
|
||||||
'Microsoft YaHei',
|
|
||||||
sans-serif;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
@@ -84,26 +82,26 @@ header,
|
|||||||
.metadata {
|
.metadata {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 10px;
|
gap: calc(var(--ci-component-gap) * 0.8);
|
||||||
}
|
}
|
||||||
header {
|
header {
|
||||||
color: #ffffffb8;
|
color: var(--ci-text-2);
|
||||||
font-size: 12px;
|
font-size: var(--ci-fs-caption);
|
||||||
}
|
}
|
||||||
header strong {
|
header strong {
|
||||||
color: var(--transfer-accent);
|
color: var(--transfer-accent);
|
||||||
}
|
}
|
||||||
.filename {
|
.filename {
|
||||||
font-weight: 600;
|
font-weight: var(--ci-fw-semi-bold);
|
||||||
font-size: 16px;
|
font-size: var(--ci-fs-title);
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.metadata {
|
.metadata {
|
||||||
color: #ffffffb8;
|
color: var(--ci-text-2);
|
||||||
font-size: 12px;
|
font-size: var(--ci-fs-caption);
|
||||||
}
|
}
|
||||||
progress {
|
progress {
|
||||||
display: block;
|
display: block;
|
||||||
@@ -111,20 +109,20 @@ progress {
|
|||||||
height: 5px;
|
height: 5px;
|
||||||
margin-top: 11px;
|
margin-top: 11px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 8px;
|
border-radius: var(--ci-radius-island);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
accent-color: var(--transfer-accent);
|
accent-color: var(--transfer-accent);
|
||||||
}
|
}
|
||||||
progress::-webkit-progress-bar {
|
progress::-webkit-progress-bar {
|
||||||
background: #ffffff30;
|
background: var(--ci-fill-strong);
|
||||||
}
|
}
|
||||||
progress::-webkit-progress-value {
|
progress::-webkit-progress-value {
|
||||||
background: var(--transfer-accent);
|
background: var(--transfer-accent);
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
margin: 3px 0;
|
margin: 3px 0;
|
||||||
font-size: 11px;
|
font-size: var(--ci-fs-caption);
|
||||||
color: #ffb4ab;
|
color: var(--ci-warning-critical);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
ISLAND_SHADOW_PAD,
|
ISLAND_SHADOW_PAD,
|
||||||
PRIORITY_RANK,
|
PRIORITY_RANK,
|
||||||
type IslandAppearance,
|
type IslandAppearance,
|
||||||
|
type IslandLayoutRow,
|
||||||
type IslandLayoutSettings,
|
type IslandLayoutSettings,
|
||||||
type IslandState,
|
type IslandState,
|
||||||
type IslandTimePointDto,
|
type IslandTimePointDto,
|
||||||
@@ -13,7 +14,6 @@ import {
|
|||||||
import ComponentNode from './ComponentNode.vue';
|
import ComponentNode from './ComponentNode.vue';
|
||||||
import ComponentIcon from './ComponentIcon.vue';
|
import ComponentIcon from './ComponentIcon.vue';
|
||||||
import ClassicNotifications from './ClassicNotifications.vue';
|
import ClassicNotifications from './ClassicNotifications.vue';
|
||||||
import { squirclePath } from './squircle.js';
|
|
||||||
import { SpringValue } from './spring.js';
|
import { SpringValue } from './spring.js';
|
||||||
import LessonReminderContent from './LessonReminderContent.vue';
|
import LessonReminderContent from './LessonReminderContent.vue';
|
||||||
|
|
||||||
@@ -27,7 +27,10 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
const scheme = computed(() => props.settings.schemes.find((s) => s.id === props.settings.activeSchemeId)!);
|
const scheme = computed(() => props.settings.schemes.find((s) => s.id === props.settings.activeSchemeId)!);
|
||||||
const expanded = computed(() => props.state.mode === 'expanded');
|
const expanded = computed(() => props.state.mode === 'expanded');
|
||||||
const lesson = computed(() => props.state.lessonReminder ?? null);
|
// 即将下课只在当前课程旁显示秒数,保留常驻组件与消息入口。
|
||||||
|
const lesson = computed(() =>
|
||||||
|
props.state.lessonReminder?.kind === 'ending' ? null : (props.state.lessonReminder ?? null),
|
||||||
|
);
|
||||||
const lastLesson = ref<IslandLessonReminder | null>(null);
|
const lastLesson = ref<IslandLessonReminder | null>(null);
|
||||||
watch(
|
watch(
|
||||||
lesson,
|
lesson,
|
||||||
@@ -75,6 +78,33 @@ function fitted(size: { width: number; height: number }) {
|
|||||||
);
|
);
|
||||||
return { scale, width: Math.ceil(size.width * scale), height: Math.ceil(size.height * scale) };
|
return { scale, width: Math.ceil(size.width * scale), height: Math.ceil(size.height * scale) };
|
||||||
}
|
}
|
||||||
|
/** 页面配置里的十六进制颜色转成背景 alpha;输入已由 shared 归一化。 */
|
||||||
|
function withAlpha(hex: string, alpha: number): string {
|
||||||
|
return `color-mix(in srgb, ${hex} ${Math.min(1, Math.max(0, alpha)) * 100}%, transparent)`;
|
||||||
|
}
|
||||||
|
/** 自定义前景色必须写进颜色 alpha,不能用 opacity 连带淡化子元素与阴影。 */
|
||||||
|
function foregroundVars(hex: string): Record<string, string> {
|
||||||
|
return {
|
||||||
|
'--ci-text-1': hex,
|
||||||
|
'--ci-text-2': `color-mix(in srgb, ${hex} 85.5%, transparent)`,
|
||||||
|
'--ci-text-3': `color-mix(in srgb, ${hex} 77.3%, transparent)`,
|
||||||
|
'--ci-text-4': `color-mix(in srgb, ${hex} 52.9%, transparent)`,
|
||||||
|
'--ci-text-5': `color-mix(in srgb, ${hex} 36.5%, transparent)`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function rowStyle(row: IslandLayoutRow): Record<string, string> {
|
||||||
|
const style: Record<string, string> = {
|
||||||
|
'--row-gap': `${row.gap}px`,
|
||||||
|
opacity: String(row.opacity),
|
||||||
|
};
|
||||||
|
if (row.fontOverridesEnabled) {
|
||||||
|
style['--ci-fs-secondary'] = `${row.secondaryFontSize}px`;
|
||||||
|
style['--ci-fs-body'] = `${row.bodyFontSize}px`;
|
||||||
|
style['--ci-fs-emphasized'] = `${row.emphasizedFontSize}px`;
|
||||||
|
style['--ci-fs-large'] = `${row.largeFontSize}px`;
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
}
|
||||||
const compactFit = computed(() => fitted(natural.value.compact));
|
const compactFit = computed(() => fitted(natural.value.compact));
|
||||||
const detailsFit = computed(() => fitted(natural.value.details));
|
const detailsFit = computed(() => fitted(natural.value.details));
|
||||||
const lessonFit = computed(() => fitted(natural.value.lesson));
|
const lessonFit = computed(() => fitted(natural.value.lesson));
|
||||||
@@ -95,30 +125,44 @@ const progress = ref(0);
|
|||||||
const lessonProgress = ref(0);
|
const lessonProgress = ref(0);
|
||||||
const compactAlpha = computed(() => Math.max(0, 1 - progress.value * 1.5) * (1 - lessonProgress.value));
|
const compactAlpha = computed(() => Math.max(0, 1 - progress.value * 1.5) * (1 - lessonProgress.value));
|
||||||
const detailsAlpha = computed(() => progress.value * progress.value * (1 - lessonProgress.value));
|
const detailsAlpha = computed(() => progress.value * progress.value * (1 - lessonProgress.value));
|
||||||
const path = computed(() => squirclePath(morph.value.width, morph.value.height, morph.value.radius));
|
const style = computed<CSSProperties>(() => {
|
||||||
const style = computed<CSSProperties>(() => ({
|
const current = scheme.value;
|
||||||
|
const background = lesson.value
|
||||||
|
? 'transparent'
|
||||||
|
: expanded.value && messages.value.length
|
||||||
|
? current.customForegroundEnabled
|
||||||
|
? 'var(--ci-brand-dark)'
|
||||||
|
: 'var(--ci-bg-base)'
|
||||||
|
: current.customBackgroundEnabled
|
||||||
|
? withAlpha(current.color, current.opacity)
|
||||||
|
: 'var(--ci-bg-secondary)';
|
||||||
|
return {
|
||||||
width: `${morph.value.width}px`,
|
width: `${morph.value.width}px`,
|
||||||
height: `${morph.value.height}px`,
|
height: `${morph.value.height}px`,
|
||||||
'--card-path': `path("${path.value}")`,
|
'--island-font': `${current.bodyFontSize}px`,
|
||||||
'--island-font': `${props.appearance.fontSize}px`,
|
'--ci-fs-secondary': `${current.secondaryFontSize}px`,
|
||||||
'--island-accent': props.appearance.accent,
|
'--ci-fs-body': `${current.bodyFontSize}px`,
|
||||||
|
'--ci-fs-emphasized': `${current.emphasizedFontSize}px`,
|
||||||
|
'--ci-fs-large': `${current.largeFontSize}px`,
|
||||||
|
'--ci-font-weight': String(current.fontWeight),
|
||||||
|
'--ci-scale': String(current.scale),
|
||||||
|
'--ci-accent': props.appearance.resolvedAccent ?? props.appearance.accent,
|
||||||
'--state-color':
|
'--state-color':
|
||||||
props.state.active?.priority === 'URGENT'
|
props.state.active?.priority === 'URGENT'
|
||||||
? '#ff453a'
|
? 'var(--ci-danger)'
|
||||||
: props.state.active?.kind === 'call'
|
: props.state.active?.kind === 'call'
|
||||||
? '#ff9f0a'
|
? 'var(--ci-warning-caution)'
|
||||||
: props.appearance.accent,
|
: 'var(--ci-accent)',
|
||||||
'--resident-background': 'var(--wn-bg)',
|
'--resident-background': background,
|
||||||
'--resident-radius': `${morph.value.radius}px`,
|
'--resident-radius': `${morph.value.radius}px`,
|
||||||
'--resident-scale': fit.value.scale,
|
'--resident-scale': fit.value.scale,
|
||||||
'--custom-row-gap': `${scheme.value.spacing}px`,
|
'--custom-row-gap': `${current.spacing}px`,
|
||||||
'--resident-row-width': `${Math.max(60, available.value.width / scheme.value.scale - 58)}px`,
|
'--resident-row-width': `${Math.max(60, available.value.width / current.scale - 58)}px`,
|
||||||
'--secondary': `${(props.appearance.fontSize / 13) * 14}px`,
|
'--ci-body-font': `${current.bodyFontSize}px`,
|
||||||
'--emphasized': `${(props.appearance.fontSize / 13) * 18}px`,
|
|
||||||
'--large': `${(props.appearance.fontSize / 13) * 20}px`,
|
|
||||||
'--ci-body-font': `${(props.appearance.fontSize / 13) * 16}px`,
|
|
||||||
'--resident-fade-duration': motion.value ? `${200 / props.appearance.speed}ms` : '0ms',
|
'--resident-fade-duration': motion.value ? `${200 / props.appearance.speed}ms` : '0ms',
|
||||||
}));
|
...(current.customForegroundEnabled ? foregroundVars(current.foreground) : {}),
|
||||||
|
};
|
||||||
|
});
|
||||||
let morphFrame = 0;
|
let morphFrame = 0;
|
||||||
let morphFallback: ReturnType<typeof setTimeout> | undefined;
|
let morphFallback: ReturnType<typeof setTimeout> | undefined;
|
||||||
function animate() {
|
function animate() {
|
||||||
@@ -283,7 +327,15 @@ watch(
|
|||||||
{ deep: true, flush: 'post' },
|
{ deep: true, flush: 'post' },
|
||||||
);
|
);
|
||||||
watch(
|
watch(
|
||||||
[fit, motion, expanded, lesson, () => props.appearance.radius, () => props.appearance.speed],
|
[
|
||||||
|
fit,
|
||||||
|
motion,
|
||||||
|
expanded,
|
||||||
|
lesson,
|
||||||
|
() => scheme.value.radius,
|
||||||
|
() => props.appearance.radius,
|
||||||
|
() => props.appearance.speed,
|
||||||
|
],
|
||||||
() => {
|
() => {
|
||||||
animate();
|
animate();
|
||||||
trackHit();
|
trackHit();
|
||||||
@@ -331,6 +383,16 @@ onUnmounted(() => {
|
|||||||
:data-bottom="appearance.position.startsWith('bottom')"
|
:data-bottom="appearance.position.startsWith('bottom')"
|
||||||
@pointerdown.capture="pointer"
|
@pointerdown.capture="pointer"
|
||||||
>
|
>
|
||||||
|
<span
|
||||||
|
class="resident-shadow"
|
||||||
|
:class="{ 'resident-shadow-hidden': lesson || (scheme.separated && !expanded) }"
|
||||||
|
:style="{
|
||||||
|
width: `${morph.width}px`,
|
||||||
|
height: `${morph.height}px`,
|
||||||
|
borderRadius: `${morph.radius}px`,
|
||||||
|
}"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
<section
|
<section
|
||||||
ref="shell"
|
ref="shell"
|
||||||
class="custom-card resident-card island-card"
|
class="custom-card resident-card island-card"
|
||||||
@@ -360,16 +422,6 @@ onUnmounted(() => {
|
|||||||
@keydown="key"
|
@keydown="key"
|
||||||
@transitionend.self="reportHit"
|
@transitionend.self="reportHit"
|
||||||
>
|
>
|
||||||
<svg
|
|
||||||
class="shape"
|
|
||||||
:width="morph.width"
|
|
||||||
:height="morph.height"
|
|
||||||
:viewBox="`0 0 ${morph.width} ${morph.height}`"
|
|
||||||
preserveAspectRatio="none"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<path :d="path" />
|
|
||||||
</svg>
|
|
||||||
<span class="tint" aria-hidden="true" />
|
<span class="tint" aria-hidden="true" />
|
||||||
<div
|
<div
|
||||||
class="resident-page resident-compact-page"
|
class="resident-page resident-compact-page"
|
||||||
@@ -389,7 +441,7 @@ onUnmounted(() => {
|
|||||||
:key="row.id"
|
:key="row.id"
|
||||||
class="layout-row"
|
class="layout-row"
|
||||||
:data-row="row.id"
|
:data-row="row.id"
|
||||||
:style="{ '--row-gap': `${row.gap}px` }"
|
:style="rowStyle(row)"
|
||||||
>
|
>
|
||||||
<div class="row-components">
|
<div class="row-components">
|
||||||
<ComponentNode
|
<ComponentNode
|
||||||
@@ -471,7 +523,7 @@ onUnmounted(() => {
|
|||||||
:key="row.id"
|
:key="row.id"
|
||||||
class="layout-row"
|
class="layout-row"
|
||||||
:data-row="row.id"
|
:data-row="row.id"
|
||||||
:style="{ '--row-gap': `${row.gap}px` }"
|
:style="rowStyle(row)"
|
||||||
>
|
>
|
||||||
<div class="row-components">
|
<div class="row-components">
|
||||||
<ComponentNode
|
<ComponentNode
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ onUnmounted(() => clearInterval(clock));
|
|||||||
* - 造型:**连续圆角(超椭圆 squircle)**而不是 border-radius(WinIsland `utils/shape.rs`);
|
* - 造型:**连续圆角(超椭圆 squircle)**而不是 border-radius(WinIsland `utils/shape.rs`);
|
||||||
* 展开卡半径取 `min(48 * 圆角系数, w/2, h/2)`,胶囊半径取 `h/2`(满圆角);
|
* 展开卡半径取 `min(48 * 圆角系数, w/2, h/2)`,胶囊半径取 `h/2`(满圆角);
|
||||||
* - 底色:默认纯黑(WinIsland `default` 风格),可选半透明毛玻璃(`glass`;
|
* - 底色:默认纯黑(WinIsland `default` 风格),可选半透明毛玻璃(`glass`;
|
||||||
* **纯 CSS 实现**,取 WinIsland 拿不到 host backdrop 时的降级色 `rgba(32,32,36,.804)`——
|
* **纯 CSS 实现**,取 WinIsland 拿不到 host backdrop 时的 80.4% 深色降级底——
|
||||||
* Electron 的 `setBackgroundMaterial()` 不能用在逐像素透明窗口上,原因见 `main/island.ts`);
|
* Electron 的 `setBackgroundMaterial()` 不能用在逐像素透明窗口上,原因见 `main/island.ts`);
|
||||||
* - 描边:1px 白、alpha 30(纯黑)/ 40(玻璃、主题色),与 WinIsland `BORDER_*_ALPHA` 同值;
|
* - 描边:1px 白、alpha 30(纯黑)/ 40(玻璃、主题色),与 WinIsland `BORDER_*_ALPHA` 同值;
|
||||||
* - 阴影:只在展开态,`0 2px 3px rgba(0,0,0,.11)`(WinIsland `draw_expanded_shadow`);
|
* - 阴影:只在展开态,2px 偏移、3px 模糊、11% 黑(WinIsland `draw_expanded_shadow`);
|
||||||
* - 排版:白字 + alpha 分级(.92/.72/.58),**所有文本 = 基础字号 × 排版系数**,
|
* - 排版:白字 + alpha 分级(.92/.72/.58),**所有文本 = 基础字号 × 排版系数**,
|
||||||
* 因此「字号」设置一改,岛内文字整体等比缩放(WinIsland `font_size` 模型);
|
* 因此「字号」设置一改,岛内文字整体等比缩放(WinIsland `font_size` 模型);
|
||||||
* - 动效:**单调缓动(无过冲、无回弹)**,只有淡入淡出与窗口形变,符合"开合不震动"。
|
* - 动效:**单调缓动(无过冲、无回弹)**,只有淡入淡出与窗口形变,符合"开合不震动"。
|
||||||
@@ -150,8 +150,8 @@ const showAfterClassHint = computed(() => state.value.reason === 'after-class' &
|
|||||||
|
|
||||||
/** 状态色(WinIsland 资源占用色板同源):危险红 / 警告橙 / 强调蓝 */
|
/** 状态色(WinIsland 资源占用色板同源):危险红 / 警告橙 / 强调蓝 */
|
||||||
const stateColor = computed(() => {
|
const stateColor = computed(() => {
|
||||||
if (isUrgent.value) return '#ff453a';
|
if (isUrgent.value) return 'var(--ci-danger)';
|
||||||
if (isCall.value) return '#ff9f0a';
|
if (isCall.value) return 'var(--ci-warning-caution)';
|
||||||
if (isHomework.value) return appearance.value.accent;
|
if (isHomework.value) return appearance.value.accent;
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
@@ -519,7 +519,8 @@ function applyAppearance(next: IslandAppearance | null | undefined): void {
|
|||||||
if (!next) return;
|
if (!next) return;
|
||||||
appearance.value = next;
|
appearance.value = next;
|
||||||
const style = document.documentElement.style;
|
const style = document.documentElement.style;
|
||||||
style.setProperty('--island-accent', next.accent);
|
style.setProperty('--ci-accent', next.resolvedAccent ?? next.accent);
|
||||||
|
style.setProperty('--ci-accent-fill', 'var(--ci-accent)');
|
||||||
style.setProperty('--island-radius', `${next.radius}px`);
|
style.setProperty('--island-radius', `${next.radius}px`);
|
||||||
style.setProperty('--island-font', `${next.fontSize}px`);
|
style.setProperty('--island-font', `${next.fontSize}px`);
|
||||||
style.setProperty('--island-w', `${next.width}px`);
|
style.setProperty('--island-w', `${next.width}px`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
import {
|
import {
|
||||||
defaultIslandLayouts,
|
defaultIslandLayouts,
|
||||||
DEFAULT_ISLAND_APPEARANCE,
|
DEFAULT_ISLAND_APPEARANCE,
|
||||||
@@ -18,6 +18,7 @@ const schedules = ref<ScheduleDto[]>([]);
|
|||||||
const timePoints = ref<IslandTimePointDto[]>([]);
|
const timePoints = ref<IslandTimePointDto[]>([]);
|
||||||
const appearance = ref<IslandAppearance>({ ...DEFAULT_ISLAND_APPEARANCE });
|
const appearance = ref<IslandAppearance>({ ...DEFAULT_ISLAND_APPEARANCE });
|
||||||
const nativeVisible = ref(false);
|
const nativeVisible = ref(false);
|
||||||
|
const theme = ref<'light' | 'dark'>('light');
|
||||||
const resident = () => settings.value.layout === 'custom';
|
const resident = () => settings.value.layout === 'custom';
|
||||||
const state = ref<IslandState>({
|
const state = ref<IslandState>({
|
||||||
mode: 'hidden',
|
mode: 'hidden',
|
||||||
@@ -31,11 +32,15 @@ const state = ref<IslandState>({
|
|||||||
updatedAt: 0,
|
updatedAt: 0,
|
||||||
});
|
});
|
||||||
let heartbeat: ReturnType<typeof setInterval>;
|
let heartbeat: ReturnType<typeof setInterval>;
|
||||||
|
watch(theme, (value) => document.documentElement.classList.toggle('dark', value === 'dark'), {
|
||||||
|
immediate: true,
|
||||||
|
});
|
||||||
onUnmounted(() => clearInterval(heartbeat));
|
onUnmounted(() => clearInterval(heartbeat));
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
heartbeat = setInterval(() => window.island?.alive(), 5000);
|
heartbeat = setInterval(() => window.island?.alive(), 5000);
|
||||||
const bridge = window.island;
|
const bridge = window.island;
|
||||||
if (bridge) {
|
if (bridge) {
|
||||||
|
bridge.onTheme((value) => (theme.value = value));
|
||||||
bridge.onLayout((value) => (settings.value = value));
|
bridge.onLayout((value) => (settings.value = value));
|
||||||
bridge.onSchedules((value) => (schedules.value = value));
|
bridge.onSchedules((value) => (schedules.value = value));
|
||||||
bridge.onTimePoints((value) => (timePoints.value = value));
|
bridge.onTimePoints((value) => (timePoints.value = value));
|
||||||
@@ -43,6 +48,7 @@ onMounted(async () => {
|
|||||||
bridge.onAppearance((value) => (appearance.value = value));
|
bridge.onAppearance((value) => (appearance.value = value));
|
||||||
bridge.onVisibility((value) => (nativeVisible.value = value));
|
bridge.onVisibility((value) => (nativeVisible.value = value));
|
||||||
nativeVisible.value = await bridge.getVisible();
|
nativeVisible.value = await bridge.getVisible();
|
||||||
|
theme.value = await bridge.getTheme();
|
||||||
appearance.value = await bridge.getAppearance();
|
appearance.value = await bridge.getAppearance();
|
||||||
settings.value = await bridge.getLayout();
|
settings.value = await bridge.getLayout();
|
||||||
schedules.value = await bridge.getSchedules();
|
schedules.value = await bridge.getSchedules();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
const root = ref<HTMLElement>();
|
const root = ref<HTMLElement>();
|
||||||
const width = ref(480);
|
const width = ref(480);
|
||||||
const mask = computed(() => props.now < props.reminder.maskUntil);
|
const mask = computed(() => props.reminder.kind !== 'ending' && props.now < props.reminder.maskUntil);
|
||||||
const title = computed(
|
const title = computed(
|
||||||
() =>
|
() =>
|
||||||
({
|
({
|
||||||
@@ -140,15 +140,14 @@ onUnmounted(() => {
|
|||||||
aria-live="polite"
|
aria-live="polite"
|
||||||
>
|
>
|
||||||
<div class="ci-lesson-info">
|
<div class="ci-lesson-info">
|
||||||
<span
|
<span v-if="reminder.kind === 'prepare' || reminder.kind === 'in-class'" class="ci-countdown">
|
||||||
v-if="reminder.kind === 'prepare' || reminder.kind === 'ending' || reminder.kind === 'in-class'"
|
|
||||||
class="ci-countdown"
|
|
||||||
>
|
|
||||||
{{ reminder.kind === 'prepare' ? '距上课还剩' : '距下课还剩' }}
|
{{ reminder.kind === 'prepare' ? '距上课还剩' : '距下课还剩' }}
|
||||||
<strong>{{ leftSeconds }}</strong>
|
<strong>{{ leftSeconds }}</strong>
|
||||||
秒
|
秒
|
||||||
</span>
|
</span>
|
||||||
<span v-else class="ci-countdown">{{ reminder.kind === 'on-class' ? '开始上课' : '课间休息' }}</span>
|
<span v-else-if="reminder.kind !== 'ending'" class="ci-countdown">
|
||||||
|
{{ reminder.kind === 'on-class' ? '开始上课' : '课间休息' }}
|
||||||
|
</span>
|
||||||
<span class="ci-lesson-course">
|
<span class="ci-lesson-course">
|
||||||
<span>
|
<span>
|
||||||
{{
|
{{
|
||||||
@@ -158,6 +157,13 @@ onUnmounted(() => {
|
|||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
<strong>{{ course || '今日课程已结束' }}</strong>
|
<strong>{{ course || '今日课程已结束' }}</strong>
|
||||||
|
<span
|
||||||
|
v-if="reminder.kind === 'ending'"
|
||||||
|
class="lesson-ending-badge"
|
||||||
|
:aria-label="`距下课${leftSeconds}秒`"
|
||||||
|
>
|
||||||
|
-{{ leftSeconds }}
|
||||||
|
</span>
|
||||||
<small v-if="course">{{ time }}</small>
|
<small v-if="course">{{ time }}</small>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -192,20 +198,20 @@ onUnmounted(() => {
|
|||||||
width: max-content;
|
width: max-content;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
height: 40px;
|
height: var(--ci-island-height);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
color: #fff;
|
color: var(--ci-text-1);
|
||||||
font-size: 16px;
|
font-size: var(--ci-fs-body);
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
border-radius: 8px;
|
border-radius: var(--ci-radius-island);
|
||||||
background: #20202080;
|
background: color-mix(in srgb, var(--ci-bg-base) 50%, transparent);
|
||||||
}
|
}
|
||||||
.ci-lesson-info {
|
.ci-lesson-info {
|
||||||
height: 40px;
|
height: var(--ci-island-height);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 12px;
|
gap: var(--ci-component-gap);
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
transition: opacity var(--ci-duration) ease-in;
|
transition: opacity var(--ci-duration) ease-in;
|
||||||
@@ -224,25 +230,26 @@ onUnmounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 6px;
|
gap: calc(var(--ci-component-gap) / 2);
|
||||||
}
|
}
|
||||||
.ci-lesson-course strong {
|
.ci-lesson-course strong {
|
||||||
font-size: 20px;
|
font-size: var(--ci-fs-large);
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.ci-lesson-course small {
|
.ci-lesson-course small {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-size: 14px;
|
color: var(--ci-text-3);
|
||||||
|
font-size: var(--ci-fs-secondary);
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
}
|
}
|
||||||
.ci-mask {
|
.ci-mask {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 40px;
|
height: var(--ci-island-height);
|
||||||
fill: var(--island-accent, #60a5fa);
|
fill: var(--island-accent, var(--ci-accent));
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.ci-mask-title {
|
.ci-mask-title {
|
||||||
@@ -251,9 +258,9 @@ onUnmounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: calc(var(--ci-component-gap) * 0.67);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
font-size: 18px;
|
font-size: var(--ci-fs-emphasized);
|
||||||
transform: scale(1.1);
|
transform: scale(1.1);
|
||||||
transition:
|
transition:
|
||||||
opacity var(--ci-duration) linear,
|
opacity var(--ci-duration) linear,
|
||||||
@@ -303,9 +310,10 @@ onUnmounted(() => {
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 2px;
|
height: var(--ci-progress-height);
|
||||||
background: var(--island-accent, #60a5fa);
|
background: var(--island-accent, var(--ci-accent));
|
||||||
transform-origin: left;
|
transform-origin: left;
|
||||||
transition: transform 50ms linear;
|
transition: transform 50ms linear;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<style src="./lesson-ending.css"></style>
|
||||||
@@ -86,6 +86,7 @@ const advice = computed(() => {
|
|||||||
}
|
}
|
||||||
small {
|
small {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: var(--secondary, 12px);
|
color: var(--ci-text-3);
|
||||||
|
font-size: var(--ci-fs-secondary);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -18,10 +18,13 @@ body,
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* 经典岛沿用历史变量名,但颜色唯一来源仍是 --ci-accent。 */
|
||||||
|
--island-accent: var(--ci-accent);
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family:
|
font-family: var(--ci-font-island);
|
||||||
-apple-system, 'Segoe UI Variable Display', 'Segoe UI', 'Microsoft YaHei', 'PingFang SC',
|
|
||||||
'Helvetica Neue', sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,36 +56,38 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
color: rgba(255, 255, 255, 0.92);
|
color: var(--ci-text-on-accent);
|
||||||
|
font-family: var(--ci-font-island);
|
||||||
font-size: var(--island-font, 13px);
|
font-size: var(--island-font, 13px);
|
||||||
|
font-weight: var(--ci-font-weight);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
/* 配色 token(默认:WinIsland 纯黑风格) */
|
/* 配色 token(默认:WinIsland 纯黑风格) */
|
||||||
--wn-bg: #000000;
|
--wn-bg: var(--ci-island-bg-custom);
|
||||||
--wn-border: rgba(255, 255, 255, 0.118);
|
--wn-border: var(--ci-stroke-island);
|
||||||
--wn-text-1: rgba(255, 255, 255, 0.92);
|
--wn-text-1: var(--ci-text-on-accent);
|
||||||
--wn-text-2: rgba(255, 255, 255, 0.72);
|
--wn-text-2: color-mix(in srgb, var(--ci-text-on-accent) 85.5%, transparent);
|
||||||
--wn-text-3: rgba(255, 255, 255, 0.58);
|
--wn-text-3: color-mix(in srgb, var(--ci-text-on-accent) 77.3%, transparent);
|
||||||
--wn-surface: rgba(255, 255, 255, 0.1);
|
--wn-surface: var(--ci-fill-secondary);
|
||||||
--wn-surface-hover: rgba(255, 255, 255, 0.18);
|
--wn-surface-hover: var(--ci-accent-soft);
|
||||||
--wn-divider: rgba(255, 255, 255, 0.09);
|
--wn-divider: var(--ci-stroke-divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card[data-style='glass'] {
|
.island-card[data-style='glass'] {
|
||||||
/* WinIsland「glass 无 host backdrop」降级色:比纯黑透一点,但保证任何桌面下都不是白底 */
|
/* WinIsland「glass 无 host backdrop」降级色:比纯黑透一点,但保证任何桌面下都不是白底 */
|
||||||
--wn-bg: rgba(32, 32, 36, 0.804);
|
--wn-bg: color-mix(in srgb, var(--ci-bg-base) 80.4%, transparent);
|
||||||
--wn-border: rgba(255, 255, 255, 0.157);
|
--wn-border: var(--ci-stroke-control);
|
||||||
--wn-surface: rgba(255, 255, 255, 0.14);
|
--wn-surface: var(--ci-fill-secondary);
|
||||||
--wn-surface-hover: rgba(255, 255, 255, 0.22);
|
--wn-surface-hover: var(--ci-accent-fill-tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card[data-style='tinted'] {
|
.island-card[data-style='tinted'] {
|
||||||
--wn-bg: #0b0b0f;
|
--wn-bg: color-mix(in srgb, var(--ci-island-bg-custom) 88%, var(--ci-accent));
|
||||||
--wn-border: rgba(255, 255, 255, 0.14);
|
--wn-border: var(--ci-stroke-control);
|
||||||
}
|
}
|
||||||
/* 阅读老师消息时使用实色底,玻璃风格也不透出桌面。 */
|
/* 阅读老师消息时使用实色底,玻璃风格也不透出桌面。 */
|
||||||
.island-card.message-surface {
|
.island-card.message-surface {
|
||||||
--wn-bg: #202020;
|
--wn-bg: var(--ci-brand-dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card.hidden-placeholder {
|
.island-card.hidden-placeholder {
|
||||||
@@ -120,7 +125,9 @@ body {
|
|||||||
胶囊态用 0 0 0:硬轮廓投影正好压在路径底下,肉眼等同无投影,与 WinIsland
|
胶囊态用 0 0 0:硬轮廓投影正好压在路径底下,肉眼等同无投影,与 WinIsland
|
||||||
"只有展开态有投影"的观感一致。
|
"只有展开态有投影"的观感一致。
|
||||||
*/
|
*/
|
||||||
filter: drop-shadow(0 var(--card-shadow-y, 0px) var(--card-shadow-blur, 0px) rgba(0, 0, 0, 0.11));
|
filter: drop-shadow(
|
||||||
|
0 var(--card-shadow-y, 0px) var(--card-shadow-blur, 0px) color-mix(in srgb, black 11%, transparent)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 内容层裁切到同一形状内;内部两层(胶囊层 / 展开层)交叉淡入 */
|
/* 内容层裁切到同一形状内;内部两层(胶囊层 / 展开层)交叉淡入 */
|
||||||
@@ -145,7 +152,7 @@ body {
|
|||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 展开态投影(WinIsland: rgba(0,0,0,.11)、y+2、σ=3 → CSS 0 2px 3px)。
|
/* 展开态投影(WinIsland: 11% 黑、y+2、σ=3 → CSS 0 2px 3px)。
|
||||||
只改参数、不动 filter 声明本身,理由见上面的 .shape path。 */
|
只改参数、不动 filter 声明本身,理由见上面的 .shape path。 */
|
||||||
.island-card.expanded .shape path {
|
.island-card.expanded .shape path {
|
||||||
--card-shadow-y: 2px;
|
--card-shadow-y: 2px;
|
||||||
@@ -155,7 +162,7 @@ body {
|
|||||||
/* 状态色:只做"内层微染 + 描边",不外溢(保持桌面干净,也不会有光晕硬边) */
|
/* 状态色:只做"内层微染 + 描边",不外溢(保持桌面干净,也不会有光晕硬边) */
|
||||||
.island-card.urgent .shape path,
|
.island-card.urgent .shape path,
|
||||||
.island-card.call .shape path {
|
.island-card.call .shape path {
|
||||||
stroke: color-mix(in srgb, var(--state-color) 62%, rgba(255, 255, 255, 0.2));
|
stroke: color-mix(in srgb, var(--state-color) 62%, var(--ci-stroke-control));
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card .tint {
|
.island-card .tint {
|
||||||
@@ -167,12 +174,20 @@ body {
|
|||||||
|
|
||||||
.island-card.urgent .tint {
|
.island-card.urgent .tint {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
background: radial-gradient(120% 90% at 50% 0%, rgba(255, 69, 58, 0.22), transparent 68%);
|
background: radial-gradient(
|
||||||
|
120% 90% at 50% 0%,
|
||||||
|
color-mix(in srgb, var(--ci-danger) 22%, transparent),
|
||||||
|
transparent 68%
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card.call .tint {
|
.island-card.call .tint {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
background: radial-gradient(120% 90% at 50% 0%, rgba(255, 159, 10, 0.2), transparent 68%);
|
background: radial-gradient(
|
||||||
|
120% 90% at 50% 0%,
|
||||||
|
color-mix(in srgb, var(--ci-warning-caution) 20%, transparent),
|
||||||
|
transparent 68%
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card[data-style='tinted'] .tint {
|
.island-card[data-style='tinted'] .tint {
|
||||||
@@ -242,7 +257,7 @@ body {
|
|||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: calc(var(--island-font, 13px) * 1.24);
|
width: calc(var(--island-font, 13px) * 1.24);
|
||||||
height: calc(var(--island-font, 13px) * 1.24);
|
height: calc(var(--island-font, 13px) * 1.24);
|
||||||
border-radius: 50%;
|
border-radius: var(--ci-radius-pill);
|
||||||
background: var(--wn-surface);
|
background: var(--wn-surface);
|
||||||
color: var(--wn-text-1);
|
color: var(--wn-text-1);
|
||||||
}
|
}
|
||||||
@@ -253,11 +268,11 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pill-icon.call {
|
.pill-icon.call {
|
||||||
color: #ff9f0a;
|
color: var(--ci-warning-caution);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pill-icon.urgent {
|
.pill-icon.urgent {
|
||||||
color: #ff453a;
|
color: var(--ci-danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pill-icon.homework {
|
.pill-icon.homework {
|
||||||
@@ -305,8 +320,8 @@ body {
|
|||||||
font-size: calc(var(--island-font, 13px) * 0.6);
|
font-size: calc(var(--island-font, 13px) * 0.6);
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
padding: 0 calc(var(--island-font, 13px) * 0.36);
|
padding: 0 calc(var(--island-font, 13px) * 0.36);
|
||||||
border-radius: 999px;
|
border-radius: var(--ci-radius-pill);
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: var(--ci-fill-secondary);
|
||||||
color: var(--wn-text-2);
|
color: var(--wn-text-2);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
@@ -314,7 +329,7 @@ body {
|
|||||||
.pill-chevron {
|
.pill-chevron {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: rgba(255, 255, 255, 0.34);
|
color: var(--ci-text-5);
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +401,7 @@ body {
|
|||||||
padding: 0 calc(var(--island-font, 13px) * 0.6);
|
padding: 0 calc(var(--island-font, 13px) * 0.6);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: calc(var(--island-font, 13px) * 0.5);
|
border-radius: calc(var(--island-font, 13px) * 0.5);
|
||||||
background: rgba(255, 255, 255, 0.045);
|
background: var(--ci-accent-soft);
|
||||||
color: var(--wn-text-1);
|
color: var(--wn-text-1);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -411,7 +426,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.row-icon.call {
|
.row-icon.call {
|
||||||
color: #ff9f0a;
|
color: var(--ci-warning-caution);
|
||||||
}
|
}
|
||||||
|
|
||||||
.row-icon.homework {
|
.row-icon.homework {
|
||||||
@@ -451,11 +466,11 @@ body {
|
|||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
height: calc(var(--island-font, 13px) * 1.25);
|
height: calc(var(--island-font, 13px) * 1.25);
|
||||||
padding: 0 calc(var(--island-font, 13px) * 0.5);
|
padding: 0 calc(var(--island-font, 13px) * 0.5);
|
||||||
border-radius: 999px;
|
border-radius: var(--ci-radius-pill);
|
||||||
font-size: calc(var(--island-font, 13px) * 0.68);
|
font-size: calc(var(--island-font, 13px) * 0.68);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: var(--ci-fill-secondary);
|
||||||
color: rgba(255, 255, 255, 0.78);
|
color: var(--ci-text-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 列表底部的提示行:能展开时是按钮,屏幕到任务栏了就是一句"去应用里看" */
|
/* 列表底部的提示行:能展开时是按钮,屏幕到任务栏了就是一句"去应用里看" */
|
||||||
@@ -511,13 +526,13 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.head-icon.urgent {
|
.head-icon.urgent {
|
||||||
background: rgba(255, 69, 58, 0.2);
|
background: color-mix(in srgb, var(--ci-danger) 20%, transparent);
|
||||||
color: #ff453a;
|
color: var(--ci-danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
.head-icon.call {
|
.head-icon.call {
|
||||||
background: rgba(255, 159, 10, 0.2);
|
background: color-mix(in srgb, var(--ci-warning-caution) 20%, transparent);
|
||||||
color: #ff9f0a;
|
color: var(--ci-warning-caution);
|
||||||
}
|
}
|
||||||
|
|
||||||
.head-icon.homework {
|
.head-icon.homework {
|
||||||
@@ -538,39 +553,39 @@ body {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
height: calc(var(--island-font, 13px) * 1.5);
|
height: calc(var(--island-font, 13px) * 1.5);
|
||||||
padding: 0 calc(var(--island-font, 13px) * 0.62);
|
padding: 0 calc(var(--island-font, 13px) * 0.62);
|
||||||
border-radius: 999px;
|
border-radius: var(--ci-radius-pill);
|
||||||
font-size: calc(var(--island-font, 13px) * 0.76);
|
font-size: calc(var(--island-font, 13px) * 0.76);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
background: color-mix(in srgb, var(--island-accent) 26%, transparent);
|
background: color-mix(in srgb, var(--island-accent) 26%, transparent);
|
||||||
color: color-mix(in srgb, var(--island-accent) 70%, #ffffff);
|
color: color-mix(in srgb, var(--island-accent) 70%, var(--ci-text-1));
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-urgent {
|
.badge-urgent {
|
||||||
background: rgba(255, 69, 58, 0.24);
|
background: color-mix(in srgb, var(--ci-danger) 24%, transparent);
|
||||||
color: #ff6961;
|
color: var(--ci-danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-high {
|
.badge-high {
|
||||||
background: rgba(255, 159, 10, 0.22);
|
background: color-mix(in srgb, var(--ci-warning-caution) 22%, transparent);
|
||||||
color: #ffb340;
|
color: var(--ci-warning-caution);
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-low,
|
.badge-low,
|
||||||
.badge-normal {
|
.badge-normal {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: var(--ci-fill-secondary);
|
||||||
color: rgba(255, 255, 255, 0.78);
|
color: var(--ci-text-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-call {
|
.badge-call {
|
||||||
background: rgba(255, 159, 10, 0.24);
|
background: color-mix(in srgb, var(--ci-warning-caution) 24%, transparent);
|
||||||
color: #ffb340;
|
color: var(--ci-warning-caution);
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-homework {
|
.badge-homework {
|
||||||
background: color-mix(in srgb, var(--island-accent) 26%, transparent);
|
background: color-mix(in srgb, var(--island-accent) 26%, transparent);
|
||||||
color: color-mix(in srgb, var(--island-accent) 72%, #ffffff);
|
color: color-mix(in srgb, var(--island-accent) 72%, var(--ci-text-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-dot {
|
.live-dot {
|
||||||
@@ -578,12 +593,12 @@ body {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: calc(var(--island-font, 13px) * 0.32);
|
gap: calc(var(--island-font, 13px) * 0.32);
|
||||||
font-size: calc(var(--island-font, 13px) * 0.76);
|
font-size: calc(var(--island-font, 13px) * 0.76);
|
||||||
color: #ff6961;
|
color: var(--ci-danger);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-dot.call {
|
.live-dot.call {
|
||||||
color: #ffb340;
|
color: var(--ci-warning-caution);
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-dot.muted {
|
.live-dot.muted {
|
||||||
@@ -605,9 +620,9 @@ body {
|
|||||||
width: calc(var(--island-font, 13px) * 1.7);
|
width: calc(var(--island-font, 13px) * 1.7);
|
||||||
height: calc(var(--island-font, 13px) * 1.7);
|
height: calc(var(--island-font, 13px) * 1.7);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: var(--ci-radius-pill);
|
||||||
background: var(--wn-surface);
|
background: var(--wn-surface);
|
||||||
color: rgba(255, 255, 255, 0.72);
|
color: var(--ci-text-3);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
transition:
|
transition:
|
||||||
@@ -625,7 +640,7 @@ body {
|
|||||||
font-size: calc(var(--island-font, 13px) * 1.08);
|
font-size: calc(var(--island-font, 13px) * 1.08);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
color: #fff;
|
color: var(--ci-text-1);
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
@@ -654,7 +669,7 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: calc(var(--island-font, 13px) * 0.85);
|
font-size: calc(var(--island-font, 13px) * 0.85);
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
color: color-mix(in srgb, var(--state-color) 66%, #ffffff);
|
color: color-mix(in srgb, var(--state-color) 66%, var(--ci-text-1));
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +706,7 @@ body {
|
|||||||
height: calc(var(--island-font, 13px) * 2.05);
|
height: calc(var(--island-font, 13px) * 2.05);
|
||||||
padding: 0 calc(var(--island-font, 13px) * 0.9);
|
padding: 0 calc(var(--island-font, 13px) * 0.9);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 999px;
|
border-radius: var(--ci-radius-pill);
|
||||||
font-size: calc(var(--island-font, 13px) * 0.76);
|
font-size: calc(var(--island-font, 13px) * 0.76);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -707,18 +722,18 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.solid-btn {
|
.solid-btn {
|
||||||
background: #ffffff;
|
background: var(--ci-text-1);
|
||||||
color: #0b0b0f;
|
color: var(--ci-bg-base);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card.call .solid-btn {
|
.island-card.call .solid-btn {
|
||||||
background: #ff9f0a;
|
background: var(--ci-warning-caution);
|
||||||
color: #1a1205;
|
color: var(--ci-brand-dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
.island-card.urgent .solid-btn {
|
.island-card.urgent .solid-btn {
|
||||||
background: #ff453a;
|
background: var(--ci-danger);
|
||||||
color: #ffffff;
|
color: var(--ci-text-on-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.ghost-btn:active,
|
.ghost-btn:active,
|
||||||
@@ -745,7 +760,7 @@ body {
|
|||||||
|
|
||||||
.icon-btn:hover {
|
.icon-btn:hover {
|
||||||
background: var(--wn-surface-hover);
|
background: var(--wn-surface-hover);
|
||||||
color: #ffffff;
|
color: var(--ci-text-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--custom-color);
|
background: var(--resident-background, var(--ci-island-bg-custom));
|
||||||
border-radius: var(--custom-radius);
|
color: var(--ci-text-1);
|
||||||
|
border-radius: var(--resident-radius, var(--ci-radius-island));
|
||||||
box-shadow:
|
box-shadow:
|
||||||
inset 0 0 0 1px #ffffff1e,
|
inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-island),
|
||||||
0 2px 3px #0000001c;
|
var(--ci-shadow-island);
|
||||||
}
|
}
|
||||||
.custom-inner {
|
.custom-inner {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
@@ -63,7 +64,7 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.custom-card[role='button']:focus-visible {
|
.custom-card[role='button']:focus-visible {
|
||||||
outline: 2px solid #8dafff;
|
outline: 2px solid var(--ci-stroke-drag);
|
||||||
outline-offset: -3px;
|
outline-offset: -3px;
|
||||||
}
|
}
|
||||||
.custom-card .resident-bell {
|
.custom-card .resident-bell {
|
||||||
@@ -76,16 +77,16 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 6px;
|
border-radius: var(--ci-radius-popup);
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: #ffda8b;
|
color: var(--ci-warning-caution);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.custom-card .resident-bell:hover {
|
.custom-card .resident-bell:hover {
|
||||||
background: #ffffff1a;
|
background: var(--ci-fill-secondary);
|
||||||
}
|
}
|
||||||
.custom-card .resident-bell.bell-empty {
|
.custom-card .resident-bell.bell-empty {
|
||||||
color: #ffffff60;
|
color: var(--ci-text-3);
|
||||||
}
|
}
|
||||||
.custom-card .resident-bell svg {
|
.custom-card .resident-bell svg {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
@@ -100,13 +101,11 @@
|
|||||||
min-width: 14px;
|
min-width: 14px;
|
||||||
height: 14px;
|
height: 14px;
|
||||||
padding: 0 3px;
|
padding: 0 3px;
|
||||||
border-radius: 7px;
|
border-radius: var(--ci-radius-pill);
|
||||||
background: #f45b58;
|
background: var(--ci-danger);
|
||||||
color: white;
|
color: var(--ci-text-on-accent);
|
||||||
font:
|
font: var(--ci-fw-semi-bold) var(--ci-fs-version) / 1 var(--ci-font);
|
||||||
600 9px/1 'Segoe UI',
|
box-shadow: 0 0 0 2px var(--resident-background, var(--ci-island-bg-custom));
|
||||||
sans-serif;
|
|
||||||
box-shadow: 0 0 0 2px var(--custom-color);
|
|
||||||
}
|
}
|
||||||
.custom-card .resident-panel-heading {
|
.custom-card .resident-panel-heading {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -114,17 +113,17 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 24px;
|
gap: 24px;
|
||||||
padding: 4px 6px 12px;
|
padding: 4px 6px 12px;
|
||||||
border-bottom: 1px solid #ffffff1a;
|
border-bottom: var(--ci-stroke-island-w) solid var(--ci-stroke-divider);
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
color: #ffffff94;
|
color: var(--ci-text-2);
|
||||||
font-size: 12px;
|
font-size: var(--ci-fs-caption);
|
||||||
}
|
}
|
||||||
.custom-card .resident-panel-heading button {
|
.custom-card .resident-panel-heading button {
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 8px;
|
border-radius: var(--ci-radius-control);
|
||||||
background: #ffffff0d;
|
background: var(--ci-fill-secondary);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -135,12 +134,12 @@
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
.layout-editor .surface-tabs button {
|
.layout-editor .surface-tabs button {
|
||||||
font-size: 12px;
|
font-size: var(--ci-fs-caption);
|
||||||
}
|
}
|
||||||
.layout-editor .surface-tabs button.active {
|
.layout-editor .surface-tabs button.active {
|
||||||
color: var(--editor-accent);
|
color: var(--ci-accent-text);
|
||||||
background: #edf2ff;
|
background: var(--ci-accent-fill-tertiary);
|
||||||
border-color: #b6c8f0;
|
border-color: var(--ci-stroke-drag);
|
||||||
}
|
}
|
||||||
.custom-card .layout-row {
|
.custom-card .layout-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -168,8 +167,8 @@
|
|||||||
}
|
}
|
||||||
.custom-card.has-alert {
|
.custom-card.has-alert {
|
||||||
box-shadow:
|
box-shadow:
|
||||||
inset 0 0 0 1px #ffffff2b,
|
inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-control),
|
||||||
0 2px 3px #0000001c;
|
var(--ci-shadow-mask);
|
||||||
}
|
}
|
||||||
.custom-card.separated {
|
.custom-card.separated {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
@@ -177,10 +176,10 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
.custom-card.separated .layout-row {
|
.custom-card.separated .layout-row {
|
||||||
background: var(--custom-color);
|
background: var(--resident-background, var(--ci-island-bg-custom));
|
||||||
border-radius: var(--custom-radius);
|
border-radius: var(--resident-radius, var(--ci-radius-island));
|
||||||
padding: 12px;
|
padding: var(--ci-island-pad-x);
|
||||||
box-shadow: inset 0 0 0 1px #ffffff1e;
|
box-shadow: inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-island);
|
||||||
}
|
}
|
||||||
/* 自定义模式只保留一个岛壳。原提醒渲染器继续负责内容、动画和按钮。 */
|
/* 自定义模式只保留一个岛壳。原提醒渲染器继续负责内容、动画和按钮。 */
|
||||||
.custom-card .island-root.embedded .shape,
|
.custom-card .island-root.embedded .shape,
|
||||||
@@ -198,7 +197,7 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
.custom-card .island-root.embedded {
|
.custom-card .island-root.embedded {
|
||||||
border-top: 1px solid #ffffff1a;
|
border-top: var(--ci-stroke-island-w) solid var(--ci-stroke-divider);
|
||||||
}
|
}
|
||||||
.custom-window .preview-stage {
|
.custom-window .preview-stage {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
|
|||||||
@@ -16,14 +16,48 @@
|
|||||||
max-width: none;
|
max-width: none;
|
||||||
max-height: none;
|
max-height: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
clip-path: var(--card-path);
|
|
||||||
isolation: isolate;
|
isolation: isolate;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
background: none;
|
background: var(--resident-background);
|
||||||
|
border: var(--ci-stroke-island-w) solid var(--ci-stroke-island);
|
||||||
border-radius: var(--resident-radius);
|
border-radius: var(--resident-radius);
|
||||||
|
color: var(--ci-text-1);
|
||||||
|
font-family: var(--ci-font-island);
|
||||||
font-size: var(--island-font);
|
font-size: var(--island-font);
|
||||||
|
font-weight: var(--ci-font-weight);
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
z-index: var(--ci-z-content);
|
||||||
|
transition: background-color var(--ci-duration) linear;
|
||||||
|
}
|
||||||
|
.resident-window .resident-shadow {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 0;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
pointer-events: none;
|
||||||
|
box-shadow: var(--ci-shadow-island);
|
||||||
|
z-index: var(--ci-z-window);
|
||||||
|
transition: opacity var(--ci-duration) linear;
|
||||||
|
}
|
||||||
|
.resident-window[data-anchor='left'] .resident-shadow {
|
||||||
|
left: 0;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
.resident-window[data-anchor='right'] .resident-shadow {
|
||||||
|
left: auto;
|
||||||
|
right: 0;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
.resident-window[data-bottom='true'] .resident-shadow {
|
||||||
|
top: auto;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
.resident-window .resident-shadow-hidden {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.resident-window .resident-card > .shape {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
.resident-window[data-anchor='left'] .resident-card {
|
.resident-window[data-anchor='left'] .resident-card {
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -72,10 +106,10 @@
|
|||||||
.resident-card .resident-compact {
|
.resident-card .resident-compact {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: calc(var(--ci-component-gap) / 2);
|
||||||
padding: 0 12px;
|
padding: 0 var(--ci-island-pad-x);
|
||||||
min-height: max(40px, calc(var(--island-font) * 2.5));
|
min-height: var(--ci-island-height);
|
||||||
font-size: var(--ci-body-font, 16px);
|
font-size: var(--ci-fs-body);
|
||||||
}
|
}
|
||||||
.resident-window .resident-card.resident-separated {
|
.resident-window .resident-card.resident-separated {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
@@ -88,7 +122,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.resident-separated .resident-compact .layout-row {
|
.resident-separated .resident-compact .layout-row {
|
||||||
padding: 0 12px;
|
padding: 0 var(--ci-island-pad-x);
|
||||||
background: var(--resident-background);
|
background: var(--resident-background);
|
||||||
border-radius: var(--resident-radius);
|
border-radius: var(--resident-radius);
|
||||||
}
|
}
|
||||||
@@ -107,10 +141,10 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
min-height: max(40px, calc(var(--island-font) * 2.5));
|
min-height: var(--ci-island-height);
|
||||||
}
|
}
|
||||||
.resident-card .resident-compact .component-node:not(.container) {
|
.resident-card .resident-compact .component-node:not(.container) {
|
||||||
min-height: max(40px, calc(var(--island-font) * 2.5));
|
min-height: var(--ci-island-height);
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -129,7 +163,7 @@
|
|||||||
}
|
}
|
||||||
.resident-card .resident-compact .schedule {
|
.resident-card .resident-compact .schedule {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: 12px;
|
gap: var(--ci-component-gap);
|
||||||
}
|
}
|
||||||
.resident-card .resident-compact .schedule > div + div {
|
.resident-card .resident-compact .schedule > div + div {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
@@ -142,14 +176,14 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
.resident-card .resident-bell.bell-empty {
|
.resident-card .resident-bell.bell-empty {
|
||||||
color: #ffffff80;
|
color: var(--ci-text-3);
|
||||||
}
|
}
|
||||||
.resident-card .resident-bell span {
|
.resident-card .resident-bell span {
|
||||||
animation: resident-indicator-in var(--resident-fade-duration) cubic-bezier(0.25, 1, 0.5, 1);
|
animation: resident-indicator-in var(--resident-fade-duration) cubic-bezier(0.25, 1, 0.5, 1);
|
||||||
}
|
}
|
||||||
.resident-card .resident-details {
|
.resident-card .resident-details {
|
||||||
min-width: 160px;
|
min-width: 160px;
|
||||||
padding: 0 12px 12px;
|
padding: 0 var(--ci-island-pad-x) var(--ci-island-pad-x);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.resident-card .resident-panel-heading {
|
.resident-card .resident-panel-heading {
|
||||||
@@ -157,12 +191,12 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 24px;
|
gap: 24px;
|
||||||
height: 40px;
|
height: var(--ci-island-height);
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
color: #ffffff94;
|
color: var(--ci-text-2);
|
||||||
font-size: 12px;
|
font-size: var(--ci-fs-caption);
|
||||||
}
|
}
|
||||||
.resident-card .resident-panel-heading .icon-btn {
|
.resident-card .resident-panel-heading .icon-btn {
|
||||||
min-height: 28px;
|
min-height: 28px;
|
||||||
@@ -176,24 +210,25 @@
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.resident-card .resident-expanded-rows {
|
.resident-card .resident-expanded-rows {
|
||||||
font-size: var(--ci-body-font, 16px);
|
font-size: var(--ci-fs-body);
|
||||||
border-top: 1px solid #ffffff1a;
|
border-top: var(--ci-stroke-island-w) solid var(--ci-stroke-divider);
|
||||||
padding-top: 8px;
|
padding-top: calc(var(--ci-component-gap) / 2);
|
||||||
}
|
}
|
||||||
.resident-card .resident-expanded-rows .row-components {
|
.resident-card .resident-expanded-rows .row-components {
|
||||||
gap: var(--row-gap, 12px);
|
gap: var(--row-gap, var(--ci-component-gap));
|
||||||
}
|
}
|
||||||
.resident-card #custom-alert-host {
|
.resident-card #custom-alert-host {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
.resident-card button:focus-visible {
|
.resident-card button:focus-visible {
|
||||||
outline: 2px solid #adc4ff;
|
outline: 2px solid var(--ci-stroke-drag);
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
@media (hover: hover) and (pointer: fine) {
|
@media (hover: hover) and (pointer: fine) {
|
||||||
.resident-card button:hover {
|
.resident-card button:hover {
|
||||||
filter: brightness(1.18);
|
background: var(--ci-accent-soft);
|
||||||
|
color: var(--ci-text-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@keyframes resident-indicator-in {
|
@keyframes resident-indicator-in {
|
||||||
@@ -240,8 +275,14 @@
|
|||||||
}
|
}
|
||||||
/* ClassIsland Fluent MainWindowLine:半透明底、1px 边框,强调遮罩只在提醒时播放。 */
|
/* ClassIsland Fluent MainWindowLine:半透明底、1px 边框,强调遮罩只在提醒时播放。 */
|
||||||
.resident-window .resident-card {
|
.resident-window .resident-card {
|
||||||
--wn-bg: #20202080;
|
--wn-bg: var(--resident-background);
|
||||||
--wn-border: #ffffff26;
|
--wn-border: var(--ci-stroke-island);
|
||||||
|
--wn-text-1: var(--ci-text-1);
|
||||||
|
--wn-text-2: var(--ci-text-2);
|
||||||
|
--wn-text-3: var(--ci-text-3);
|
||||||
|
--wn-surface: var(--ci-fill-secondary);
|
||||||
|
--wn-surface-hover: var(--ci-accent-soft);
|
||||||
|
--wn-divider: var(--ci-stroke-divider);
|
||||||
}
|
}
|
||||||
.resident-window .resident-card > .tint {
|
.resident-window .resident-card > .tint {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -250,6 +291,9 @@
|
|||||||
fill: transparent;
|
fill: transparent;
|
||||||
stroke: none;
|
stroke: none;
|
||||||
}
|
}
|
||||||
.resident-window .resident-card.message-surface {
|
.resident-card.resident-lesson {
|
||||||
--wn-bg: #202020;
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
.resident-window .resident-card.message-surface {
|
||||||
|
--resident-background: var(--ci-brand-dark);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/* 两种岛共用临近下课徽标;固定正圆,数字使用等宽字形。 */
|
||||||
|
.lesson-ending-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: var(--ci-radius-pill);
|
||||||
|
color: var(--ci-text-on-accent);
|
||||||
|
background: var(--ci-accent-fill);
|
||||||
|
font-size: var(--ci-fs-caption);
|
||||||
|
font-weight: var(--ci-fw-semi-bold);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '@classhelper/ui/tokens.css';
|
||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import IslandApp from './LayoutIslandApp.vue';
|
import IslandApp from './LayoutIslandApp.vue';
|
||||||
import { applyMotionTokens } from '../renderer/composables/motion.js';
|
import { applyMotionTokens } from '../renderer/composables/motion.js';
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ export const IPC_CHANNELS = {
|
|||||||
clearConfig: 'classhelper:config:clear',
|
clearConfig: 'classhelper:config:clear',
|
||||||
appInfo: 'classhelper:app:info',
|
appInfo: 'classhelper:app:info',
|
||||||
openExternal: 'classhelper:shell:open-external',
|
openExternal: 'classhelper:shell:open-external',
|
||||||
updateCheck: 'classhelper:update:check',
|
|
||||||
updateIgnore: 'classhelper:update:ignore',
|
|
||||||
getAutoLaunch: 'classhelper:app:get-autolaunch',
|
getAutoLaunch: 'classhelper:app:get-autolaunch',
|
||||||
setAutoLaunch: 'classhelper:app:set-autolaunch',
|
setAutoLaunch: 'classhelper:app:set-autolaunch',
|
||||||
openLogDir: 'classhelper:app:open-log-dir',
|
openLogDir: 'classhelper:app:open-log-dir',
|
||||||
@@ -28,6 +26,3 @@ export const IPC_CHANNELS = {
|
|||||||
clientStatus: 'classhelper:client:status',
|
clientStatus: 'classhelper:client:status',
|
||||||
clientBeatNow: 'classhelper:client:beat-now',
|
clientBeatNow: 'classhelper:client:beat-now',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/** 主进程 → 渲染进程的单向推送:有可用更新(同理,供 preload 与主进程共用) */
|
|
||||||
export const UPDATE_AVAILABLE_CHANNEL = 'classhelper:update:available';
|
|
||||||
@@ -38,11 +38,12 @@ interface PersistedConfig {
|
|||||||
homeworkPhrases?: string[];
|
homeworkPhrases?: string[];
|
||||||
/** 是否已看过初次启动引导(向后兼容:旧配置没有该字段视为没看过,首启弹一次) */
|
/** 是否已看过初次启动引导(向后兼容:旧配置没有该字段视为没看过,首启弹一次) */
|
||||||
onboardingDone?: boolean;
|
onboardingDone?: boolean;
|
||||||
|
onboardingVersion?: number;
|
||||||
/** 界面主题(向后兼容:旧配置没有该字段用浅色) */
|
/** 界面主题(向后兼容:旧配置没有该字段用浅色) */
|
||||||
theme?: 'light' | 'dark';
|
theme?: 'light' | 'dark';
|
||||||
/** 主侧边栏是否折叠(向后兼容:旧配置没有该字段视为展开) */
|
/** 主侧边栏是否折叠(向后兼容:旧配置没有该字段视为展开) */
|
||||||
sidebarCollapsed?: boolean;
|
sidebarCollapsed?: boolean;
|
||||||
/** 用户选择「忽略此版本」的版本号(向后兼容:旧配置没有该字段视为没忽略过任何版本) */
|
/** 旧版主动更新检查的兼容字段;统一云端下发更新后不再参与更新决策。 */
|
||||||
ignoredUpdateVersion?: string;
|
ignoredUpdateVersion?: string;
|
||||||
/** 本机设备标识(向后兼容:旧配置没有该字段时首次读取生成并落盘,之后永不变) */
|
/** 本机设备标识(向后兼容:旧配置没有该字段时首次读取生成并落盘,之后永不变) */
|
||||||
deviceKey?: string;
|
deviceKey?: string;
|
||||||
@@ -69,6 +70,7 @@ const DEFAULT_CONFIG: PersistedConfig = {
|
|||||||
homeworkBoard: { ...DEFAULT_HOMEWORK_BOARD },
|
homeworkBoard: { ...DEFAULT_HOMEWORK_BOARD },
|
||||||
homeworkPhrases: [...HOMEWORK_PHRASE_DEFAULTS],
|
homeworkPhrases: [...HOMEWORK_PHRASE_DEFAULTS],
|
||||||
onboardingDone: false,
|
onboardingDone: false,
|
||||||
|
onboardingVersion: 0,
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
sidebarCollapsed: false,
|
sidebarCollapsed: false,
|
||||||
ignoredUpdateVersion: '',
|
ignoredUpdateVersion: '',
|
||||||
@@ -134,6 +136,14 @@ function normalizeIslandAppearance(input?: Partial<IslandAppearance>): IslandApp
|
|||||||
'bottom-right',
|
'bottom-right',
|
||||||
];
|
];
|
||||||
const styles: IslandAppearance['style'][] = ['black', 'glass', 'tinted'];
|
const styles: IslandAppearance['style'][] = ['black', 'glass', 'tinted'];
|
||||||
|
const accentPalette = Array.isArray(input?.accentPalette)
|
||||||
|
? input.accentPalette
|
||||||
|
.filter((value): value is string => typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value))
|
||||||
|
.slice(0, 32)
|
||||||
|
: [...DEFAULT_ISLAND_APPEARANCE.accentPalette];
|
||||||
|
const accentSource = [0, 1, 2, 3].includes(input?.accentSource as number)
|
||||||
|
? (input?.accentSource as IslandAppearance['accentSource'])
|
||||||
|
: DEFAULT_ISLAND_APPEARANCE.accentSource;
|
||||||
return {
|
return {
|
||||||
height: clamp(input?.height, 36, 72, DEFAULT_ISLAND_APPEARANCE.height),
|
height: clamp(input?.height, 36, 72, DEFAULT_ISLAND_APPEARANCE.height),
|
||||||
width: clamp(input?.width, 220, 420, DEFAULT_ISLAND_APPEARANCE.width),
|
width: clamp(input?.width, 220, 420, DEFAULT_ISLAND_APPEARANCE.width),
|
||||||
@@ -143,6 +153,11 @@ function normalizeIslandAppearance(input?: Partial<IslandAppearance>): IslandApp
|
|||||||
typeof input?.accent === 'string' && /^#[0-9a-fA-F]{6}$/.test(input.accent)
|
typeof input?.accent === 'string' && /^#[0-9a-fA-F]{6}$/.test(input.accent)
|
||||||
? input.accent
|
? input.accent
|
||||||
: DEFAULT_ISLAND_APPEARANCE.accent,
|
: DEFAULT_ISLAND_APPEARANCE.accent,
|
||||||
|
accentSource,
|
||||||
|
accentPalette: accentPalette.length ? accentPalette : [...DEFAULT_ISLAND_APPEARANCE.accentPalette],
|
||||||
|
accentPaletteIndex: Math.round(
|
||||||
|
clamp(input?.accentPaletteIndex, 0, Math.max(0, accentPalette.length - 1), 0),
|
||||||
|
),
|
||||||
fontSize: clamp(input?.fontSize, 11, 20, DEFAULT_ISLAND_APPEARANCE.fontSize),
|
fontSize: clamp(input?.fontSize, 11, 20, DEFAULT_ISLAND_APPEARANCE.fontSize),
|
||||||
animations: input?.animations !== false,
|
animations: input?.animations !== false,
|
||||||
speed: clamp(input?.speed, 0.5, 2, DEFAULT_ISLAND_APPEARANCE.speed),
|
speed: clamp(input?.speed, 0.5, 2, DEFAULT_ISLAND_APPEARANCE.speed),
|
||||||
@@ -210,6 +225,7 @@ function readPersistedFromDisk(): PersistedConfig {
|
|||||||
homeworkBoard: normalizeHomeworkBoard(parsed.homeworkBoard),
|
homeworkBoard: normalizeHomeworkBoard(parsed.homeworkBoard),
|
||||||
homeworkPhrases: normalizeHomeworkPhrases(parsed.homeworkPhrases),
|
homeworkPhrases: normalizeHomeworkPhrases(parsed.homeworkPhrases),
|
||||||
onboardingDone: parsed.onboardingDone === true,
|
onboardingDone: parsed.onboardingDone === true,
|
||||||
|
onboardingVersion: Number.isInteger(parsed.onboardingVersion) ? Number(parsed.onboardingVersion) : 0,
|
||||||
theme: normalizeTheme(parsed.theme),
|
theme: normalizeTheme(parsed.theme),
|
||||||
sidebarCollapsed: parsed.sidebarCollapsed === true,
|
sidebarCollapsed: parsed.sidebarCollapsed === true,
|
||||||
ignoredUpdateVersion:
|
ignoredUpdateVersion:
|
||||||
@@ -373,6 +389,7 @@ function toDesktopConfig(state: ConfigCache): DesktopStoredConfig {
|
|||||||
homeworkBoard: normalizeHomeworkBoard(persisted.homeworkBoard),
|
homeworkBoard: normalizeHomeworkBoard(persisted.homeworkBoard),
|
||||||
homeworkPhrases: normalizeHomeworkPhrases(persisted.homeworkPhrases),
|
homeworkPhrases: normalizeHomeworkPhrases(persisted.homeworkPhrases),
|
||||||
onboardingDone: persisted.onboardingDone === true,
|
onboardingDone: persisted.onboardingDone === true,
|
||||||
|
onboardingVersion: persisted.onboardingVersion ?? 0,
|
||||||
theme: normalizeTheme(persisted.theme),
|
theme: normalizeTheme(persisted.theme),
|
||||||
sidebarCollapsed: persisted.sidebarCollapsed === true,
|
sidebarCollapsed: persisted.sidebarCollapsed === true,
|
||||||
ignoredUpdateVersion: persisted.ignoredUpdateVersion ?? '',
|
ignoredUpdateVersion: persisted.ignoredUpdateVersion ?? '',
|
||||||
@@ -460,6 +477,11 @@ export function saveConfig(patch: Partial<DesktopStoredConfig>): DesktopStoredCo
|
|||||||
if (patch.onboardingDone === true) {
|
if (patch.onboardingDone === true) {
|
||||||
persisted.onboardingDone = true;
|
persisted.onboardingDone = true;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
Number.isInteger(patch.onboardingVersion) &&
|
||||||
|
Number(patch.onboardingVersion) > (persisted.onboardingVersion ?? 0)
|
||||||
|
)
|
||||||
|
persisted.onboardingVersion = Number(patch.onboardingVersion);
|
||||||
if (patch.theme !== undefined) {
|
if (patch.theme !== undefined) {
|
||||||
persisted.theme = normalizeTheme(patch.theme);
|
persisted.theme = normalizeTheme(patch.theme);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { island, registerIslandIpc } from './island.js';
|
|||||||
import { logger } from './logger.js';
|
import { logger } from './logger.js';
|
||||||
import { runSmokeTest } from './smoke.js';
|
import { runSmokeTest } from './smoke.js';
|
||||||
import { createTray, destroyTray, isTrayReady } from './tray.js';
|
import { createTray, destroyTray, isTrayReady } from './tray.js';
|
||||||
import { scheduleStartupUpdateCheck } from './update.js';
|
|
||||||
|
|
||||||
// 主进程由 esbuild 打包为 CommonJS,因此这里可以直接使用 __dirname
|
// 主进程由 esbuild 打包为 CommonJS,因此这里可以直接使用 __dirname
|
||||||
// (dist/main/index.js -> dist/preload/index.js 与 dist/renderer/index.html)
|
// (dist/main/index.js -> dist/preload/index.js 与 dist/renderer/index.html)
|
||||||
@@ -259,9 +258,6 @@ if (!gotLock) {
|
|||||||
logger.warn(`系统托盘初始化失败(不影响主功能):${error instanceof Error ? error.message : error}`);
|
logger.warn(`系统托盘初始化失败(不影响主功能):${error instanceof Error ? error.message : error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启动后自动查一次更新(延迟几秒,不跟首屏抢带宽);冒烟模式下自动跳过,见 main/update.ts
|
|
||||||
scheduleStartupUpdateCheck(() => mainWindow);
|
|
||||||
|
|
||||||
// 服务端统一下发:定时上报本机状态并领取「待执行命令 / 统一更新」(冒烟默认不上报)
|
// 服务端统一下发:定时上报本机状态并领取「待执行命令 / 统一更新」(冒烟默认不上报)
|
||||||
startClientAgent();
|
startClientAgent();
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ import { island } from './island.js';
|
|||||||
import { getIslandWeather } from './island-weather.js';
|
import { getIslandWeather } from './island-weather.js';
|
||||||
import { getUpdateProgress } from './auto-update.js';
|
import { getUpdateProgress } from './auto-update.js';
|
||||||
import { app, BrowserWindow, ipcMain, shell } from 'electron';
|
import { app, BrowserWindow, ipcMain, shell } from 'electron';
|
||||||
import type { UpdateInfo } from '@classhelper/shared';
|
|
||||||
import { IPC_CHANNELS } from './channels.js';
|
import { IPC_CHANNELS } from './channels.js';
|
||||||
import { beatNow, getClientAgentStatus } from './client-agent.js';
|
import { beatNow, getClientAgentStatus } from './client-agent.js';
|
||||||
import { clearConfig, getConfig, getConfigPath, saveConfig } from './config.js';
|
import { clearConfig, getConfig, getConfigPath, saveConfig } from './config.js';
|
||||||
import { logger } from './logger.js';
|
import { logger } from './logger.js';
|
||||||
import { checkForUpdates, ignoreUpdateVersion } from './update.js';
|
|
||||||
import type { DesktopAppInfo, DesktopStoredConfig } from '../types/desktop.js';
|
import type { DesktopAppInfo, DesktopStoredConfig } from '../types/desktop.js';
|
||||||
|
|
||||||
// 通道名定义搬到了叶子模块 `channels.ts`(原因见那里的注释:preload 在沙箱里不能碰 node 内建模块);
|
// 通道名定义搬到了叶子模块 `channels.ts`(原因见那里的注释:preload 在沙箱里不能碰 node 内建模块);
|
||||||
@@ -42,6 +40,7 @@ export function registerIpcHandlers(): void {
|
|||||||
delete allowed.pendingUpdateVersion;
|
delete allowed.pendingUpdateVersion;
|
||||||
const saved = saveConfig(allowed);
|
const saved = saveConfig(allowed);
|
||||||
if (allowed.islandLayout) island.syncCustomLayout();
|
if (allowed.islandLayout) island.syncCustomLayout();
|
||||||
|
if (allowed.theme !== undefined) island.syncTheme();
|
||||||
return saved;
|
return saved;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -65,21 +64,6 @@ export function registerIpcHandlers(): void {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查更新(走主进程直连 GitHub,见 main/update.ts 的说明)。
|
|
||||||
*
|
|
||||||
* `force` 为 true 时绕过主进程缓存 —— 对应「关于」页里用户主动点的那次检查;
|
|
||||||
* 启动自动检查一律用缓存(避免同一分钟内重复请求打满匿名限流)。
|
|
||||||
*/
|
|
||||||
ipcMain.handle(IPC_CHANNELS.updateCheck, (_event, force?: boolean): Promise<UpdateInfo> => {
|
|
||||||
return checkForUpdates(force === true);
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 忽略某个版本的更新提示(记入 config.json,启动自动检查不再提示它) */
|
|
||||||
ipcMain.handle(IPC_CHANNELS.updateIgnore, (_event, version: string): void => {
|
|
||||||
if (typeof version === 'string') ignoreUpdateVersion(version);
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 开机自启:读的是系统登录项,不是配置文件里的值(两者可能被外部改过) */
|
/** 开机自启:读的是系统登录项,不是配置文件里的值(两者可能被外部改过) */
|
||||||
ipcMain.handle(IPC_CHANNELS.getAutoLaunch, (): boolean => {
|
ipcMain.handle(IPC_CHANNELS.getAutoLaunch, (): boolean => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import type {
|
|||||||
} from '@classhelper/shared';
|
} from '@classhelper/shared';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
import { BrowserWindow, ipcMain, screen } from 'electron';
|
import { BrowserWindow, ipcMain, screen, systemPreferences } from 'electron';
|
||||||
import {
|
import {
|
||||||
COURSEWARE_ISLAND_SIZE,
|
COURSEWARE_ISLAND_SIZE,
|
||||||
|
CLASSISLAND_TOKENS,
|
||||||
type CoursewareTransfer,
|
type CoursewareTransfer,
|
||||||
DEFAULT_ISLAND_APPEARANCE,
|
DEFAULT_ISLAND_APPEARANCE,
|
||||||
CLASSISLAND_ISLAND_METRICS,
|
CLASSISLAND_ISLAND_METRICS,
|
||||||
@@ -171,6 +172,7 @@ class IslandController {
|
|||||||
private lessonTimer: ReturnType<typeof setInterval> | null = null;
|
private lessonTimer: ReturnType<typeof setInterval> | null = null;
|
||||||
private lessonTestTime: number | null = null;
|
private lessonTestTime: number | null = null;
|
||||||
private get lessonShowing(): boolean {
|
private get lessonShowing(): boolean {
|
||||||
|
if (this.customLayout && this.lessonCue?.kind === 'ending') return false;
|
||||||
return Boolean(
|
return Boolean(
|
||||||
this.lessonCue &&
|
this.lessonCue &&
|
||||||
!this.editingLayout &&
|
!this.editingLayout &&
|
||||||
@@ -335,6 +337,13 @@ class IslandController {
|
|||||||
this.syncResidentShape(true);
|
this.syncResidentShape(true);
|
||||||
this.syncWindow();
|
this.syncWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 主题独立于外观补丁,主窗口切肤时实时同步给岛渲染进程。 */
|
||||||
|
syncTheme(): void {
|
||||||
|
if (!this.win || this.win.isDestroyed()) return;
|
||||||
|
this.win.webContents.send('island:theme', getConfig().theme);
|
||||||
|
}
|
||||||
|
|
||||||
/** 仅用于首次切换布局、启动与退出编辑;日常常驻岛开合保持窗口可见。 */
|
/** 仅用于首次切换布局、启动与退出编辑;日常常驻岛开合保持窗口可见。 */
|
||||||
private settleCustomLayout(): void {
|
private settleCustomLayout(): void {
|
||||||
if (this.layoutSettleTimer) clearTimeout(this.layoutSettleTimer);
|
if (this.layoutSettleTimer) clearTimeout(this.layoutSettleTimer);
|
||||||
@@ -622,6 +631,7 @@ class IslandController {
|
|||||||
}
|
}
|
||||||
// 首次进入时同步一次外观与状态,保证渲染进程不会停在初始默认值
|
// 首次进入时同步一次外观与状态,保证渲染进程不会停在初始默认值
|
||||||
this.emitAppearance();
|
this.emitAppearance();
|
||||||
|
this.syncTheme();
|
||||||
this.win?.webContents.send('island:schedules', this.schedules);
|
this.win?.webContents.send('island:schedules', this.schedules);
|
||||||
this.win?.webContents.send('island:time-points', this.timePoints);
|
this.win?.webContents.send('island:time-points', this.timePoints);
|
||||||
this.emit();
|
this.emit();
|
||||||
@@ -649,7 +659,10 @@ class IslandController {
|
|||||||
return {
|
return {
|
||||||
...this.state,
|
...this.state,
|
||||||
coursewareTransfer: this.coursewareShowing ? this.state.coursewareTransfer : null,
|
coursewareTransfer: this.coursewareShowing ? this.state.coursewareTransfer : null,
|
||||||
lessonReminder: this.lessonShowing ? this.lessonCue : null,
|
lessonReminder:
|
||||||
|
this.lessonShowing || (this.customLayout && this.lessonCue?.kind === 'ending')
|
||||||
|
? this.lessonCue
|
||||||
|
: null,
|
||||||
queued: [...this.state.queued],
|
queued: [...this.state.queued],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -770,7 +783,7 @@ class IslandController {
|
|||||||
private refreshViewport(): void {
|
private refreshViewport(): void {
|
||||||
const area = this.targetDisplay().workArea;
|
const area = this.targetDisplay().workArea;
|
||||||
const anchor = this.resolveAnchor();
|
const anchor = this.resolveAnchor();
|
||||||
const marginY = Math.round(this.appearance.marginY ?? ISLAND_MARGIN);
|
const marginY = this.verticalMargin();
|
||||||
const available =
|
const available =
|
||||||
anchor.vMode === 'bottom'
|
anchor.vMode === 'bottom'
|
||||||
? anchor.vValue - (area.y + marginY)
|
? anchor.vValue - (area.y + marginY)
|
||||||
@@ -1329,7 +1342,7 @@ class IslandController {
|
|||||||
const display = this.targetDisplay();
|
const display = this.targetDisplay();
|
||||||
const area = display.workArea;
|
const area = display.workArea;
|
||||||
const marginX = Math.round(this.appearance.marginX ?? ISLAND_MARGIN);
|
const marginX = Math.round(this.appearance.marginX ?? ISLAND_MARGIN);
|
||||||
const marginY = Math.round(this.appearance.marginY ?? ISLAND_MARGIN);
|
const marginY = this.verticalMargin();
|
||||||
const center = Math.round(area.x + area.width / 2);
|
const center = Math.round(area.x + area.width / 2);
|
||||||
|
|
||||||
// 6 个停靠位置(顶/底 × 左/中/右),与 WinIsland 的 DockPosition 一一对应
|
// 6 个停靠位置(顶/底 × 左/中/右),与 WinIsland 的 DockPosition 一一对应
|
||||||
@@ -1346,6 +1359,12 @@ class IslandController {
|
|||||||
return { hMode, hValue, vMode, vValue };
|
return { hMode, hValue, vMode, vValue };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 自定义岛遵循 ClassIsland Fluent 的 20px 竖直安全区;经典岛保留原有外观边距。 */
|
||||||
|
private verticalMargin(): number {
|
||||||
|
const configured = Math.round(this.appearance.marginY ?? ISLAND_MARGIN);
|
||||||
|
return this.customLayout ? Math.max(configured, CLASSISLAND_TOKENS.dpi.verticalSafeArea) : configured;
|
||||||
|
}
|
||||||
|
|
||||||
/** 当前应该把岛放在哪块屏上:跟随鼠标时用光标所在屏,否则用主屏 */
|
/** 当前应该把岛放在哪块屏上:跟随鼠标时用光标所在屏,否则用主屏 */
|
||||||
private targetDisplay(cursor?: { x: number; y: number } | null): Electron.Display {
|
private targetDisplay(cursor?: { x: number; y: number } | null): Electron.Display {
|
||||||
return this.appearance.followCursorDisplay
|
return this.appearance.followCursorDisplay
|
||||||
@@ -1520,7 +1539,7 @@ class IslandController {
|
|||||||
// 与 ClassIsland 一样,让背景/内容在固定画布内过渡。预留一帧绘制边界,避免过冲裁切。
|
// 与 ClassIsland 一样,让背景/内容在固定画布内过渡。预留一帧绘制边界,避免过冲裁切。
|
||||||
return {
|
return {
|
||||||
width: Math.min(960, area.width),
|
width: Math.min(960, area.width),
|
||||||
height: Math.min(640, Math.max(60, area.height - this.appearance.marginY)),
|
height: Math.min(640, Math.max(60, area.height - this.verticalMargin())),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (this.customLayout)
|
if (this.customLayout)
|
||||||
@@ -1731,14 +1750,14 @@ class IslandController {
|
|||||||
* 2. 材质的明暗跟随**应用主题**:本客户端是浅色 Fluent 主题,亚克力必然是浅色,
|
* 2. 材质的明暗跟随**应用主题**:本客户端是浅色 Fluent 主题,亚克力必然是浅色,
|
||||||
* 无法像 WinIsland 那样自带深色 tint(`Color::from_argb(150, 10, 10, 14)`)。
|
* 无法像 WinIsland 那样自带深色 tint(`Color::from_argb(150, 10, 10, 14)`)。
|
||||||
* 3. 更糟的是:只要调用过一次(**包括 `'none'`**),窗口就再也不是逐像素透明的了 ——
|
* 3. 更糟的是:只要调用过一次(**包括 `'none'`**),窗口就再也不是逐像素透明的了 ——
|
||||||
* Electron 会让它回落到默认不透明底色(`backgroundColor` 默认 `#FFF`),
|
* Electron 会让它回落到默认不透明白色底,
|
||||||
* 于是从 `glass` 切到 `black` / `tinted` 之后,卡片周围会永久留一圈**纯白**。
|
* 于是从 `glass` 切到 `black` / `tinted` 之后,卡片周围会永久留一圈**纯白**。
|
||||||
* 这正好对应"毛玻璃和主题色渐变会出现白底"的现象。
|
* 这正好对应"毛玻璃和主题色渐变会出现白底"的现象。
|
||||||
* 4. CSS `backdrop-filter: blur()` 也不能替代:透明窗口里 Chromium 采样不到窗口之后的桌面,
|
* 4. CSS `backdrop-filter: blur()` 也不能替代:透明窗口里 Chromium 采样不到窗口之后的桌面,
|
||||||
* 真机实测与不加模糊的像素完全一致(卡片区域离散度都是 12.7)。
|
* 真机实测与不加模糊的像素完全一致(卡片区域离散度都是 12.7)。
|
||||||
*
|
*
|
||||||
* 结论:`glass` 风格改为**纯 CSS 半透明深色卡片**(取 WinIsland 拿不到 host backdrop 时的
|
* 结论:`glass` 风格改为**纯 CSS 半透明深色卡片**(取 WinIsland 拿不到 host backdrop 时的
|
||||||
* 官方降级色 `rgba(32,32,36,0.804)`,见 `docs/dev/winisland-design-tokens.md`),
|
* 官方 80.4% 深色降级底,见 `docs/dev/winisland-design-tokens.md`),
|
||||||
* 桌面透过率由卡片自身 alpha 决定,窗口始终保持 `transparent: true` 的逐像素透明。
|
* 桌面透过率由卡片自身 alpha 决定,窗口始终保持 `transparent: true` 的逐像素透明。
|
||||||
* 回归用例:「个性设置:卡片外圈透出桌面(三种风格都没有白底面板)」。
|
* 回归用例:「个性设置:卡片外圈透出桌面(三种风格都没有白底面板)」。
|
||||||
*/
|
*/
|
||||||
@@ -2169,7 +2188,40 @@ class IslandController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAppearance(): IslandAppearance {
|
getAppearance(): IslandAppearance {
|
||||||
return { ...this.appearance };
|
return { ...this.appearance, resolvedAccent: this.effectiveAccent() };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ClassIsland ColorSource 分支;1/3 取已选调色板,2 取系统强调色。 */
|
||||||
|
private effectiveAccent(): string {
|
||||||
|
const fallback = CLASSISLAND_TOKENS.colors.light.accentPaletteFallback;
|
||||||
|
const { accentSource, accent, accentPalette, accentPaletteIndex } = this.appearance;
|
||||||
|
if (accentSource === 0) return accent || fallback;
|
||||||
|
if (accentSource === 1 || accentSource === 3) {
|
||||||
|
return accentPalette[accentPaletteIndex] ?? fallback;
|
||||||
|
}
|
||||||
|
if (accentSource === 2) {
|
||||||
|
try {
|
||||||
|
let value: string | boolean | undefined;
|
||||||
|
try {
|
||||||
|
value = systemPreferences.getAccentColor?.();
|
||||||
|
} catch {
|
||||||
|
// Windows 旧系统可能只在窗口 API 暴露系统强调色。
|
||||||
|
}
|
||||||
|
if (typeof value !== 'string' && process.platform === 'win32') value = this.win?.getAccentColor();
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
const hex = value.replace('#', '');
|
||||||
|
return `#${hex.length === 8 ? hex.slice(0, 6) : hex.slice(-6)}`;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 平台不提供系统强调色时走 ClassIsland 的 DodgerBlue 兜底。
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 系统强调色变化时仅刷新“跟随系统”来源,不影响自定义色和其他来源。 */
|
||||||
|
syncSystemAccent(): void {
|
||||||
|
if (this.appearance.accentSource === 2) this.emitAppearance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 把外观同步给灵动岛渲染进程(CSS 变量) */
|
/** 把外观同步给灵动岛渲染进程(CSS 变量) */
|
||||||
@@ -2239,12 +2291,22 @@ const clamp = (value: number, min: number, max: number, fallback: number): numbe
|
|||||||
/** 夹紧外观取值(越界值直接收敛,避免用户配置破坏布局) */
|
/** 夹紧外观取值(越界值直接收敛,避免用户配置破坏布局) */
|
||||||
export function normalizeAppearance(input: IslandAppearance): IslandAppearance {
|
export function normalizeAppearance(input: IslandAppearance): IslandAppearance {
|
||||||
const fallbackOf = DEFAULT_ISLAND_APPEARANCE;
|
const fallbackOf = DEFAULT_ISLAND_APPEARANCE;
|
||||||
|
const accentPalette = Array.isArray(input.accentPalette)
|
||||||
|
? input.accentPalette
|
||||||
|
.filter((value) => typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value))
|
||||||
|
.slice(0, 32)
|
||||||
|
: [...fallbackOf.accentPalette];
|
||||||
return {
|
return {
|
||||||
height: clamp(input.height, 36, 72, fallbackOf.height),
|
height: clamp(input.height, 36, 72, fallbackOf.height),
|
||||||
width: clamp(input.width, 220, 420, fallbackOf.width),
|
width: clamp(input.width, 220, 420, fallbackOf.width),
|
||||||
radius: clamp(input.radius, 8, 32, fallbackOf.radius),
|
radius: clamp(input.radius, 8, 32, fallbackOf.radius),
|
||||||
opacity: clamp(input.opacity, 0.4, 1, fallbackOf.opacity),
|
opacity: clamp(input.opacity, 0.4, 1, fallbackOf.opacity),
|
||||||
accent: /^#[0-9a-fA-F]{6}$/.test(input.accent) ? input.accent : DEFAULT_ISLAND_APPEARANCE.accent,
|
accent: /^#[0-9a-fA-F]{6}$/.test(input.accent) ? input.accent : DEFAULT_ISLAND_APPEARANCE.accent,
|
||||||
|
accentSource: [0, 1, 2, 3].includes(input.accentSource) ? input.accentSource : fallbackOf.accentSource,
|
||||||
|
accentPalette: accentPalette.length ? accentPalette : [...fallbackOf.accentPalette],
|
||||||
|
accentPaletteIndex: Math.round(
|
||||||
|
clamp(input.accentPaletteIndex, 0, Math.max(0, accentPalette.length - 1), 0),
|
||||||
|
),
|
||||||
fontSize: clamp(input.fontSize, 11, 20, fallbackOf.fontSize),
|
fontSize: clamp(input.fontSize, 11, 20, fallbackOf.fontSize),
|
||||||
animations: input.animations !== false,
|
animations: input.animations !== false,
|
||||||
speed: clamp(input.speed, 0.5, 2, fallbackOf.speed),
|
speed: clamp(input.speed, 0.5, 2, fallbackOf.speed),
|
||||||
@@ -2332,6 +2394,8 @@ export const island = new IslandController();
|
|||||||
|
|
||||||
/** 注册灵动岛相关 IPC(主窗口渲染进程 -> 主进程;灵动岛渲染进程 -> 主进程) */
|
/** 注册灵动岛相关 IPC(主窗口渲染进程 -> 主进程;灵动岛渲染进程 -> 主进程) */
|
||||||
export function registerIslandIpc(): void {
|
export function registerIslandIpc(): void {
|
||||||
|
systemPreferences.on('accent-color-changed', () => island.syncSystemAccent());
|
||||||
|
ipcMain.handle('island:get-theme', () => getConfig().theme);
|
||||||
ipcMain.handle('island:get-schedules', (event) =>
|
ipcMain.handle('island:get-schedules', (event) =>
|
||||||
event.sender === island.getWindow()?.webContents ? island.getSchedules() : [],
|
event.sender === island.getWindow()?.webContents ? island.getSchedules() : [],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ export async function verifyLayoutSmoke(
|
|||||||
await editor.webContents.executeJavaScript(`document.querySelector('[aria-label="新建方案"]').click()`);
|
await editor.webContents.executeJavaScript(`document.querySelector('[aria-label="新建方案"]').click()`);
|
||||||
await pause();
|
await pause();
|
||||||
await editor.webContents.executeJavaScript(
|
await editor.webContents.executeJavaScript(
|
||||||
`(() => { const input=document.querySelector('.el-message-box__input input'); input.value='组件方案验收';input.dispatchEvent(new Event('input',{bubbles:true}));document.querySelector('.el-message-box__btns .el-button--primary').click(); })()`,
|
`(() => { const input=[...document.querySelectorAll('.el-message-box__input input')].filter(e=>e.getBoundingClientRect().width>0).at(-1); input.value='组件方案验收';input.dispatchEvent(new Event('input',{bubbles:true}));[...document.querySelectorAll('.el-message-box__btns .el-button--primary')].filter(e=>e.getBoundingClientRect().width>0).at(-1).click(); })()`,
|
||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
if (getConfig().islandLayout.schemes.length !== 2) throw Error('新建方案没有保存');
|
if (getConfig().islandLayout.schemes.length !== 2) throw Error('新建方案没有保存');
|
||||||
@@ -274,7 +274,7 @@ export async function verifyLayoutSmoke(
|
|||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
await editor.webContents.executeJavaScript(
|
await editor.webContents.executeJavaScript(
|
||||||
`document.querySelector('.el-message-box__btns .el-button--primary').click()`,
|
`[...document.querySelectorAll('.el-message-box__btns .el-button--primary')].filter(e=>e.getBoundingClientRect().width>0).at(-1).click()`,
|
||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
await editor.webContents.executeJavaScript(`document.querySelector('[aria-label="管理方案"]').click()`);
|
await editor.webContents.executeJavaScript(`document.querySelector('[aria-label="管理方案"]').click()`);
|
||||||
@@ -284,14 +284,26 @@ export async function verifyLayoutSmoke(
|
|||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
await editor.webContents.executeJavaScript(
|
await editor.webContents.executeJavaScript(
|
||||||
`document.querySelector('.el-message-box__btns .el-button--primary').click()`,
|
`[...document.querySelectorAll('.el-message-box__btns .el-button--primary')].filter(e=>e.getBoundingClientRect().width>0).at(-1).click()`,
|
||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
return (
|
const restored =
|
||||||
getConfig().islandLayout.schemes.length === 1 &&
|
getConfig().islandLayout.schemes.length === 1 &&
|
||||||
getConfig().islandLayout.activeSchemeId === 'default' &&
|
getConfig().islandLayout.activeSchemeId === 'default' &&
|
||||||
getConfig().islandLayout.schemes[0]!.rows.length === 2
|
getConfig().islandLayout.schemes[0]!.rows.length === 2;
|
||||||
|
if (!restored)
|
||||||
|
throw Error(
|
||||||
|
'方案未恢复:' +
|
||||||
|
JSON.stringify({
|
||||||
|
active: getConfig().islandLayout.activeSchemeId,
|
||||||
|
schemes: getConfig().islandLayout.schemes.map((s) => ({
|
||||||
|
id: s.id,
|
||||||
|
name: s.name,
|
||||||
|
rows: s.rows.length,
|
||||||
|
})),
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
return restored;
|
||||||
});
|
});
|
||||||
await check('方案 JSON 导入导出保留容器结构并重新生成标识', async () => {
|
await check('方案 JSON 导入导出保留容器结构并重新生成标识', async () => {
|
||||||
await editor.webContents.executeJavaScript(`document.querySelector('[aria-label="管理方案"]').click()`);
|
await editor.webContents.executeJavaScript(`document.querySelector('[aria-label="管理方案"]').click()`);
|
||||||
@@ -329,10 +341,22 @@ export async function verifyLayoutSmoke(
|
|||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
await editor.webContents.executeJavaScript(
|
await editor.webContents.executeJavaScript(
|
||||||
`document.querySelector('.el-message-box__btns .el-button--primary').click()`,
|
`[...document.querySelectorAll('.el-message-box__btns .el-button--primary')].filter(e=>e.getBoundingClientRect().width>0).at(-1).click()`,
|
||||||
);
|
);
|
||||||
await pause();
|
await pause();
|
||||||
return preserved && getConfig().islandLayout.schemes.length === 1;
|
if (!preserved || getConfig().islandLayout.schemes.length !== 1)
|
||||||
|
throw Error(
|
||||||
|
'方案导入或收尾不一致:' +
|
||||||
|
JSON.stringify({
|
||||||
|
preserved,
|
||||||
|
schemes: getConfig().islandLayout.schemes.map((s) => ({
|
||||||
|
id: s.id,
|
||||||
|
name: s.name,
|
||||||
|
rows: s.rows.length,
|
||||||
|
})),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
if (process.env.ISLAND_SHOTS_DIR) {
|
if (process.env.ISLAND_SHOTS_DIR) {
|
||||||
await editor.webContents.executeJavaScript(`document.querySelector('.main').scrollTop=0`);
|
await editor.webContents.executeJavaScript(`document.querySelector('.main').scrollTop=0`);
|
||||||
@@ -379,8 +403,10 @@ export async function verifyLayoutSmoke(
|
|||||||
await pause();
|
await pause();
|
||||||
const result = await win.webContents.executeJavaScript(`(() => {
|
const result = await win.webContents.executeJavaScript(`(() => {
|
||||||
const card=document.querySelector('.resident-card'), content=card?.querySelector('.classic-notifications'),r=card?.getBoundingClientRect(),c=content?.getBoundingClientRect();
|
const card=document.querySelector('.resident-card'), content=card?.querySelector('.classic-notifications'),r=card?.getBoundingClientRect(),c=content?.getBoundingClientRect();
|
||||||
const valid=Boolean(content&&content.textContent.includes('组件化提醒验收')&&card.querySelectorAll('.shape').length===1&&c.left>=r.left-1&&c.right<=r.right+1&&c.bottom<=r.bottom+1);
|
const shape=card?.querySelectorAll('.shape').length;
|
||||||
return {valid,card:r?.toJSON(),content:c?.toJSON(),shape:card?.querySelectorAll('.shape').length};
|
const radius=parseFloat(card ? getComputedStyle(card).borderTopLeftRadius : '0');
|
||||||
|
const valid=Boolean(content&&content.textContent.includes('组件化提醒验收')&&shape===0&&radius>0&&c.left>=r.left-1&&c.right<=r.right+1&&c.bottom<=r.bottom+1);
|
||||||
|
return {valid,card:r?.toJSON(),content:c?.toJSON(),shape,radius};
|
||||||
})()`);
|
})()`);
|
||||||
if (!result.valid) throw Error(JSON.stringify(result));
|
if (!result.valid) throw Error(JSON.stringify(result));
|
||||||
return island.getState().mode === 'expanded';
|
return island.getState().mode === 'expanded';
|
||||||
|
|||||||
@@ -83,6 +83,59 @@ export async function runQuickSmoke(win: BrowserWindow): Promise<void> {
|
|||||||
return result.detail;
|
return result.detail;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
await check('主窗口最小与常规尺寸、深浅主题及关怀字号无页面横向溢出', async () => {
|
||||||
|
const bounds = win.getContentBounds();
|
||||||
|
const appearance = await win.webContents.executeJavaScript(
|
||||||
|
`({className:document.documentElement.className,style:document.documentElement.getAttribute('style')})`,
|
||||||
|
);
|
||||||
|
const shots = path.resolve(app.getAppPath(), '../../docs/screenshots/desktop-responsive');
|
||||||
|
fs.mkdirSync(shots, { recursive: true });
|
||||||
|
await win.webContents.executeJavaScript('window.__classhelperSmoke__.islandEditorSmoke(true)');
|
||||||
|
try {
|
||||||
|
for (const [width, height] of [
|
||||||
|
[1000, 540],
|
||||||
|
[1242, 582],
|
||||||
|
[1920, 1080],
|
||||||
|
])
|
||||||
|
for (const theme of ['light', 'dark']) {
|
||||||
|
win.setContentSize(width!, height!);
|
||||||
|
await win.webContents.executeJavaScript(
|
||||||
|
`document.documentElement.classList.toggle('dark',${theme === 'dark'});document.documentElement.classList.toggle('care-mode',${theme === 'dark'});document.documentElement.style.setProperty('--ch-font-scale',${JSON.stringify(theme === 'dark' ? '1.5' : '1')})`,
|
||||||
|
);
|
||||||
|
for (const route of [
|
||||||
|
'/schedule',
|
||||||
|
'/homeworks',
|
||||||
|
'/notifications',
|
||||||
|
'/grades',
|
||||||
|
'/courseware',
|
||||||
|
'/settings/general',
|
||||||
|
'/settings/appearance',
|
||||||
|
'/settings/island',
|
||||||
|
'/settings/island/editor',
|
||||||
|
'/settings/reminder',
|
||||||
|
'/settings/account',
|
||||||
|
'/settings/about',
|
||||||
|
]) {
|
||||||
|
await win.webContents.executeJavaScript(`location.hash=${JSON.stringify('#' + route)}`);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 150));
|
||||||
|
if (
|
||||||
|
!(await win.webContents.executeJavaScript('document.documentElement.scrollWidth<=innerWidth+1'))
|
||||||
|
)
|
||||||
|
throw new Error(`${route} ${width} ${theme} 页面溢出`);
|
||||||
|
}
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(shots, `main-${width}-${theme}.png`),
|
||||||
|
(await win.webContents.capturePage()).toPNG(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await win.webContents.executeJavaScript(
|
||||||
|
`document.documentElement.className=${JSON.stringify(appearance.className)};document.documentElement.setAttribute('style',${JSON.stringify(appearance.style || '')});window.__classhelperSmoke__.islandEditorSmoke(false)`,
|
||||||
|
);
|
||||||
|
win.setContentSize(bounds.width, bounds.height);
|
||||||
|
}
|
||||||
|
return '1000×540、1242×582、1920×1080,截图保存在 docs/screenshots/desktop-responsive';
|
||||||
|
});
|
||||||
await verifyAgentSmoke(check);
|
await verifyAgentSmoke(check);
|
||||||
await verifyLayoutSmoke(check);
|
await verifyLayoutSmoke(check);
|
||||||
await verifyCoursewareSmoke(check);
|
await verifyCoursewareSmoke(check);
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ export async function verifyResidentSmoke(
|
|||||||
await pause(700);
|
await pause(700);
|
||||||
return Math.abs(immediate - opacity) < 0.01 && Math.abs(after - opacity) < 0.01;
|
return Math.abs(immediate - opacity) < 0.01 && Math.abs(after - opacity) < 0.01;
|
||||||
});
|
});
|
||||||
await check('两种布局均弹出ClassIsland课前/上下课提醒,倒计时与右侧时间正确且不写入通知队列', async () => {
|
await check('两种布局的上下课提醒、课程旁下课倒数与右侧时间正确且不写入通知队列', async () => {
|
||||||
const capture = process.env.ISLAND_MOTION_CAPTURE === '1' && process.env.ELECTRON_SMOKE_MODE === 'visual';
|
const capture = process.env.ISLAND_MOTION_CAPTURE === '1' && process.env.ELECTRON_SMOKE_MODE === 'visual';
|
||||||
const recorded: Array<{ at: number; image: Electron.NativeImage }> = [];
|
const recorded: Array<{ at: number; image: Electron.NativeImage }> = [];
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
@@ -642,17 +642,33 @@ export async function verifyResidentSmoke(
|
|||||||
throw new Error('自动倒计时未切到本节下课');
|
throw new Error('自动倒计时未切到本节下课');
|
||||||
}
|
}
|
||||||
if (layout === 'custom') {
|
if (layout === 'custom') {
|
||||||
saveConfig({ islandLayout: { ...fixture, layout } });
|
const endingLayout = JSON.parse(JSON.stringify(fixture));
|
||||||
|
endingLayout.schemes[0].rows[0].nodes = [islandNode('schedule', 'lesson-ending-course')];
|
||||||
|
saveConfig({ islandLayout: endingLayout });
|
||||||
island.syncCustomLayout();
|
island.syncCustomLayout();
|
||||||
}
|
}
|
||||||
await setTime(9, 44);
|
await setTime(9, 44);
|
||||||
await pause(700);
|
await pause(1100);
|
||||||
if (island.getState().lessonReminder?.kind !== 'ending')
|
if (island.getState().lessonReminder?.kind !== 'ending')
|
||||||
throw new Error(layout + '下课倒数状态错误:' + JSON.stringify(island.getState().lessonReminder));
|
throw new Error(layout + '下课倒数状态错误:' + JSON.stringify(island.getState().lessonReminder));
|
||||||
const ending = await win.webContents.executeJavaScript(
|
const ending = await win.webContents.executeJavaScript(
|
||||||
`document.querySelector('${layout === 'custom' ? '.resident-lesson-page' : '.ci-fixed-lesson'}')?.textContent.includes('距下课还剩')`,
|
`(() => {
|
||||||
|
const root=document.querySelector('${layout === 'custom' ? '.resident-compact' : '.ci-fixed-lesson'}');
|
||||||
|
const badge=root?.querySelector('.lesson-ending-badge');
|
||||||
|
const course=root?.querySelector('${layout === 'custom' ? '.lesson-line.current strong' : '.ci-lesson-course strong'}');
|
||||||
|
const rect=badge?.getBoundingClientRect(),name=course?.getBoundingClientRect();
|
||||||
|
return Boolean(badge?.textContent.trim()==='-60'&&rect&&name&&rect.left>=name.right&&Math.abs(rect.width-rect.height)<1&&!root?.querySelector('.ci-mask-active'));
|
||||||
|
})()`,
|
||||||
);
|
);
|
||||||
if (!ending) throw new Error(layout + '下课倒数未渲染');
|
if (!ending) throw new Error(layout + '下课倒数未渲染');
|
||||||
|
await setTime(9, 44, 59);
|
||||||
|
await pause(1100);
|
||||||
|
if (
|
||||||
|
!(await win.webContents.executeJavaScript(
|
||||||
|
`document.querySelector('${layout === 'custom' ? '.resident-compact' : '.ci-fixed-lesson'} .lesson-ending-badge')?.textContent.trim()==='-1'`,
|
||||||
|
))
|
||||||
|
)
|
||||||
|
throw new Error(layout + '最后一秒徽标错误');
|
||||||
await shot('lesson-ending-' + layout);
|
await shot('lesson-ending-' + layout);
|
||||||
await setTime(9, 45);
|
await setTime(9, 45);
|
||||||
island.setClassState({ inClass: false });
|
island.setClassState({ inClass: false });
|
||||||
@@ -894,9 +910,12 @@ export async function verifyResidentSmoke(
|
|||||||
const solid = await win.webContents.executeJavaScript(`(() => {
|
const solid = await win.webContents.executeJavaScript(`(() => {
|
||||||
const card=document.querySelector('${layout === 'custom' ? '.resident-card' : '.island-card'}');
|
const card=document.querySelector('${layout === 'custom' ? '.resident-card' : '.island-card'}');
|
||||||
if (!card?.classList.contains('message-surface')) return false;
|
if (!card?.classList.contains('message-surface')) return false;
|
||||||
|
let color=getComputedStyle(card).backgroundColor;
|
||||||
|
if (${JSON.stringify(layout)} === 'fixed') {
|
||||||
const probe=document.createElement('span');probe.style.background='var(--wn-bg)';card.append(probe);
|
const probe=document.createElement('span');probe.style.background='var(--wn-bg)';card.append(probe);
|
||||||
const color=getComputedStyle(probe).backgroundColor;probe.remove();
|
color=getComputedStyle(probe).backgroundColor;probe.remove();
|
||||||
return color==='rgb(32, 32, 32)'&&!!card.querySelector('.classic-notifications');
|
}
|
||||||
|
return color!=='transparent'&&!color.includes('rgba')&&!!card.querySelector('.classic-notifications');
|
||||||
})()`);
|
})()`);
|
||||||
if (!solid || Math.abs(win.getOpacity() - 1) > 0.01 || island.getAppearance().opacity !== 0.45)
|
if (!solid || Math.abs(win.getOpacity() - 1) > 0.01 || island.getAppearance().opacity !== 0.45)
|
||||||
return false;
|
return false;
|
||||||
@@ -917,12 +936,15 @@ export async function verifyResidentSmoke(
|
|||||||
island.setClassState({ inClass: false, currentPeriodEnd: null, week: 1 });
|
island.setClassState({ inClass: false, currentPeriodEnd: null, week: 1 });
|
||||||
saveConfig({ islandLayout: defaultIslandLayouts() });
|
saveConfig({ islandLayout: defaultIslandLayouts() });
|
||||||
island.syncCustomLayout();
|
island.syncCustomLayout();
|
||||||
await pause();
|
await pause(400);
|
||||||
return (
|
const visible = win.isVisible();
|
||||||
!win.isVisible() &&
|
const residentEnabled = getConfig().islandLayout.residentEnabled;
|
||||||
!getConfig().islandLayout.residentEnabled &&
|
const customDom = await win.webContents.executeJavaScript(
|
||||||
(await win.webContents.executeJavaScript(`!document.querySelector('.custom-card')`))
|
`Boolean(document.querySelector('.custom-card'))`,
|
||||||
);
|
);
|
||||||
|
if (visible || residentEnabled || customDom)
|
||||||
|
throw new Error(JSON.stringify({ visible, residentEnabled, customDom }));
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
island.setHitTestCursor(null);
|
island.setHitTestCursor(null);
|
||||||
island.setTouchMode(originalTouchMode);
|
island.setTouchMode(originalTouchMode);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
ISLAND_URGENT_SIZE,
|
ISLAND_URGENT_SIZE,
|
||||||
} from './island.js';
|
} from './island.js';
|
||||||
import { destroyTray, getTrayState, isTrayReady } from './tray.js';
|
import { destroyTray, getTrayState, isTrayReady } from './tray.js';
|
||||||
import { checkForUpdates, wasStartupCheckSkipped } from './update.js';
|
|
||||||
|
|
||||||
interface SmokeResult {
|
interface SmokeResult {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -2660,7 +2659,7 @@ async function runIslandChecks(
|
|||||||
h: style.getPropertyValue('--island-h').trim(),
|
h: style.getPropertyValue('--island-h').trim(),
|
||||||
w: style.getPropertyValue('--island-w').trim(),
|
w: style.getPropertyValue('--island-w').trim(),
|
||||||
font: style.getPropertyValue('--island-font').trim(),
|
font: style.getPropertyValue('--island-font').trim(),
|
||||||
accent: style.getPropertyValue('--island-accent').trim(),
|
accent: style.getPropertyValue('--ci-accent').trim(),
|
||||||
};
|
};
|
||||||
})()`,
|
})()`,
|
||||||
)
|
)
|
||||||
@@ -2717,7 +2716,7 @@ async function runIslandChecks(
|
|||||||
w: style.getPropertyValue('--island-w').trim(),
|
w: style.getPropertyValue('--island-w').trim(),
|
||||||
radius: style.getPropertyValue('--island-radius').trim(),
|
radius: style.getPropertyValue('--island-radius').trim(),
|
||||||
font: style.getPropertyValue('--island-font').trim(),
|
font: style.getPropertyValue('--island-font').trim(),
|
||||||
accent: style.getPropertyValue('--island-accent').trim(),
|
accent: style.getPropertyValue('--ci-accent').trim(),
|
||||||
cardHeight: card ? Math.round(card.getBoundingClientRect().height) : 0,
|
cardHeight: card ? Math.round(card.getBoundingClientRect().height) : 0,
|
||||||
};
|
};
|
||||||
})()`,
|
})()`,
|
||||||
@@ -3078,7 +3077,9 @@ async function runIslandChecks(
|
|||||||
`${islandStateSummary()}`,
|
`${islandStateSummary()}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 10.7) 视觉风格:纯黑 / 毛玻璃(亚克力)/ 主题色渐变,切换立即生效
|
// 消息使用实色底;先清空消息,单独验证用户设置的三种基础风格。
|
||||||
|
await drainIsland();
|
||||||
|
await sleep(260);
|
||||||
const probeStyle = async (style: IslandAppearance['style']): Promise<{ fill: string; stroke: string }> => {
|
const probeStyle = async (style: IslandAppearance['style']): Promise<{ fill: string; stroke: string }> => {
|
||||||
island.setAppearance({ ...appearanceBefore, style });
|
island.setAppearance({ ...appearanceBefore, style });
|
||||||
await sleep(260);
|
await sleep(260);
|
||||||
@@ -3102,7 +3103,7 @@ async function runIslandChecks(
|
|||||||
const glassStyle = await probeStyle('glass');
|
const glassStyle = await probeStyle('glass');
|
||||||
const tintedStyle = await probeStyle('tinted');
|
const tintedStyle = await probeStyle('tinted');
|
||||||
record(
|
record(
|
||||||
'视觉风格切换立刻生效(纯黑 / 毛玻璃半透明 / 主题色)',
|
'无消息时视觉风格切换立刻生效(纯黑 / 毛玻璃半透明 / 主题色)',
|
||||||
blackStyle.fill === 'rgb(0, 0, 0)' &&
|
blackStyle.fill === 'rgb(0, 0, 0)' &&
|
||||||
glassStyle.fill.startsWith('rgba(32, 32, 36') &&
|
glassStyle.fill.startsWith('rgba(32, 32, 36') &&
|
||||||
tintedStyle.fill === 'rgb(11, 11, 15)',
|
tintedStyle.fill === 'rgb(11, 11, 15)',
|
||||||
@@ -3301,9 +3302,9 @@ async function runIslandChecks(
|
|||||||
island.setAppearance({ ...appearanceBefore, accent: '#ff7043' });
|
island.setAppearance({ ...appearanceBefore, accent: '#ff7043' });
|
||||||
await sleep(200);
|
await sleep(200);
|
||||||
const accentVar = await islandWindow?.webContents.executeJavaScript(
|
const accentVar = await islandWindow?.webContents.executeJavaScript(
|
||||||
`getComputedStyle(document.documentElement).getPropertyValue('--island-accent').trim()`,
|
`getComputedStyle(document.documentElement).getPropertyValue('--ci-accent').trim()`,
|
||||||
);
|
);
|
||||||
record('个性设置:主题色生效(CSS 变量)', accentVar === '#ff7043', `CSS --island-accent=${accentVar}`);
|
record('个性设置:主题色生效(CSS 变量)', accentVar === '#ff7043', `CSS --ci-accent=${accentVar}`);
|
||||||
|
|
||||||
// 11.2b) 三种视觉风格的**底色**:黑 / 毛玻璃 / 主题色渐变都必须是深色卡片
|
// 11.2b) 三种视觉风格的**底色**:黑 / 毛玻璃 / 主题色渐变都必须是深色卡片
|
||||||
// 并且卡片**外面那一圈**必须完全透明(用户反馈:毛玻璃与主题色渐变会出现白底 ——
|
// 并且卡片**外面那一圈**必须完全透明(用户反馈:毛玻璃与主题色渐变会出现白底 ——
|
||||||
@@ -4476,46 +4477,6 @@ export async function runSmokeTest(win: BrowserWindow): Promise<void> {
|
|||||||
);
|
);
|
||||||
record('关于页渲染(应用信息/诊断信息/鸣谢)', Boolean(aboutPage?.ok), String(aboutPage?.detail ?? ''));
|
record('关于页渲染(应用信息/诊断信息/鸣谢)', Boolean(aboutPage?.ok), String(aboutPage?.detail ?? ''));
|
||||||
|
|
||||||
// 更新检查(新功能回归):主进程直连 GitHub 取最新 Release。
|
|
||||||
//
|
|
||||||
// **刻意不断言"一定有新版本"**:那会把冒烟绑死在外网可达上,而教室机器常常没有外网
|
|
||||||
// (`ok=false` 是设计内的降级结果,不是失败)。因此两种结果都算通过,验的是:
|
|
||||||
// 结构完整、失败时有可读原因、以及缓存真的生效。
|
|
||||||
const updateFirst = await checkForUpdates(true);
|
|
||||||
const isVersionLike = (value: unknown): boolean => typeof value === 'string' && /^\d/.test(value);
|
|
||||||
const updateShapeOk =
|
|
||||||
isVersionLike(updateFirst.currentVersion) &&
|
|
||||||
typeof updateFirst.ok === 'boolean' &&
|
|
||||||
typeof updateFirst.hasUpdate === 'boolean' &&
|
|
||||||
(updateFirst.ok
|
|
||||||
? isVersionLike(updateFirst.latestVersion) &&
|
|
||||||
Array.isArray(updateFirst.assets) &&
|
|
||||||
/^https:\/\//.test(updateFirst.releaseUrl) &&
|
|
||||||
updateFirst.error === null
|
|
||||||
: typeof updateFirst.error === 'string' && updateFirst.error.length > 0);
|
|
||||||
record(
|
|
||||||
'更新检查返回结构正确(无外网时降级为 ok=false 且带原因)',
|
|
||||||
updateShapeOk,
|
|
||||||
`ok=${updateFirst.ok} 本机=${updateFirst.currentVersion} 最新=${updateFirst.latestVersion ?? '-'} ` +
|
|
||||||
`有新版本=${updateFirst.hasUpdate} 附件=${updateFirst.assets.length}` +
|
|
||||||
`${updateFirst.error ? ` 原因=${updateFirst.error}` : ''}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 缓存:紧接着再查一次(不传 force)应命中缓存 —— checkedAt 不变即说明没有二次请求
|
|
||||||
const updateSecond = await checkForUpdates();
|
|
||||||
record(
|
|
||||||
'更新检查结果带缓存(不重复请求 GitHub)',
|
|
||||||
updateSecond.checkedAt === updateFirst.checkedAt,
|
|
||||||
`两次 checkedAt 相同=${updateSecond.checkedAt === updateFirst.checkedAt}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 启动自动检查在冒烟模式下必须被跳过,否则每次验证都会产生一次真实网络请求与提示条
|
|
||||||
record(
|
|
||||||
'冒烟模式下跳过启动自动检查(验证不依赖外网)',
|
|
||||||
wasStartupCheckSkipped(),
|
|
||||||
`skipped=${wasStartupCheckSkipped()}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 未读红点必须挂在"通知"图标右上方(用户反馈:原来挂在文字后面,位置不对)
|
// 未读红点必须挂在"通知"图标右上方(用户反馈:原来挂在文字后面,位置不对)
|
||||||
const readBadgeGeometry = async (): Promise<{
|
const readBadgeGeometry = async (): Promise<{
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
|
|||||||
@@ -1,216 +0,0 @@
|
|||||||
import { app, type BrowserWindow } from 'electron';
|
|
||||||
import {
|
|
||||||
GITHUB_RELEASES_LATEST_API,
|
|
||||||
GITHUB_RELEASES_PAGE,
|
|
||||||
UPDATE_CHECK_CACHE_TTL_MS,
|
|
||||||
UPDATE_CHECK_TIMEOUT_MS,
|
|
||||||
UPDATE_CHECK_USER_AGENT,
|
|
||||||
isNewerVersion,
|
|
||||||
normalizeVersion,
|
|
||||||
type UpdateAssetDto,
|
|
||||||
type UpdateInfo,
|
|
||||||
} from '@classhelper/shared';
|
|
||||||
import { UPDATE_AVAILABLE_CHANNEL } from './channels.js';
|
|
||||||
import { getConfig, saveConfig } from './config.js';
|
|
||||||
import { logger } from './logger.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新检查(桌面客户端)。
|
|
||||||
*
|
|
||||||
* **为什么在主进程做**:渲染进程通过 preload 能拿到 `getConfig()` 的明文 token(代表全班身份),
|
|
||||||
* 它的 CSP 与导航防线是整个安全模型里最要紧的一层;让它额外去连一个外部域名、
|
|
||||||
* 解析外部 JSON,等于把"外部数据"请进最有价值的那一侧。主进程本来就在做网络与文件,
|
|
||||||
* 放这里也顺带复用 Node 的 fetch(无需额外依赖)。
|
|
||||||
*
|
|
||||||
* 与 Web 管理端的差别:Web 端受服务端 CSP 的 `connect-src` 限制,只能走 `/api/update/check` 转发;
|
|
||||||
* 客户端没有这个限制,按用户选择**直连 GitHub**。两边归一化出的 `UpdateInfo` 结构一致。
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** 主进程 → 渲染进程:发现新版本(渲染进程据此弹一次性提示);定义在叶子模块 `channels.ts` */
|
|
||||||
export { UPDATE_AVAILABLE_CHANNEL };
|
|
||||||
|
|
||||||
/** 启动后多久自动查一次:等窗口与登录流程就绪,也不跟首屏请求抢带宽 */
|
|
||||||
const STARTUP_DELAY_MS = 5_000;
|
|
||||||
|
|
||||||
interface GithubReleasePayload {
|
|
||||||
tag_name?: unknown;
|
|
||||||
name?: unknown;
|
|
||||||
published_at?: unknown;
|
|
||||||
body?: unknown;
|
|
||||||
html_url?: unknown;
|
|
||||||
assets?: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
let cache: { at: number; info: UpdateInfo } | null = null;
|
|
||||||
let startupTimer: ReturnType<typeof setTimeout> | null = null;
|
|
||||||
/** 冒烟断言用:启动自动检查是否被跳过(冒烟模式下必须是 true) */
|
|
||||||
let startupCheckSkipped = false;
|
|
||||||
|
|
||||||
/** 失败的统一出口:结构完整,界面不必做 null 判断 */
|
|
||||||
function failure(error: string): UpdateInfo {
|
|
||||||
return {
|
|
||||||
ok: false,
|
|
||||||
error,
|
|
||||||
currentVersion: app.getVersion(),
|
|
||||||
latestVersion: null,
|
|
||||||
hasUpdate: false,
|
|
||||||
releaseUrl: GITHUB_RELEASES_PAGE,
|
|
||||||
releaseName: null,
|
|
||||||
publishedAt: null,
|
|
||||||
notes: null,
|
|
||||||
assets: [],
|
|
||||||
checkedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function toAssets(raw: unknown): UpdateAssetDto[] {
|
|
||||||
if (!Array.isArray(raw)) return [];
|
|
||||||
return raw
|
|
||||||
.map((item) => item as { name?: unknown; browser_download_url?: unknown; size?: unknown })
|
|
||||||
.filter(
|
|
||||||
(item): item is { name: string; browser_download_url: string; size?: unknown } =>
|
|
||||||
typeof item.name === 'string' && typeof item.browser_download_url === 'string',
|
|
||||||
)
|
|
||||||
.map((item) => ({
|
|
||||||
name: item.name,
|
|
||||||
downloadUrl: item.browser_download_url,
|
|
||||||
size: typeof item.size === 'number' && Number.isFinite(item.size) ? item.size : 0,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
function toInfo(payload: GithubReleasePayload, currentVersion: string): UpdateInfo {
|
|
||||||
const latestVersion = normalizeVersion(typeof payload.tag_name === 'string' ? payload.tag_name : '');
|
|
||||||
if (!latestVersion) {
|
|
||||||
logger.warn('更新检查:GitHub 返回的 Release 里没有可识别的 tag_name');
|
|
||||||
return failure('GitHub 返回的版本号无法识别');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
ok: true,
|
|
||||||
error: null,
|
|
||||||
currentVersion,
|
|
||||||
latestVersion,
|
|
||||||
hasUpdate: isNewerVersion(currentVersion, latestVersion),
|
|
||||||
releaseUrl:
|
|
||||||
typeof payload.html_url === 'string' && payload.html_url ? payload.html_url : GITHUB_RELEASES_PAGE,
|
|
||||||
releaseName: typeof payload.name === 'string' ? payload.name : null,
|
|
||||||
publishedAt: typeof payload.published_at === 'string' ? payload.published_at : null,
|
|
||||||
notes: typeof payload.body === 'string' ? payload.body : null,
|
|
||||||
assets: toAssets(payload.assets),
|
|
||||||
checkedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 把各种失败翻译成一句用户能看懂的话(教室里最常见的就是"这台机器没有外网") */
|
|
||||||
function describeFailure(error: unknown): string {
|
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
|
||||||
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
||||||
return `连接 GitHub 超时(${UPDATE_CHECK_TIMEOUT_MS / 1000} 秒),本机可能没有外网`;
|
|
||||||
}
|
|
||||||
if (/fetch failed|ENOTFOUND|ECONNREFUSED|EAI_AGAIN|ETIMEDOUT|certificate|net::/i.test(message)) {
|
|
||||||
return '无法连接 GitHub,本机可能没有外网';
|
|
||||||
}
|
|
||||||
return `检查更新失败:${message}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查 GitHub 上有没有比本机新的版本(结果带缓存)。
|
|
||||||
*
|
|
||||||
* 缓存的意义:匿名调用 GitHub API 的限流是 60 次/小时/IP,而「关于」页的按钮可以随便点。
|
|
||||||
* 失败结果同样进缓存 —— 否则离线时每点一次都要白等一个超时。
|
|
||||||
*/
|
|
||||||
export async function checkForUpdates(force = false): Promise<UpdateInfo> {
|
|
||||||
const currentVersion = app.getVersion();
|
|
||||||
const now = Date.now();
|
|
||||||
if (!force && cache && now - cache.at < UPDATE_CHECK_CACHE_TTL_MS) {
|
|
||||||
return cache.info;
|
|
||||||
}
|
|
||||||
|
|
||||||
let info: UpdateInfo;
|
|
||||||
try {
|
|
||||||
const response = await fetch(GITHUB_RELEASES_LATEST_API, {
|
|
||||||
headers: {
|
|
||||||
// GitHub API 强制要求 User-Agent,不带会直接 403
|
|
||||||
'User-Agent': UPDATE_CHECK_USER_AGENT,
|
|
||||||
Accept: 'application/vnd.github+json',
|
|
||||||
},
|
|
||||||
signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
info =
|
|
||||||
response.status === 403 || response.status === 429
|
|
||||||
? failure('GitHub 暂时拒绝了请求(匿名查询次数过多),请过一会儿再试')
|
|
||||||
: failure(`GitHub 返回 HTTP ${response.status}`);
|
|
||||||
logger.warn(`更新检查失败:HTTP ${response.status}(本机版本 ${currentVersion})`);
|
|
||||||
} else {
|
|
||||||
info = toInfo((await response.json()) as GithubReleasePayload, currentVersion);
|
|
||||||
logger.info(
|
|
||||||
`更新检查:本机 ${currentVersion} / 最新 ${info.latestVersion ?? '-'}` +
|
|
||||||
`${info.hasUpdate ? '(有新版本)' : '(已是最新)'}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
info = failure(describeFailure(error));
|
|
||||||
logger.warn(`更新检查失败:${info.error}(本机版本 ${currentVersion})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
cache = { at: now, info };
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 「知道了 / 忽略此版本」:记到配置里,同一个版本不再重复弹提示 */
|
|
||||||
export function ignoreUpdateVersion(version: string): void {
|
|
||||||
const normalized = normalizeVersion(version);
|
|
||||||
if (!normalized) return;
|
|
||||||
saveConfig({ ignoredUpdateVersion: normalized });
|
|
||||||
logger.info(`已忽略版本 ${normalized} 的更新提示`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 该版本是否已被用户忽略 */
|
|
||||||
export function isUpdateIgnored(version: string): boolean {
|
|
||||||
return normalizeVersion(getConfig().ignoredUpdateVersion) === normalizeVersion(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启动后的自动检查:延迟 `STARTUP_DELAY_MS` 查一次,有新版本(且没被忽略)就通知渲染进程弹提示。
|
|
||||||
*
|
|
||||||
* **冒烟模式直接跳过**:自动化验证不该每次都发真实网络请求(既抖动又依赖外网),
|
|
||||||
* 而且凭空多出来的提示条会撞坏既有 UI 断言。冒烟用例改为直接调 IPC 验证返回结构。
|
|
||||||
*/
|
|
||||||
export function scheduleStartupUpdateCheck(getWindow: () => BrowserWindow | null): void {
|
|
||||||
if (process.env.ELECTRON_SMOKE_TEST === '1') {
|
|
||||||
startupCheckSkipped = true;
|
|
||||||
logger.info('更新检查:冒烟模式下跳过启动自动检查');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (startupTimer) clearTimeout(startupTimer);
|
|
||||||
|
|
||||||
startupTimer = setTimeout(() => {
|
|
||||||
startupTimer = null;
|
|
||||||
void (async () => {
|
|
||||||
try {
|
|
||||||
const info = await checkForUpdates();
|
|
||||||
if (!info.ok || !info.hasUpdate || !info.latestVersion) return;
|
|
||||||
if (isUpdateIgnored(info.latestVersion)) {
|
|
||||||
logger.info(`更新检查:${info.latestVersion} 已被用户忽略,本次不提示`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const win = getWindow();
|
|
||||||
if (!win || win.isDestroyed()) return;
|
|
||||||
win.webContents.send(UPDATE_AVAILABLE_CHANNEL, info);
|
|
||||||
logger.info(`更新检查:已提示新版本 ${info.latestVersion}`);
|
|
||||||
} catch (error) {
|
|
||||||
// 自动检查失败不该打扰用户(手动检查才需要看到原因)
|
|
||||||
logger.warn(`启动自动检查更新失败:${error instanceof Error ? error.message : error}`);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}, STARTUP_DELAY_MS);
|
|
||||||
// 不阻止进程退出:这个定时器只是"顺便查一下"
|
|
||||||
startupTimer.unref?.();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 冒烟断言用:启动自动检查是否被跳过(冒烟模式下应为 true —— 否则每次验证都会发真实网络请求) */
|
|
||||||
export function wasStartupCheckSkipped(): boolean {
|
|
||||||
return startupCheckSkipped;
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ import type {
|
|||||||
CoursewareTransfer,
|
CoursewareTransfer,
|
||||||
} from '@classhelper/shared';
|
} from '@classhelper/shared';
|
||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
import { IPC_CHANNELS, UPDATE_AVAILABLE_CHANNEL } from '../main/channels.js';
|
import { IPC_CHANNELS } from '../main/channels.js';
|
||||||
import type { ClientAgentStatus } from '../main/client-agent.js';
|
import type { ClientAgentStatus } from '../main/client-agent.js';
|
||||||
import type {
|
import type {
|
||||||
DesktopAppInfo,
|
DesktopAppInfo,
|
||||||
@@ -12,7 +12,7 @@ import type {
|
|||||||
IslandClassStatePayload,
|
IslandClassStatePayload,
|
||||||
IslandPushContext,
|
IslandPushContext,
|
||||||
} from '../types/desktop.js';
|
} from '../types/desktop.js';
|
||||||
import type { IslandNotification, UpdateInfo } from '@classhelper/shared';
|
import type { IslandNotification } from '@classhelper/shared';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预加载脚本:在开启了 contextIsolation + sandbox 的前提下,
|
* 预加载脚本:在开启了 contextIsolation + sandbox 的前提下,
|
||||||
@@ -65,15 +65,6 @@ const bridge: DesktopBridge = {
|
|||||||
getAppInfo: (): Promise<DesktopAppInfo> => ipcRenderer.invoke(IPC_CHANNELS.appInfo),
|
getAppInfo: (): Promise<DesktopAppInfo> => ipcRenderer.invoke(IPC_CHANNELS.appInfo),
|
||||||
openExternal: (url: string): Promise<boolean> => ipcRenderer.invoke(IPC_CHANNELS.openExternal, url),
|
openExternal: (url: string): Promise<boolean> => ipcRenderer.invoke(IPC_CHANNELS.openExternal, url),
|
||||||
|
|
||||||
/* 更新检查(主进程直连 GitHub,见 main/update.ts) */
|
|
||||||
checkForUpdates: (force = false): Promise<UpdateInfo> =>
|
|
||||||
ipcRenderer.invoke(IPC_CHANNELS.updateCheck, force),
|
|
||||||
ignoreUpdateVersion: (version: string): Promise<void> =>
|
|
||||||
ipcRenderer.invoke(IPC_CHANNELS.updateIgnore, version),
|
|
||||||
onUpdateAvailable: (handler: (info: UpdateInfo) => void): void => {
|
|
||||||
ipcRenderer.on(UPDATE_AVAILABLE_CHANNEL, (_event, info: UpdateInfo) => handler(info));
|
|
||||||
},
|
|
||||||
|
|
||||||
islandPush: (payload: { notification: IslandNotification; context?: IslandPushContext }): void => {
|
islandPush: (payload: { notification: IslandNotification; context?: IslandPushContext }): void => {
|
||||||
ipcRenderer.send('island:push', payload);
|
ipcRenderer.send('island:push', payload);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import type { IslandAppearance, IslandState } from '@classhelper/shared';
|
|||||||
* 只暴露「订阅状态/外观」与「发送用户操作」两件事,渲染进程不接触任何 Node 能力。
|
* 只暴露「订阅状态/外观」与「发送用户操作」两件事,渲染进程不接触任何 Node 能力。
|
||||||
*/
|
*/
|
||||||
export interface IslandBridge {
|
export interface IslandBridge {
|
||||||
|
getTheme(): Promise<'light' | 'dark'>;
|
||||||
|
onTheme(handler: (theme: 'light' | 'dark') => void): void;
|
||||||
getIslandWeather(coordinates: { latitude: number; longitude: number }): Promise<IslandWeather>;
|
getIslandWeather(coordinates: { latitude: number; longitude: number }): Promise<IslandWeather>;
|
||||||
getLayout(): Promise<ContractIslandLayoutSettings>;
|
getLayout(): Promise<ContractIslandLayoutSettings>;
|
||||||
saveLayout(value: ContractIslandLayoutSettings): Promise<ContractIslandLayoutSettings>;
|
saveLayout(value: ContractIslandLayoutSettings): Promise<ContractIslandLayoutSettings>;
|
||||||
@@ -62,6 +64,10 @@ export interface IslandBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bridge: IslandBridge = {
|
const bridge: IslandBridge = {
|
||||||
|
getTheme: () => ipcRenderer.invoke('island:get-theme'),
|
||||||
|
onTheme: (handler) => {
|
||||||
|
ipcRenderer.on('island:theme', (_event, theme: 'light' | 'dark') => handler(theme));
|
||||||
|
},
|
||||||
getIslandWeather: (coordinates) => ipcRenderer.invoke('island:weather', coordinates),
|
getIslandWeather: (coordinates) => ipcRenderer.invoke('island:weather', coordinates),
|
||||||
getLayout: () => ipcRenderer.invoke('island:get-layout'),
|
getLayout: () => ipcRenderer.invoke('island:get-layout'),
|
||||||
saveLayout: (value) => ipcRenderer.invoke('island:save-layout', value),
|
saveLayout: (value) => ipcRenderer.invoke('island:save-layout', value),
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { h, onMounted, onUnmounted, ref } from 'vue';
|
import { onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { ElButton, ElNotification } from 'element-plus';
|
|
||||||
import type { UpdateInfo } from '@classhelper/shared';
|
|
||||||
import {
|
import {
|
||||||
replayMissedNotifications,
|
replayMissedNotifications,
|
||||||
startIslandBridge,
|
startIslandBridge,
|
||||||
@@ -13,6 +11,7 @@ import {
|
|||||||
import OnboardingWelcome from './components/OnboardingWelcome.vue';
|
import OnboardingWelcome from './components/OnboardingWelcome.vue';
|
||||||
import { useAppStore } from './stores/app.js';
|
import { useAppStore } from './stores/app.js';
|
||||||
import { useAuthStore } from './stores/auth.js';
|
import { useAuthStore } from './stores/auth.js';
|
||||||
|
import { ONBOARDING_VERSION } from '@classhelper/ui';
|
||||||
import { useOnboardingStore } from './stores/onboarding.js';
|
import { useOnboardingStore } from './stores/onboarding.js';
|
||||||
import { useRealtimeStore } from './stores/realtime.js';
|
import { useRealtimeStore } from './stores/realtime.js';
|
||||||
import { useUiStore } from './stores/ui.js';
|
import { useUiStore } from './stores/ui.js';
|
||||||
@@ -27,56 +26,10 @@ const realtime = useRealtimeStore();
|
|||||||
const booting = ref(true);
|
const booting = ref(true);
|
||||||
const bootText = ref('正在读取本地配置...');
|
const bootText = ref('正在读取本地配置...');
|
||||||
|
|
||||||
/**
|
|
||||||
* 启动自动检查发现新版本时的提示(主进程查出后推过来,见 main/update.ts)。
|
|
||||||
*
|
|
||||||
* **为什么订阅放在 App.vue**:`onUpdateAvailable` 底层是 `ipcRenderer.on`,
|
|
||||||
* 桥接层没有对应的 off —— 挂在会随"登出 → 登录"反复挂载的 ClientLayout 里,
|
|
||||||
* 处理器会越堆越多(与灵动岛订阅同一个坑)。App.vue 整个应用生命周期只挂载一次。
|
|
||||||
*
|
|
||||||
* 提示是**一次性**且可永久消音:点「忽略此版本」写进 config.json,同一版本不再提示;
|
|
||||||
* 「关于」页里仍可随时手动检查。
|
|
||||||
*/
|
|
||||||
function showUpdateAvailable(info: UpdateInfo): void {
|
|
||||||
if (!info.latestVersion) return;
|
|
||||||
ElNotification({
|
|
||||||
title: `发现新版本 v${info.latestVersion}`,
|
|
||||||
type: 'info',
|
|
||||||
// 不自动消失:这是需要用户决定的事(去下载 / 忽略),滑过去就只能靠「关于」页再想起来
|
|
||||||
duration: 0,
|
|
||||||
message: h('div', { style: 'line-height: 1.7' }, [
|
|
||||||
h('p', { style: 'margin: 0 0 10px' }, `当前版本 ${info.currentVersion},可前往下载更新。`),
|
|
||||||
h('div', { style: 'display: flex; gap: 8px' }, [
|
|
||||||
h(
|
|
||||||
ElButton,
|
|
||||||
{
|
|
||||||
size: 'small',
|
|
||||||
type: 'primary',
|
|
||||||
onClick: () => {
|
|
||||||
void window.desktop?.openExternal(info.releaseUrl);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
() => '前往下载',
|
|
||||||
),
|
|
||||||
h(
|
|
||||||
ElButton,
|
|
||||||
{
|
|
||||||
size: 'small',
|
|
||||||
onClick: () => {
|
|
||||||
void window.desktop?.ignoreUpdateVersion(info.latestVersion ?? '');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
() => '忽略此版本',
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上线补弹「离线期间收到的消息」(需求 11)。
|
* 上线补弹「离线期间收到的消息」(需求 11)。
|
||||||
*
|
*
|
||||||
* **为什么订阅放在 App.vue**:与 `onUpdateAvailable` 同一条理由 —— App.vue 整个应用生命周期
|
* **为什么订阅放在 App.vue**:App.vue 整个应用生命周期
|
||||||
* 只挂载一次,而 `ClientLayout` 会随"登出 → 登录"反复挂载。而且恢复事件本身是"可达性由不可达
|
* 只挂载一次,而 `ClientLayout` 会随"登出 → 登录"反复挂载。而且恢复事件本身是"可达性由不可达
|
||||||
* 变为可达"的那一刻,一次会话里可能发生多次,处理器必须是**幂等**的(`replayMissedNotifications`
|
* 变为可达"的那一刻,一次会话里可能发生多次,处理器必须是**幂等**的(`replayMissedNotifications`
|
||||||
* 推完就清掉离线起点,重复触发时第二次读到空值、直接返回 0)。
|
* 推完就清掉离线起点,重复触发时第二次读到空值、直接返回 0)。
|
||||||
@@ -117,19 +70,16 @@ onMounted(async () => {
|
|||||||
// 离线期间收到的消息:可达性恢复的那一刻补弹到灵动岛(App.vue 常驻,所以每次恢复只跑一次)
|
// 离线期间收到的消息:可达性恢复的那一刻补弹到灵动岛(App.vue 常驻,所以每次恢复只跑一次)
|
||||||
appStore.onServerRecovered(handleServerRecovered);
|
appStore.onServerRecovered(handleServerRecovered);
|
||||||
|
|
||||||
// 启动自动检查发现新版本时由主进程推过来(订阅只挂一次,理由见 showUpdateAvailable)
|
|
||||||
window.desktop?.onUpdateAvailable?.(showUpdateAvailable);
|
|
||||||
|
|
||||||
if (auth.isAuthenticated) await router.replace('/schedule');
|
if (auth.isAuthenticated) await router.replace('/schedule');
|
||||||
else await router.replace('/login');
|
else await router.replace('/login');
|
||||||
|
|
||||||
// 初次启动引导:配置里没记「已看过」就自动弹一次(完成/跳过后由引导组件写入配置)。
|
// 引导按版本展示,完成或跳过后记住当前版本。
|
||||||
// 稍等一拍再弹:让登录页/主界面先渲染完,避免和启动过渡的收尾抢帧。
|
// 稍等一拍再弹:让登录页/主界面先渲染完,避免和启动过渡的收尾抢帧。
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
void window.desktop
|
void window.desktop
|
||||||
?.getConfig()
|
?.getConfig()
|
||||||
.then((config) => {
|
.then((config) => {
|
||||||
if (config.onboardingDone !== true) onboarding.open();
|
if ((config.onboardingVersion ?? 0) < ONBOARDING_VERSION) onboarding.open();
|
||||||
})
|
})
|
||||||
.catch(() => undefined);
|
.catch(() => undefined);
|
||||||
}, 400);
|
}, 400);
|
||||||
|
|||||||
@@ -61,7 +61,10 @@ http.interceptors.response.use(
|
|||||||
const status = error.response.status;
|
const status = error.response.status;
|
||||||
const message = error.response.data?.message ?? `请求失败(${status})`;
|
const message = error.response.data?.message ?? `请求失败(${status})`;
|
||||||
|
|
||||||
if (status === 401) {
|
const loginAttempt =
|
||||||
|
error.config?.method?.toLowerCase() === 'post' &&
|
||||||
|
/\/auth\/(?:class-)?login\/?(?:\?|$)/.test(error.config?.url ?? '');
|
||||||
|
if (status === 401 && !loginAttempt) {
|
||||||
ElMessage.warning('登录状态已失效,请重新登录');
|
ElMessage.warning('登录状态已失效,请重新登录');
|
||||||
unauthorizedHandler();
|
unauthorizedHandler();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -67,8 +67,15 @@ export const homeworkApi = {
|
|||||||
date?: string;
|
date?: string;
|
||||||
}): Promise<HomeworkDto[]> => api.get(API_PATHS.homeworks, params),
|
}): Promise<HomeworkDto[]> => api.get(API_PATHS.homeworks, params),
|
||||||
/** 哪些天有作业(日期选择器高亮) */
|
/** 哪些天有作业(日期选择器高亮) */
|
||||||
days: (params: { classId?: string; from?: string; to?: string; days?: number }): Promise<HomeworkDaysDto> =>
|
days: (params: {
|
||||||
api.get(`${API_PATHS.homeworks}/days`, params),
|
classId?: string;
|
||||||
|
courseId?: string;
|
||||||
|
keyword?: string;
|
||||||
|
pendingOnly?: boolean;
|
||||||
|
from?: string;
|
||||||
|
to?: string;
|
||||||
|
days?: number;
|
||||||
|
}): Promise<HomeworkDaysDto> => api.get(`${API_PATHS.homeworks}/days`, params),
|
||||||
/** 在教室机器上直接录入作业(班级账号可调用;也可选所属日期) */
|
/** 在教室机器上直接录入作业(班级账号可调用;也可选所属日期) */
|
||||||
create: (payload: {
|
create: (payload: {
|
||||||
classId: string;
|
classId: string;
|
||||||
@@ -88,8 +95,21 @@ export const homeworkApi = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const notificationApi = {
|
export const notificationApi = {
|
||||||
list: (params?: { classId?: string; unreadOnly?: boolean }): Promise<NotificationDto[]> =>
|
days: (params: {
|
||||||
api.get(API_PATHS.notifications, params),
|
classId?: string;
|
||||||
|
from?: string;
|
||||||
|
to?: string;
|
||||||
|
createdBy?: string;
|
||||||
|
priority?: string;
|
||||||
|
unreadOnly?: boolean;
|
||||||
|
}): Promise<{ days: { date: string; count: number }[] }> => api.get('/notifications/days', params),
|
||||||
|
list: (params?: {
|
||||||
|
classId?: string;
|
||||||
|
unreadOnly?: boolean;
|
||||||
|
date?: string;
|
||||||
|
createdBy?: string;
|
||||||
|
priority?: string;
|
||||||
|
}): Promise<NotificationDto[]> => api.get(API_PATHS.notifications, params),
|
||||||
unreadCount: (): Promise<{ count: number }> => api.get(`${API_PATHS.notifications}/unread-count`),
|
unreadCount: (): Promise<{ count: number }> => api.get(`${API_PATHS.notifications}/unread-count`),
|
||||||
// id 来自服务端或灵动岛(作业卡是本地合成的 `homework-…`),一律 encodeURIComponent:
|
// id 来自服务端或灵动岛(作业卡是本地合成的 `homework-…`),一律 encodeURIComponent:
|
||||||
// 否则含 `/` 或 `..` 的 id 会改变实际请求的路径
|
// 否则含 `/` 或 `..` 的 id 会改变实际请求的路径
|
||||||
|
|||||||
@@ -885,14 +885,7 @@ export async function islandHomeworkSuppressionCheck(): Promise<SmokeCheckResult
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 全新配置首次展示全屏引导,完成后保存版本标记。 */
|
||||||
* 冒烟自检(不需要后端):**初次启动引导**。
|
|
||||||
*
|
|
||||||
* 冒烟每次都用全新配置目录(等于"首次启动"),因此引导必须自动弹出;
|
|
||||||
* 这里真实点击把它一步步走完,断言:遮罩关闭 + `onboardingDone` 已写入配置。
|
|
||||||
* 关闭判据用「元素从 DOM 消失」——引导是 v-if 自绘遮罩(特意不用 el-dialog,
|
|
||||||
* 避免"关闭后 DOM 残留在文档里"的误报,见 AGENTS §7 第 22 条)。
|
|
||||||
*/
|
|
||||||
export async function onboardingSelfTest(): Promise<SmokeCheckResult> {
|
export async function onboardingSelfTest(): Promise<SmokeCheckResult> {
|
||||||
try {
|
try {
|
||||||
// 引导在启动后延迟 ~400ms 弹出,这里轮询等它出现
|
// 引导在启动后延迟 ~400ms 弹出,这里轮询等它出现
|
||||||
@@ -908,7 +901,10 @@ export async function onboardingSelfTest(): Promise<SmokeCheckResult> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 逐页「下一步」到最后一页再点「开始使用」(按钮由 data-action 标识,不依赖文案)
|
const guide = document.querySelector<HTMLElement>('.ch-guide')!;
|
||||||
|
const bounds = guide.getBoundingClientRect();
|
||||||
|
const fullscreen = Math.abs(bounds.width - innerWidth) < 2 && Math.abs(bounds.height - innerHeight) < 2;
|
||||||
|
const focused = guide.contains(document.activeElement);
|
||||||
const clicks: string[] = [];
|
const clicks: string[] = [];
|
||||||
for (let attempt = 0; attempt < 12; attempt += 1) {
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
||||||
const action = document.querySelector('.onboarding-welcome [data-action="finish"]') ? 'finish' : 'next';
|
const action = document.querySelector('.onboarding-welcome [data-action="finish"]') ? 'finish' : 'next';
|
||||||
@@ -928,10 +924,11 @@ export async function onboardingSelfTest(): Promise<SmokeCheckResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = await window.desktop?.getConfig?.();
|
const config = await window.desktop?.getConfig?.();
|
||||||
const done = config?.onboardingDone === true;
|
const { ONBOARDING_VERSION } = await import('@classhelper/ui');
|
||||||
|
const done = config?.onboardingDone === true && config.onboardingVersion === ONBOARDING_VERSION;
|
||||||
return {
|
return {
|
||||||
ok: closed && done,
|
ok: closed && done && fullscreen && focused,
|
||||||
detail: `步骤点击=[${clicks.join(',')}] 已关闭=${closed} onboardingDone=${config?.onboardingDone ?? '-'}`,
|
detail: `步骤点击=[${clicks.join(',')}] 全屏=${fullscreen} 焦点=${focused} 已关闭=${closed} 引导版本=${config?.onboardingVersion ?? '-'}`,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
@@ -1171,18 +1168,12 @@ export async function aboutPageSelfTest(): Promise<SmokeCheckResult> {
|
|||||||
const hasDiagnostics = text.includes('诊断信息');
|
const hasDiagnostics = text.includes('诊断信息');
|
||||||
const info = await window.desktop?.getAppInfo?.();
|
const info = await window.desktop?.getAppInfo?.();
|
||||||
const hasConfigPath = Boolean(info?.configPath);
|
const hasConfigPath = Boolean(info?.configPath);
|
||||||
|
const hasUpdateCheck = Boolean(document.querySelector('[data-test="update-check"]'));
|
||||||
// 检查更新入口(新功能回归):关于页要有这一块,且按钮可点。
|
|
||||||
// 这里只断言"入口存在"——是否真有新版本取决于 GitHub,不该绑进冒烟(见 main/update.ts)
|
|
||||||
const updateBlock = document.querySelector('[data-test="update-check"]');
|
|
||||||
const updateButton = document.querySelector('[data-test="update-check-button"]');
|
|
||||||
|
|
||||||
await router.push('/schedule');
|
await router.push('/schedule');
|
||||||
return {
|
return {
|
||||||
ok: hasThanks && hasDiagnostics && hasConfigPath && Boolean(updateBlock) && Boolean(updateButton),
|
ok: hasThanks && hasDiagnostics && hasConfigPath && !hasUpdateCheck,
|
||||||
detail:
|
detail: `鸣谢=${hasThanks} 诊断=${hasDiagnostics} configPath=${hasConfigPath ? '有' : '无'}`,
|
||||||
`鸣谢=${hasThanks} 诊断=${hasDiagnostics} configPath=${hasConfigPath ? '有' : '无'} ` +
|
|
||||||
`检查更新块=${updateBlock ? '有' : '无'} 按钮=${updateButton ? '有' : '无'}`,
|
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import {
|
import {
|
||||||
|
CLASSISLAND_TOKENS,
|
||||||
ISLAND_COMPONENT_LABELS,
|
ISLAND_COMPONENT_LABELS,
|
||||||
type IslandComponentNode,
|
type IslandComponentNode,
|
||||||
type IslandComponentKind,
|
type IslandComponentKind,
|
||||||
@@ -52,7 +53,7 @@ const containers = ['group', 'stack', 'slide', 'rolling'] as const;
|
|||||||
<el-input v-model="node.settings.countdownTitle" :maxlength="64" @change="emit('change')" />
|
<el-input v-model="node.settings.countdownTitle" :maxlength="64" @change="emit('change')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="目标日期">
|
<el-form-item label="目标日期">
|
||||||
<el-date-picker
|
<ch-date-picker
|
||||||
v-model="node.settings.targetDate"
|
v-model="node.settings.targetDate"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
@@ -180,8 +181,9 @@ const containers = ['group', 'stack', 'slide', 'rolling'] as const;
|
|||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="node.appearance[key]"
|
v-model="node.appearance[key]"
|
||||||
:disabled="!node.appearance.resourceOverridingEnabled"
|
:disabled="!node.appearance.resourceOverridingEnabled"
|
||||||
:min="8"
|
:min="CLASSISLAND_TOKENS.fontSizes.inputMin"
|
||||||
:max="96"
|
:max="CLASSISLAND_TOKENS.fontSizes.inputMax"
|
||||||
|
:step="CLASSISLAND_TOKENS.fontSizes.inputStep"
|
||||||
@change="emit('change')"
|
@change="emit('change')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -234,7 +236,8 @@ const containers = ['group', 'stack', 'slide', 'rolling'] as const;
|
|||||||
v-if="node.appearance.customCornerRadiusEnabled"
|
v-if="node.appearance.customCornerRadiusEnabled"
|
||||||
v-model="node.appearance.cornerRadius"
|
v-model="node.appearance.cornerRadius"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="CLASSISLAND_TOKENS.radii.islandMax"
|
||||||
|
:step="CLASSISLAND_TOKENS.radii.islandStep"
|
||||||
@change="emit('change')"
|
@change="emit('change')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const container = computed(() => ['group', 'stack', 'slide', 'rolling'].includes
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
border-radius: 5px;
|
border-radius: var(--ch-radius-control);
|
||||||
}
|
}
|
||||||
.component-chip {
|
.component-chip {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -62,9 +62,9 @@ const container = computed(() => ['group', 'stack', 'slide', 'rolling'].includes
|
|||||||
gap: 5px;
|
gap: 5px;
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
padding: 5px 9px;
|
padding: 5px 9px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid var(--ch-border);
|
||||||
border-radius: 5px;
|
border-radius: var(--ch-radius-control);
|
||||||
background: transparent;
|
background: var(--ch-surface);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
@@ -1,309 +1,59 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onUnmounted, ref, watch } from 'vue';
|
import { FullScreenGuide, ONBOARDING_VERSION } from '@classhelper/ui';
|
||||||
import { useOnboardingStore } from '../stores/onboarding.js';
|
import { useOnboardingStore } from '../stores/onboarding.js';
|
||||||
|
import { BRAND_LOGO_URL } from '../config.js';
|
||||||
/**
|
|
||||||
* 初次启动引导(六步向导)。
|
|
||||||
*
|
|
||||||
* - 首次启动自动弹出(App.vue 按 `onboardingDone` 判定);完成 / 跳过(右上角按钮 / Esc)
|
|
||||||
* 都算看过,由这里写入主进程配置,之后不再自动弹出。
|
|
||||||
* - 登录页与设置页的「使用引导」入口可随时重看(重看关闭时再写一次也无副作用)。
|
|
||||||
* - **用 v-if 自绘遮罩而不是 el-dialog**:关闭即从 DOM 卸载。冒烟断言"引导已关闭"时
|
|
||||||
* 不会踩 el-dialog「DOM 残留在文档里」的坑(AGENTS §7 第 22 条)。
|
|
||||||
* - 操作按钮用 `data-action` 标识(prev/next/finish/skip),冒烟点击不依赖按钮文案。
|
|
||||||
*/
|
|
||||||
const onboarding = useOnboardingStore();
|
const onboarding = useOnboardingStore();
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
{
|
{
|
||||||
icon: 'School',
|
id: 'server',
|
||||||
title: '欢迎使用 ClassHelper',
|
title: '连接学校服务器',
|
||||||
lines: [
|
text: '填写管理员提供的服务器地址,测试连接后继续。',
|
||||||
'这台电脑将以「班级」的身份使用 ClassHelper:实时接收课表、作业、通知与成绩。',
|
example: ['服务器地址', '测试连接', '连接成功'],
|
||||||
'第一次使用,先花半分钟看看怎么开始。',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'Link',
|
id: 'login',
|
||||||
title: '第一步 · 连接服务器',
|
title: '登录班级',
|
||||||
lines: [
|
text: '使用班级码和班级密码登录,这台设备将代表本班。',
|
||||||
'在登录页填写老师或管理员提供的服务器地址(通常形如 http://192.168.x.x:4000)。',
|
example: ['班级码', '班级密码', '登录'],
|
||||||
'点「测试连接」确认可达;以后也能在「设置」里随时修改。',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'Key',
|
id: 'teaching',
|
||||||
title: '第二步 · 登录班级',
|
title: '查看课表与作业',
|
||||||
lines: [
|
text: '从菜单切换页面,用日历查找记录;断网时可查看已缓存的内容。',
|
||||||
'使用班级码 + 班级密码登录(向老师或管理员索取)。',
|
example: ['今日课表', '作业看板', '日期下方的圆点 ·'],
|
||||||
'登录后这台设备就代表全班:作业完成、通知已读都会按全班记录,不需要每个学生单独登录。',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'Calendar',
|
id: 'files',
|
||||||
title: '登录之后',
|
title: '接收通知与课件',
|
||||||
lines: [
|
text: '新内容自动同步,课件下载后由你选择如何打开。',
|
||||||
'左侧菜单切换「课表 / 作业 / 通知 / 成绩」四个页面,作业支持看板全屏展示。',
|
example: ['班级通知', '课件传输进度', '打开所在文件夹'],
|
||||||
'断网时自动显示最近同步的缓存数据,联网后自动更新。',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'Bell',
|
id: 'island',
|
||||||
title: '灵动岛提醒',
|
title: '选择灵动岛模式',
|
||||||
lines: [
|
text: '经典模式自动呈现提醒;常驻模式先显示消息数量,由你展开查看。',
|
||||||
'屏幕上方会有一条「灵动岛」浮窗:新通知、叫人、作业都会在那里弹出。',
|
example: ['经典模式', '自定义常驻模式', '设置 → 灵动岛'],
|
||||||
'上课时段自动隐藏、下课自动弹出;外观与位置可在「设置 → 灵动岛」调整。',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'CircleCheckFilled',
|
id: 'settings',
|
||||||
title: '准备好了',
|
title: '准备好了',
|
||||||
lines: [
|
text: '在设置中调整外观和关怀模式,也可以随时重看引导。',
|
||||||
'按上面的步骤登录就可以开始使用了。',
|
example: ['通用设置', '外观', '使用引导'],
|
||||||
'侧边栏「设置」分组里有通用、外观(深色模式)、灵动岛等页面;这份引导可以在登录页或「设置 → 通用 → 使用引导」随时重看。',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async function finish(): Promise<void> {
|
||||||
const index = ref(0);
|
try {
|
||||||
const current = computed(() => steps[index.value] ?? steps[0]);
|
await window.desktop?.saveConfig({ onboardingDone: true, onboardingVersion: ONBOARDING_VERSION });
|
||||||
const isFirst = computed(() => index.value === 0);
|
} finally {
|
||||||
const isLast = computed(() => index.value === steps.length - 1);
|
|
||||||
|
|
||||||
/** 每次打开都从第一步开始(重看入口也走完整流程) */
|
|
||||||
watch(
|
|
||||||
() => onboarding.visible,
|
|
||||||
(visible) => {
|
|
||||||
if (visible) index.value = 0;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
function goNext(): void {
|
|
||||||
if (isLast.value) finish();
|
|
||||||
else index.value += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function goPrev(): void {
|
|
||||||
if (!isFirst.value) index.value -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 完成 / 跳过统一走这里:记「已看过」并关闭(重看时重复写一次无副作用) */
|
|
||||||
function finish(): void {
|
|
||||||
const bridge = window.desktop;
|
|
||||||
// 桥接不可用(浏览器调试)也要能正常关掉引导
|
|
||||||
if (!bridge) {
|
|
||||||
onboarding.close();
|
onboarding.close();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
void bridge
|
|
||||||
.saveConfig({ onboardingDone: true })
|
|
||||||
.then(() => onboarding.close())
|
|
||||||
.catch(() => onboarding.close());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeydown(event: KeyboardEvent): void {
|
|
||||||
if (onboarding.visible && event.key === 'Escape') finish();
|
|
||||||
}
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
window.addEventListener('keydown', onKeydown);
|
|
||||||
}
|
|
||||||
onUnmounted(() => {
|
|
||||||
window.removeEventListener('keydown', onKeydown);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Transition name="onboarding-fade">
|
<FullScreenGuide
|
||||||
<div
|
:model-value="onboarding.visible"
|
||||||
v-if="onboarding.visible"
|
:steps="steps"
|
||||||
class="onboarding-mask"
|
:brand-logo="BRAND_LOGO_URL"
|
||||||
role="dialog"
|
@finish="finish"
|
||||||
aria-modal="true"
|
|
||||||
aria-label="初次启动引导"
|
|
||||||
>
|
|
||||||
<div class="onboarding-card onboarding-welcome">
|
|
||||||
<div class="onboarding-head">
|
|
||||||
<span class="onboarding-logo">
|
|
||||||
<el-icon :size="18"><School /></el-icon>
|
|
||||||
</span>
|
|
||||||
<div class="onboarding-heading">
|
|
||||||
<h2 class="onboarding-title">ClassHelper</h2>
|
|
||||||
<p class="onboarding-sub">初次启动引导 · 第 {{ index + 1 }} / {{ steps.length }} 步</p>
|
|
||||||
</div>
|
|
||||||
<el-button link class="onboarding-skip" data-action="skip" @click="finish">跳过引导</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="onboarding-body">
|
|
||||||
<span class="onboarding-icon">
|
|
||||||
<el-icon :size="30"><component :is="current.icon" /></el-icon>
|
|
||||||
</span>
|
|
||||||
<h3 class="onboarding-step-title">{{ current.title }}</h3>
|
|
||||||
<p v-for="(line, lineIndex) in current.lines" :key="lineIndex" class="onboarding-line">
|
|
||||||
{{ line }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="onboarding-foot">
|
|
||||||
<div class="onboarding-dots">
|
|
||||||
<span
|
|
||||||
v-for="(step, dotIndex) in steps"
|
|
||||||
:key="dotIndex"
|
|
||||||
class="dot"
|
|
||||||
:class="{ active: dotIndex === index }"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<div class="onboarding-actions">
|
|
||||||
<el-button v-if="!isFirst" data-action="prev" @click="goPrev">上一步</el-button>
|
|
||||||
<el-button v-if="!isLast" type="primary" data-action="next" @click="goNext">下一步</el-button>
|
|
||||||
<el-button v-else type="primary" data-action="finish" @click="finish">开始使用</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Transition>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.onboarding-mask {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 3000;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 24px;
|
|
||||||
background: rgba(15, 30, 50, 0.55);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-card {
|
|
||||||
width: 520px;
|
|
||||||
max-width: 92vw;
|
|
||||||
max-height: 86vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
background: var(--ch-layer-solid);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 22px 24px 18px;
|
|
||||||
box-shadow: 0 24px 64px rgba(15, 30, 50, 0.35);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-logo {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 34px;
|
|
||||||
height: 34px;
|
|
||||||
border-radius: 9px;
|
|
||||||
color: #fff;
|
|
||||||
background: linear-gradient(135deg, var(--ch-accent) 0%, #4d94d1 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-heading {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-title {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 1.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-sub {
|
|
||||||
margin: 2px 0 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ch-text-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-body {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
padding: 18px 4px 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-icon {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 58px;
|
|
||||||
height: 58px;
|
|
||||||
border-radius: 16px;
|
|
||||||
margin-bottom: 14px;
|
|
||||||
color: var(--ch-accent);
|
|
||||||
background: var(--ch-accent-soft);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-step-title {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-line {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.8;
|
|
||||||
color: var(--ch-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-foot {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: 14px;
|
|
||||||
padding-top: 14px;
|
|
||||||
border-top: 1px solid var(--ch-divider);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-dots {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dot {
|
|
||||||
width: 7px;
|
|
||||||
height: 7px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: var(--ch-border-strong);
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dot.active {
|
|
||||||
width: 20px;
|
|
||||||
background: var(--ch-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-actions {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 进出场:淡入 + 轻微上浮,跟随系统"动画"开关无强依赖 */
|
|
||||||
.onboarding-fade-enter-active,
|
|
||||||
.onboarding-fade-leave-active {
|
|
||||||
transition: opacity 0.22s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-fade-enter-active .onboarding-card,
|
|
||||||
.onboarding-fade-leave-active .onboarding-card {
|
|
||||||
transition: transform 0.22s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-fade-enter-from,
|
|
||||||
.onboarding-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.onboarding-fade-enter-from .onboarding-card,
|
|
||||||
.onboarding-fade-leave-to .onboarding-card {
|
|
||||||
transform: translateY(10px) scale(0.98);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -11,6 +11,8 @@ import router from './router/index.js';
|
|||||||
import { registerAppIcons } from './icons.js';
|
import { registerAppIcons } from './icons.js';
|
||||||
import { applyMotionTokens } from './composables/motion.js';
|
import { applyMotionTokens } from './composables/motion.js';
|
||||||
import './styles/index.css';
|
import './styles/index.css';
|
||||||
|
import { registerSharedUi } from '@classhelper/ui';
|
||||||
|
import '@classhelper/ui/theme.css';
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ registerAppIcons(app);
|
|||||||
app.use(createPinia());
|
app.use(createPinia());
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(ElementPlus, { locale: zhCn });
|
app.use(ElementPlus, { locale: zhCn });
|
||||||
|
registerSharedUi(app);
|
||||||
|
|
||||||
// 冒烟验证模式:把缓存自检钩子暴露给主进程调用(正常运行时不存在)。
|
// 冒烟验证模式:把缓存自检钩子暴露给主进程调用(正常运行时不存在)。
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
|
|
||||||
/**
|
/** App.vue 按引导版本自动展示;登录页和设置页可随时重看。 */
|
||||||
* 初次启动引导的显示状态。
|
|
||||||
*
|
|
||||||
* 首次启动由 App.vue 按「配置里是否记过 onboardingDone」自动弹出;
|
|
||||||
* 登录页与设置页的「使用引导」入口调用 open() 随时重看。
|
|
||||||
* 单独一个 store 而不是组件内部 ref:触发入口(登录页 / 设置页)与
|
|
||||||
* 渲染点(App.vue 顶层)分处两棵互不相干的子树。
|
|
||||||
*/
|
|
||||||
export const useOnboardingStore = defineStore('onboarding', () => {
|
export const useOnboardingStore = defineStore('onboarding', () => {
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
color: var(--ch-text);
|
color: var(--ch-text);
|
||||||
padding: 12px 24px 16px;
|
padding: 12px 24px 16px;
|
||||||
background: var(--editor-background, var(--ch-bg));
|
background: var(--ch-bg);
|
||||||
}
|
}
|
||||||
:global(.main:has(> .island-editor-page)) {
|
:global(.main:has(> .island-editor-page)) {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -16,11 +16,6 @@
|
|||||||
.island-editor-page > * {
|
.island-editor-page > * {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
:global(html.dark) .island-editor-page {
|
|
||||||
--editor-background: #262626;
|
|
||||||
--editor-divider: #3a3a3a;
|
|
||||||
--editor-card: #2c2c2c;
|
|
||||||
}
|
|
||||||
.editor-actions {
|
.editor-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -77,7 +72,8 @@
|
|||||||
}
|
}
|
||||||
.scheme-controls :deep(.el-select__wrapper) {
|
.scheme-controls :deep(.el-select__wrapper) {
|
||||||
min-height: 38px;
|
min-height: 38px;
|
||||||
background: var(--ch-card-subtle);
|
background: var(--ch-surface);
|
||||||
|
border-radius: var(--ch-radius-control);
|
||||||
}
|
}
|
||||||
.icon-button {
|
.icon-button {
|
||||||
width: 34px;
|
width: 34px;
|
||||||
@@ -139,7 +135,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 54px;
|
min-height: 54px;
|
||||||
border-radius: 6px;
|
border-radius: var(--ch-radius-control);
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
@@ -180,7 +176,7 @@
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--ch-text-tertiary);
|
color: var(--ch-text-tertiary);
|
||||||
padding: 10px 24px;
|
padding: 10px 24px;
|
||||||
border-radius: 5px;
|
border-radius: var(--ch-radius-control);
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -199,10 +195,12 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--preview-gap);
|
gap: var(--preview-gap);
|
||||||
width: max-content;
|
width: max-content;
|
||||||
color: #ffffffeb;
|
color: var(--ci-text-1);
|
||||||
padding: 12px;
|
padding: var(--ci-island-pad-x);
|
||||||
border-radius: var(--preview-radius);
|
border-radius: var(--preview-radius);
|
||||||
background: #202024;
|
background: var(--preview-background);
|
||||||
|
font-family: var(--ci-font-island);
|
||||||
|
font-weight: var(--ci-font-weight);
|
||||||
}
|
}
|
||||||
.preview-row {
|
.preview-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -216,14 +214,14 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
.separated .preview-row {
|
.separated .preview-row {
|
||||||
padding: 12px;
|
padding: var(--ci-island-pad-x);
|
||||||
background: #202024;
|
background: var(--preview-background);
|
||||||
}
|
}
|
||||||
.empty-preview {
|
.empty-preview {
|
||||||
color: #ffffffb8;
|
color: var(--ci-text-2);
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px dashed #ffffff60;
|
border: var(--ci-stroke-island-w) dashed var(--ci-stroke-control);
|
||||||
border-radius: 5px;
|
border-radius: var(--ci-radius-control);
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
@@ -250,8 +248,21 @@
|
|||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
.font-preview {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: calc(var(--ci-line-gap) * 2);
|
||||||
|
margin: 0 0 18px;
|
||||||
|
padding: var(--ci-popup-pad);
|
||||||
|
border: var(--ci-stroke-island-w) solid var(--ci-stroke-island);
|
||||||
|
border-radius: var(--ci-radius-card);
|
||||||
|
background: var(--ci-island-bg-custom);
|
||||||
|
line-height: var(--ci-line-height-body);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
.component-library {
|
.component-library {
|
||||||
border-top: 6px solid var(--editor-divider, var(--ch-divider));
|
border-top: 1px solid var(--ch-border);
|
||||||
margin: 0 -24px;
|
margin: 0 -24px;
|
||||||
padding: 14px 24px 24px;
|
padding: 14px 24px 24px;
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
@@ -288,9 +299,9 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
min-height: 76px;
|
min-height: 76px;
|
||||||
padding: 10px 8px;
|
padding: 10px 8px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid var(--ch-border);
|
||||||
border-radius: 6px;
|
border-radius: var(--ch-radius-control);
|
||||||
background: transparent;
|
background: var(--ch-surface);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
@@ -332,51 +343,6 @@
|
|||||||
font-size: calc(14px * var(--ch-font-scale));
|
font-size: calc(14px * var(--ch-font-scale));
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
.message-library-title {
|
|
||||||
color: var(--ch-text-tertiary);
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 400;
|
|
||||||
margin: 20px 8px 4px;
|
|
||||||
}
|
|
||||||
.message-options .library-item {
|
|
||||||
min-height: 64px;
|
|
||||||
}
|
|
||||||
.message-options .library-item strong {
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
.message-options .library-item > svg {
|
|
||||||
width: 26px;
|
|
||||||
height: 26px;
|
|
||||||
flex-basis: 26px;
|
|
||||||
}
|
|
||||||
.editor-tip {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 14px;
|
|
||||||
padding: 12px 16px;
|
|
||||||
min-height: 60px;
|
|
||||||
border: 1px solid var(--ch-border-strong);
|
|
||||||
border-radius: 5px;
|
|
||||||
background: var(--editor-card, var(--ch-card-subtle));
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.editor-tip > span {
|
|
||||||
flex: 1;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
.tip-icon {
|
|
||||||
color: var(--ch-accent);
|
|
||||||
font-size: 22px;
|
|
||||||
}
|
|
||||||
.dismiss-tip {
|
|
||||||
border: 0;
|
|
||||||
color: var(--ch-text);
|
|
||||||
background: transparent;
|
|
||||||
font-size: 26px;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-left: auto;
|
|
||||||
padding: 0 8px;
|
|
||||||
}
|
|
||||||
.drag-ghost {
|
.drag-ghost {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 10000;
|
z-index: 10000;
|
||||||
@@ -392,6 +358,22 @@
|
|||||||
.inspector-tabs {
|
.inspector-tabs {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
:global(.island-inspector) {
|
||||||
|
color: var(--ch-text);
|
||||||
|
background: var(--ch-surface);
|
||||||
|
}
|
||||||
|
:global(.island-inspector .el-drawer__header) {
|
||||||
|
color: var(--ch-text);
|
||||||
|
}
|
||||||
|
:global(.island-inspector .el-input-number),
|
||||||
|
:global(.island-inspector .el-select) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
:global(.island-inspector .el-input__wrapper),
|
||||||
|
:global(.island-inspector .el-select__wrapper) {
|
||||||
|
background: var(--ch-surface);
|
||||||
|
border-radius: var(--ch-radius-control);
|
||||||
|
}
|
||||||
.row-actions {
|
.row-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
@@ -426,9 +408,6 @@
|
|||||||
.scheme-tools {
|
.scheme-tools {
|
||||||
flex: 1 1 100%;
|
flex: 1 1 100%;
|
||||||
}
|
}
|
||||||
.editor-tip {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
.preview-toolbar .hint {
|
.preview-toolbar .hint {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { countDates, CoursewareFolders } from '@classhelper/ui';
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import {
|
import {
|
||||||
@@ -14,45 +15,47 @@ import { useRealtimeStore } from '../stores/realtime.js';
|
|||||||
const realtime = useRealtimeStore();
|
const realtime = useRealtimeStore();
|
||||||
const localItems = ref<CoursewareDto[]>([]),
|
const localItems = ref<CoursewareDto[]>([]),
|
||||||
library = ref<'shared' | 'local'>('shared'),
|
library = ref<'shared' | 'local'>('shared'),
|
||||||
teacher = ref(''),
|
teacher = ref('');
|
||||||
archive = ref('');
|
|
||||||
const source = computed(() => (library.value === 'local' ? localItems.value : items.value));
|
const source = computed(() => (library.value === 'local' ? localItems.value : items.value));
|
||||||
const teachers = computed(() => [...new Set(source.value.map((item) => item.teacher.name))]);
|
const teachers = computed(() => [...new Set(source.value.map((item) => item.teacher.name))]);
|
||||||
const archiveFolders = computed(() => [
|
|
||||||
...new Set(
|
|
||||||
source.value
|
|
||||||
.filter((item) => !teacher.value || item.teacher.name === teacher.value)
|
|
||||||
.map((item) => item.archivePath?.split('/').slice(0, -1).join('/') || item.archiveDate),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
async function refreshLocal() {
|
async function refreshLocal() {
|
||||||
localItems.value = (await window.desktop?.listLocalCourseware()) || [];
|
localItems.value = (await window.desktop?.listLocalCourseware()) || [];
|
||||||
}
|
}
|
||||||
// 两个来源的教师与目录不通用,切换时清空,避免看到空列表却找不到原因。
|
// 两个来源的教师与目录不通用,切换时清空,避免看到空列表却找不到原因。
|
||||||
watch(library, () => {
|
watch(library, () => {
|
||||||
teacher.value = '';
|
teacher.value = '';
|
||||||
archive.value = '';
|
folderPath.value = '';
|
||||||
|
folderOwner.value = '';
|
||||||
});
|
});
|
||||||
const items = ref<CoursewareDto[]>([]),
|
const items = ref<CoursewareDto[]>([]),
|
||||||
loading = ref(false),
|
loading = ref(false),
|
||||||
offline = ref(false),
|
offline = ref(false),
|
||||||
error = ref('');
|
error = ref('');
|
||||||
|
const folderPath = ref(''),
|
||||||
|
folderOwner = ref(''),
|
||||||
|
grouping = ref('folder');
|
||||||
const query = ref(''),
|
const query = ref(''),
|
||||||
category = ref(''),
|
category = ref(''),
|
||||||
date = ref(''),
|
date = ref(''),
|
||||||
busy = ref<string[]>([]),
|
busy = ref<string[]>([]),
|
||||||
transfer = ref<CoursewareTransfer | null>(null);
|
transfer = ref<CoursewareTransfer | null>(null);
|
||||||
const filtered = computed(() =>
|
const dateSource = computed(() =>
|
||||||
source.value.filter(
|
source.value.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
(!query.value || `${item.name} ${item.teacher.name}`.includes(query.value)) &&
|
(!query.value || `${item.name} ${item.teacher.name}`.includes(query.value)) &&
|
||||||
|
(grouping.value !== 'folder' ||
|
||||||
|
((item.folderPath || '') === folderPath.value &&
|
||||||
|
(folderOwner.value
|
||||||
|
? item.teacher.id === folderOwner.value
|
||||||
|
: new Set(items.value.map((i) => i.teacher.id)).size <= 1))) &&
|
||||||
(!category.value || item.category === category.value) &&
|
(!category.value || item.category === category.value) &&
|
||||||
(!teacher.value || item.teacher.name === teacher.value) &&
|
(!teacher.value || item.teacher.name === teacher.value),
|
||||||
(!archive.value ||
|
|
||||||
(item.archivePath?.startsWith(archive.value + '/') ?? item.archiveDate === archive.value)) &&
|
|
||||||
(!date.value || item.archiveDate === date.value),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
const dateMarks = computed(() => countDates(dateSource.value, (item) => item.archiveDate));
|
||||||
|
const filtered = computed(() =>
|
||||||
|
dateSource.value.filter((item) => !date.value || item.archiveDate === date.value),
|
||||||
|
);
|
||||||
let disposed = false;
|
let disposed = false;
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
await refreshLocal();
|
await refreshLocal();
|
||||||
@@ -119,6 +122,16 @@ onUnmounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="page courseware-page">
|
<div class="page courseware-page">
|
||||||
|
<el-radio-group v-model="grouping">
|
||||||
|
<el-radio-button value="folder">文件夹</el-radio-button>
|
||||||
|
<el-radio-button value="date">日期归档</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
<CoursewareFolders
|
||||||
|
v-if="grouping === 'folder'"
|
||||||
|
v-model:path="folderPath"
|
||||||
|
v-model:owner="folderOwner"
|
||||||
|
:items="source"
|
||||||
|
/>
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">课件</h2>
|
<h2 class="page-title">课件</h2>
|
||||||
@@ -153,17 +166,14 @@ onUnmounted(() => {
|
|||||||
<el-radio-button value="shared">班级共享</el-radio-button>
|
<el-radio-button value="shared">班级共享</el-radio-button>
|
||||||
<el-radio-button value="local">本机归档</el-radio-button>
|
<el-radio-button value="local">本机归档</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
<el-select v-model="teacher" clearable placeholder="全部教师" @change="archive = ''">
|
<el-select v-model="teacher" clearable placeholder="全部教师">
|
||||||
<el-option v-for="name in teachers" :key="name" :label="name" :value="name" />
|
<el-option v-for="name in teachers" :key="name" :label="name" :value="name" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select v-model="archive" clearable filterable placeholder="年 / 月 / 日 / 时间">
|
|
||||||
<el-option v-for="folder in archiveFolders" :key="folder" :label="folder" :value="folder" />
|
|
||||||
</el-select>
|
|
||||||
<el-input v-model="query" clearable placeholder="搜索课件或教师" />
|
<el-input v-model="query" clearable placeholder="搜索课件或教师" />
|
||||||
<el-select v-model="category" clearable placeholder="全部类型">
|
<el-select v-model="category" clearable placeholder="全部类型">
|
||||||
<el-option v-for="(label, key) in COURSEWARE_CATEGORIES" :key="key" :label="label" :value="key" />
|
<el-option v-for="(label, key) in COURSEWARE_CATEGORIES" :key="key" :label="label" :value="key" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-date-picker v-model="date" value-format="YYYY-MM-DD" placeholder="归档日期" />
|
<ch-date-picker v-model="date" :marks="dateMarks" value-format="YYYY-MM-DD" placeholder="归档日期" />
|
||||||
</div>
|
</div>
|
||||||
<el-card shadow="never" class="table-card" v-loading="loading">
|
<el-card shadow="never" class="table-card" v-loading="loading">
|
||||||
<el-table
|
<el-table
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { getCacheScope } from '../cache/scope.js';
|
||||||
|
import type { CalendarRange } from '@classhelper/ui';
|
||||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
@@ -60,19 +62,13 @@ const selectedDate = ref(
|
|||||||
? route.query.date
|
? route.query.date
|
||||||
: dayKeyLocal(new Date()),
|
: dayKeyLocal(new Date()),
|
||||||
);
|
);
|
||||||
/** 有作业的日期(日期选择器高亮):来自 GET /homeworks/days */
|
const calendarRevision = ref(0);
|
||||||
const dayMarks = ref<Map<string, number>>(new Map());
|
|
||||||
/** 录入作业的科目下拉 */
|
/** 录入作业的科目下拉 */
|
||||||
const courses = ref<CourseDto[]>([]);
|
const courses = ref<CourseDto[]>([]);
|
||||||
|
|
||||||
/** 选中的是否就是今天(标题与按钮文案用) */
|
/** 选中的是否就是今天(标题与按钮文案用) */
|
||||||
const isToday = computed(() => selectedDate.value === dayKeyLocal(now.value));
|
const isToday = computed(() => selectedDate.value === dayKeyLocal(now.value));
|
||||||
|
|
||||||
/** 日期选择器:给有作业的日期加高亮类 */
|
|
||||||
function dayCellClass(date: Date): string {
|
|
||||||
return dayMarks.value.has(dayKeyLocal(date)) ? 'day-has-homework' : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
async function selectDate(value: string | null): Promise<void> {
|
async function selectDate(value: string | null): Promise<void> {
|
||||||
if (!value || !isDayKey(value)) return;
|
if (!value || !isDayKey(value)) return;
|
||||||
selectedDate.value = value;
|
selectedDate.value = value;
|
||||||
@@ -279,6 +275,7 @@ function onResize(): void {
|
|||||||
/* ------------------------------------------------------------ 数据加载 */
|
/* ------------------------------------------------------------ 数据加载 */
|
||||||
|
|
||||||
async function loadHomework(): Promise<void> {
|
async function loadHomework(): Promise<void> {
|
||||||
|
calendarRevision.value++;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const classId = auth.classId ?? undefined;
|
const classId = auth.classId ?? undefined;
|
||||||
@@ -294,7 +291,6 @@ async function loadHomework(): Promise<void> {
|
|||||||
fromCache.value = result.fromCache;
|
fromCache.value = result.fromCache;
|
||||||
updatedAt.value = result.updatedAt;
|
updatedAt.value = result.updatedAt;
|
||||||
if (!result.fromCache) appStore.markSynced();
|
if (!result.fromCache) appStore.markSynced();
|
||||||
void loadDayMarks(classId);
|
|
||||||
if (current.value) {
|
if (current.value) {
|
||||||
current.value = homeworks.value.find((item) => item.id === current.value?.id) ?? current.value;
|
current.value = homeworks.value.find((item) => item.id === current.value?.id) ?? current.value;
|
||||||
}
|
}
|
||||||
@@ -304,22 +300,15 @@ async function loadHomework(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async function calendarDays(range: CalendarRange) {
|
||||||
* 拉取"哪些天有作业"(日期选择器高亮)。
|
const result = await fetchWithCache(
|
||||||
*
|
'homeworks',
|
||||||
* 范围取当前查看日期前后各 45 天:教室电脑上翻月份也能看到有作业的日子。
|
`days:${JSON.stringify(range)}`,
|
||||||
*/
|
() => homeworkApi.days({ ...range, classId: auth.classId || undefined }),
|
||||||
async function loadDayMarks(classId: string | undefined): Promise<void> {
|
{ days: [] as { date: string; count: number }[] },
|
||||||
try {
|
);
|
||||||
const from = shiftDayKey(selectedDate.value, -45);
|
return result.data.days;
|
||||||
const to = shiftDayKey(selectedDate.value, 45);
|
|
||||||
const result = await homeworkApi.days({ classId, from, to });
|
|
||||||
dayMarks.value = new Map(result.days.map((item) => [item.date, item.count]));
|
|
||||||
} catch {
|
|
||||||
// 离线/失败时保留上一次的高亮,不打断展示
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** 科目下拉(录入作业时可选) */
|
/** 科目下拉(录入作业时可选) */
|
||||||
async function loadCourses(): Promise<void> {
|
async function loadCourses(): Promise<void> {
|
||||||
if (!auth.classId) return;
|
if (!auth.classId) return;
|
||||||
@@ -569,15 +558,19 @@ onUnmounted(() => {
|
|||||||
<el-button-group>
|
<el-button-group>
|
||||||
<el-button :icon="'ArrowLeft'" @click="shiftDate(-1)">前一天</el-button>
|
<el-button :icon="'ArrowLeft'" @click="shiftDate(-1)">前一天</el-button>
|
||||||
<el-button :disabled="isToday" @click="selectDate(dayKeyLocal(now))">今天</el-button>
|
<el-button :disabled="isToday" @click="selectDate(dayKeyLocal(now))">今天</el-button>
|
||||||
<el-button @click="shiftDate(1)">后一天<el-icon class="ml-4"><ArrowRight /></el-icon></el-button>
|
<el-button @click="shiftDate(1)">
|
||||||
|
后一天
|
||||||
|
<el-icon class="ml-4"><ArrowRight /></el-icon>
|
||||||
|
</el-button>
|
||||||
</el-button-group>
|
</el-button-group>
|
||||||
<el-date-picker
|
<ch-date-picker
|
||||||
:model-value="selectedDate"
|
:model-value="selectedDate"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
placeholder="选择日期"
|
placeholder="选择日期"
|
||||||
class="day-picker"
|
class="day-picker"
|
||||||
:cell-class-name="dayCellClass"
|
:load-marks="calendarDays"
|
||||||
|
:scope-key="JSON.stringify([getCacheScope(), selectedDate, calendarRevision])"
|
||||||
@update:model-value="(value: string | null) => selectDate(value)"
|
@update:model-value="(value: string | null) => selectDate(value)"
|
||||||
/>
|
/>
|
||||||
<el-radio-group v-model="viewMode" @change="saveBoardSettings">
|
<el-radio-group v-model="viewMode" @change="saveBoardSettings">
|
||||||
@@ -765,11 +758,12 @@ onUnmounted(() => {
|
|||||||
<el-dialog v-model="createVisible" title="录入作业" width="620px">
|
<el-dialog v-model="createVisible" title="录入作业" width="620px">
|
||||||
<el-form label-width="90px">
|
<el-form label-width="90px">
|
||||||
<el-form-item label="所属日期">
|
<el-form-item label="所属日期">
|
||||||
<el-date-picker
|
<ch-date-picker
|
||||||
:model-value="selectedDate"
|
:model-value="selectedDate"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
:cell-class-name="dayCellClass"
|
:load-marks="calendarDays"
|
||||||
|
:scope-key="JSON.stringify([getCacheScope(), calendarRevision])"
|
||||||
@update:model-value="(value: string | null) => selectDate(value)"
|
@update:model-value="(value: string | null) => selectDate(value)"
|
||||||
/>
|
/>
|
||||||
<span class="text-muted ml-8">默认就是当前正在查看的这一天</span>
|
<span class="text-muted ml-8">默认就是当前正在查看的这一天</span>
|
||||||
@@ -810,7 +804,9 @@ onUnmounted(() => {
|
|||||||
>
|
>
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
<span class="text-muted">点一下追加到「{{ lastFocused === 'title' ? '标题' : '作业要求' }}」</span>
|
<span class="text-muted">
|
||||||
|
点一下追加到「{{ lastFocused === 'title' ? '标题' : '作业要求' }}」
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@@ -880,19 +876,6 @@ onUnmounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 日期选择器:有作业的日子加一个圆点,翻月份时一眼看出哪天有作业 */
|
|
||||||
:deep(.day-has-homework .el-date-table-cell__text)::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
bottom: 2px;
|
|
||||||
width: 4px;
|
|
||||||
height: 4px;
|
|
||||||
margin-left: -2px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: currentColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
.day-picker {
|
.day-picker {
|
||||||
width: 168px;
|
width: 168px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
import { notificationApi } from '../api/index.js';
|
||||||
|
import { fetchWithCache } from '../cache/index.js';
|
||||||
|
import { getCacheScope } from '../cache/scope.js';
|
||||||
|
import { useAuthStore } from '../stores/auth.js';
|
||||||
|
import type { CalendarRange } from '@classhelper/ui';
|
||||||
|
import { countDates } from '@classhelper/ui';
|
||||||
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import {
|
import {
|
||||||
NOTIFICATION_PRIORITIES,
|
NOTIFICATION_PRIORITIES,
|
||||||
@@ -22,21 +28,70 @@ const filter = ref<'all' | 'unread'>('all');
|
|||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const current = ref<NotificationDto | null>(null);
|
const current = ref<NotificationDto | null>(null);
|
||||||
const marking = ref(false);
|
const marking = ref(false);
|
||||||
|
const auth = useAuthStore();
|
||||||
|
const calendarRevision = ref(0);
|
||||||
|
const dayItems = ref<NotificationDto[] | null>(null);
|
||||||
|
let calendarRequest = 0,
|
||||||
|
disposed = false;
|
||||||
|
async function calendarDays(range: CalendarRange) {
|
||||||
|
const params = {
|
||||||
|
...range,
|
||||||
|
classId: auth.classId || undefined,
|
||||||
|
createdBy: creatorFilter.value || undefined,
|
||||||
|
priority: priorityFilter.value || undefined,
|
||||||
|
unreadOnly: filter.value === 'unread',
|
||||||
|
};
|
||||||
|
const result = await fetchWithCache(
|
||||||
|
'notifications',
|
||||||
|
'days:' + JSON.stringify(params),
|
||||||
|
() => notificationApi.days(params),
|
||||||
|
{ days: dateMarks.value },
|
||||||
|
);
|
||||||
|
return result.data.days;
|
||||||
|
}
|
||||||
|
async function loadDay(): Promise<void> {
|
||||||
|
const request = ++calendarRequest,
|
||||||
|
scope = getCacheScope();
|
||||||
|
if (!dayFilter.value) {
|
||||||
|
dayItems.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const params = {
|
||||||
|
date: dayFilter.value,
|
||||||
|
classId: auth.classId || undefined,
|
||||||
|
createdBy: creatorFilter.value || undefined,
|
||||||
|
priority: priorityFilter.value || undefined,
|
||||||
|
unreadOnly: filter.value === 'unread',
|
||||||
|
};
|
||||||
|
const fallback = store.items.filter((item) => assignDay(item) === params.date);
|
||||||
|
dayItems.value = [];
|
||||||
|
const result = await fetchWithCache<NotificationDto[]>(
|
||||||
|
'notifications',
|
||||||
|
'date:' + JSON.stringify(params),
|
||||||
|
() => notificationApi.list(params),
|
||||||
|
fallback,
|
||||||
|
);
|
||||||
|
if (!disposed && request === calendarRequest && scope === getCacheScope()) dayItems.value = result.data;
|
||||||
|
}
|
||||||
|
|
||||||
const visibleItems = computed(() =>
|
const visibleItems = computed(() =>
|
||||||
filter.value === 'unread' ? store.items.filter((item) => !item.read) : store.items,
|
filter.value === 'unread'
|
||||||
|
? (dayItems.value ?? store.items).filter((item) => !item.read)
|
||||||
|
: (dayItems.value ?? store.items),
|
||||||
);
|
);
|
||||||
|
|
||||||
/* ------------------------------------------------------- 按天归档 / 按发布人 / 按类型 */
|
watch(
|
||||||
/**
|
() => store.items,
|
||||||
* 三个筛选都在**已加载的列表**上做,不再请求服务端:
|
() => {
|
||||||
* 客户端是离线优先的(AGENTS.md 的现行工程约定),断网回退缓存时归档功能必须照常可用。
|
calendarRevision.value++;
|
||||||
* 口径与服务端一致:按 `assignDate`(本地日期)分组 —— 用 createdAt 的 UTC 切片会把晚上
|
},
|
||||||
* 发出来的通知算到第二天(AGENTS.md 的现行工程约定)。
|
);
|
||||||
*/
|
|
||||||
const dayFilter = ref('');
|
const dayFilter = ref('');
|
||||||
const creatorFilter = ref('');
|
const creatorFilter = ref('');
|
||||||
const priorityFilter = ref('');
|
const priorityFilter = ref('');
|
||||||
|
watch([dayFilter, creatorFilter, priorityFilter, filter, () => store.items], () => {
|
||||||
|
void loadDay();
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一条通知归到哪一天。
|
* 一条通知归到哪一天。
|
||||||
@@ -47,16 +102,17 @@ function assignDay(item: NotificationDto): string {
|
|||||||
return item.assignDate || dayKeyLocal(new Date(item.createdAt));
|
return item.assignDate || dayKeyLocal(new Date(item.createdAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
const dayOptions = computed(() => {
|
const dateMarks = computed(() =>
|
||||||
const map = new Map<string, number>();
|
countDates(
|
||||||
for (const item of store.items) {
|
store.items.filter(
|
||||||
const day = assignDay(item);
|
(item) =>
|
||||||
map.set(day, (map.get(day) ?? 0) + 1);
|
(filter.value !== 'unread' || !item.read) &&
|
||||||
}
|
(!creatorFilter.value || item.createdBy === creatorFilter.value) &&
|
||||||
return [...map.entries()]
|
(!priorityFilter.value || item.priority === priorityFilter.value),
|
||||||
.sort((a, b) => b[0].localeCompare(a[0]))
|
),
|
||||||
.map(([date, count]) => ({ date, count }));
|
assignDay,
|
||||||
});
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const creatorOptions = computed(() => {
|
const creatorOptions = computed(() => {
|
||||||
const map = new Map<string, { name: string; count: number }>();
|
const map = new Map<string, { name: string; count: number }>();
|
||||||
@@ -117,6 +173,7 @@ async function markRead(item: NotificationDto): Promise<void> {
|
|||||||
marking.value = true;
|
marking.value = true;
|
||||||
try {
|
try {
|
||||||
await store.markRead(item.id);
|
await store.markRead(item.id);
|
||||||
|
item.read = true;
|
||||||
if (current.value?.id === item.id) current.value = { ...item, read: true };
|
if (current.value?.id === item.id) current.value = { ...item, read: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(error instanceof Error ? error.message : '标记已读失败');
|
ElMessage.error(error instanceof Error ? error.message : '标记已读失败');
|
||||||
@@ -147,6 +204,8 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
disposed = true;
|
||||||
|
++calendarRequest;
|
||||||
// store 是全局的,这里无需清理;保留钩子以便将来取消订阅
|
// store 是全局的,这里无需清理;保留钩子以便将来取消订阅
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -175,16 +234,14 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-card v-loading="store.loading" shadow="never">
|
<el-card v-loading="store.loading" shadow="never">
|
||||||
<!-- 按天归档 + 按发布人 + 按类型;都在本地已加载的列表上筛(离线也能用) -->
|
|
||||||
<div class="notice-filters">
|
<div class="notice-filters">
|
||||||
<el-select v-model="dayFilter" placeholder="按天归档" clearable size="small" style="width: 150px">
|
<ch-date-picker
|
||||||
<el-option
|
v-model="dayFilter"
|
||||||
v-for="item in dayOptions"
|
:load-marks="calendarDays"
|
||||||
:key="item.date"
|
:scope-key="JSON.stringify([creatorFilter, priorityFilter, filter, calendarRevision])"
|
||||||
:label="`${item.date}(${item.count})`"
|
placeholder="日期"
|
||||||
:value="item.date"
|
clearable
|
||||||
/>
|
/>
|
||||||
</el-select>
|
|
||||||
<el-select
|
<el-select
|
||||||
v-model="creatorFilter"
|
v-model="creatorFilter"
|
||||||
placeholder="全部发布人"
|
placeholder="全部发布人"
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import UpdateProgress from '../../components/UpdateProgress.vue';
|
import UpdateProgress from '../../components/UpdateProgress.vue';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { ElMessage } from 'element-plus';
|
|
||||||
import type { UpdateInfo } from '@classhelper/shared';
|
|
||||||
import type { DesktopAppInfo } from '../../../types/desktop.js';
|
import type { DesktopAppInfo } from '../../../types/desktop.js';
|
||||||
import { useAppStore } from '../../stores/app.js';
|
import { useAppStore } from '../../stores/app.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关于(ClassIsland 同款折叠卡片式):
|
* 关于(ClassIsland 同款折叠卡片式):
|
||||||
* 应用信息(版本/运行时/常用链接/检查更新)→ 诊断信息(排查问题用)→ 鸣谢。
|
* 应用信息(版本/运行时/常用链接)→ 诊断信息(排查问题用)→ 鸣谢。
|
||||||
* 所有外链走主进程 openExternal(只放行 http/https,见 main/ipc.ts 的白名单)。
|
* 所有外链走主进程 openExternal(只放行 http/https,见 main/ipc.ts 的白名单)。
|
||||||
*/
|
*/
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
@@ -17,10 +15,6 @@ const appInfo = ref<DesktopAppInfo | null>(null);
|
|||||||
/** 折叠面板默认展开第一项(应用信息),诊断信息默认收起 */
|
/** 折叠面板默认展开第一项(应用信息),诊断信息默认收起 */
|
||||||
const expandedNames = ref(['app']);
|
const expandedNames = ref(['app']);
|
||||||
|
|
||||||
/** 检查更新:结果由主进程直连 GitHub 得到(见 main/update.ts) */
|
|
||||||
const checking = ref(false);
|
|
||||||
const updateInfo = ref<UpdateInfo | null>(null);
|
|
||||||
|
|
||||||
const PROJECT_URL = 'https://github.com/LoveChengke/ClassHelper';
|
const PROJECT_URL = 'https://github.com/LoveChengke/ClassHelper';
|
||||||
const ISSUES_URL = 'https://github.com/LoveChengke/ClassHelper/issues';
|
const ISSUES_URL = 'https://github.com/LoveChengke/ClassHelper/issues';
|
||||||
|
|
||||||
@@ -38,44 +32,19 @@ async function openExternal(url: string): Promise<void> {
|
|||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查更新。
|
|
||||||
*
|
|
||||||
* @param force true = 用户主动点击(绕过主进程缓存);false = 进页面时带出启动自动检查的结果
|
|
||||||
*/
|
|
||||||
async function checkUpdate(force: boolean): Promise<void> {
|
|
||||||
if (!window.desktop?.checkForUpdates) return;
|
|
||||||
checking.value = true;
|
|
||||||
try {
|
|
||||||
updateInfo.value = await window.desktop.checkForUpdates(force);
|
|
||||||
} finally {
|
|
||||||
checking.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 忽略这个版本:写进配置,启动自动检查不再提示它 */
|
|
||||||
async function ignoreVersion(): Promise<void> {
|
|
||||||
const version = updateInfo.value?.latestVersion;
|
|
||||||
if (!version) return;
|
|
||||||
await window.desktop?.ignoreUpdateVersion(version);
|
|
||||||
ElMessage.success(`已忽略 v${version} 的更新提示`);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!window.desktop) return;
|
if (!window.desktop) return;
|
||||||
appInfo.value = await window.desktop.getAppInfo().catch(() => null);
|
appInfo.value = await window.desktop.getAppInfo().catch(() => null);
|
||||||
// 带出启动自动检查的结果(命中主进程缓存,不会再发一次请求)
|
|
||||||
void checkUpdate(false);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<UpdateProgress />
|
<UpdateProgress />
|
||||||
|
<p class="text-muted">客户端更新由管理端统一下发。</p>
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">关于</h2>
|
<h2 class="page-title">关于</h2>
|
||||||
<p class="page-subtitle">版本、诊断信息与鸣谢</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -108,51 +77,6 @@ onMounted(async () => {
|
|||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="平台">{{ appInfo?.platform ?? '-' }}</el-descriptions-item>
|
<el-descriptions-item label="平台">{{ appInfo?.platform ?? '-' }}</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
|
|
||||||
<!-- 检查更新:直连 GitHub 看最新的 Release 是不是比本机新 -->
|
|
||||||
<div class="about-update" data-test="update-check">
|
|
||||||
<div class="about-update-head">
|
|
||||||
<span class="about-update-label">检查更新</span>
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
:loading="checking"
|
|
||||||
data-test="update-check-button"
|
|
||||||
@click="checkUpdate(true)"
|
|
||||||
>
|
|
||||||
检查更新
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="about-update-body">
|
|
||||||
<template v-if="checking">正在检查…</template>
|
|
||||||
<template v-else-if="!updateInfo">尚未检查</template>
|
|
||||||
<template v-else-if="!updateInfo.ok">
|
|
||||||
<!-- 教室机器没有外网是常态,这里只是"查不到",不是错误 -->
|
|
||||||
<span class="about-update-muted">{{ updateInfo.error ?? '暂时无法检查更新' }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="updateInfo.hasUpdate">
|
|
||||||
<el-tag size="small" type="success" effect="light">
|
|
||||||
发现新版本 v{{ updateInfo.latestVersion }}
|
|
||||||
</el-tag>
|
|
||||||
<span class="about-update-muted">当前 v{{ updateInfo.currentVersion }}</span>
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
data-test="update-download"
|
|
||||||
@click="openExternal(updateInfo.releaseUrl)"
|
|
||||||
>
|
|
||||||
前往下载
|
|
||||||
</el-button>
|
|
||||||
<el-button link size="small" @click="ignoreVersion">忽略此版本</el-button>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<el-tag size="small" type="info" effect="plain">已是最新版本</el-tag>
|
|
||||||
<span class="about-update-muted">
|
|
||||||
v{{ updateInfo.currentVersion }} · {{ updateInfo.latestVersion }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
|
|
||||||
@@ -220,7 +144,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.about-extra {
|
.about-extra {
|
||||||
margin-left: auto;
|
margin-left: 12px;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
@@ -249,55 +173,4 @@ onMounted(async () => {
|
|||||||
color: var(--ch-text-secondary);
|
color: var(--ch-text-secondary);
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 检查更新:颜色一律走 --ch-* 变量(深色主题下不能写死浅色底/深色字) */
|
|
||||||
.about-update {
|
|
||||||
margin-top: 12px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid var(--ch-border);
|
|
||||||
border-radius: var(--ch-radius-card);
|
|
||||||
background: var(--ch-layer-alt);
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-update-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-update-label {
|
|
||||||
font-size: 12.5px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--ch-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-update-body {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
margin-top: 8px;
|
|
||||||
font-size: 12.5px;
|
|
||||||
color: var(--ch-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-update-muted {
|
|
||||||
color: var(--ch-text-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-thanks {
|
|
||||||
margin: 0;
|
|
||||||
padding-left: 18px;
|
|
||||||
line-height: 2;
|
|
||||||
font-size: 12.5px;
|
|
||||||
color: var(--ch-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-quote {
|
|
||||||
margin: 18px 0 4px;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ch-text-tertiary);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
@@ -27,7 +27,6 @@ async function logout(): Promise<void> {
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">账号</h2>
|
<h2 class="page-title">账号</h2>
|
||||||
<p class="page-subtitle">本机登录的班级账号</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ async function selectTheme(value: 'light' | 'dark'): Promise<void> {
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">外观</h2>
|
<h2 class="page-title">外观</h2>
|
||||||
<p class="page-subtitle">黑夜与白天模式,切换立即生效并自动保存</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -50,7 +49,10 @@ async function selectTheme(value: 'light' | 'dark'): Promise<void> {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="theme-name">
|
<span class="theme-name">
|
||||||
<el-icon><Sunny v-if="option.value === 'light'" /><Moon v-else /></el-icon>
|
<el-icon>
|
||||||
|
<Sunny v-if="option.value === 'light'" />
|
||||||
|
<Moon v-else />
|
||||||
|
</el-icon>
|
||||||
{{ option.label }}
|
{{ option.label }}
|
||||||
</span>
|
</span>
|
||||||
<span class="theme-desc">{{ option.desc }}</span>
|
<span class="theme-desc">{{ option.desc }}</span>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { confirmAction } from '../../composables/confirm.js';
|
import { confirmAction } from '../../composables/confirm.js';
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { formatDate, relativeTime, type UpdateInfo } from '@classhelper/shared';
|
import { formatDate, relativeTime } from '@classhelper/shared';
|
||||||
import type { ClientAgentStatus, DesktopAppInfo } from '../../../types/desktop.js';
|
import type { ClientAgentStatus, DesktopAppInfo } from '../../../types/desktop.js';
|
||||||
import { useAppStore } from '../../stores/app.js';
|
import { useAppStore } from '../../stores/app.js';
|
||||||
import { useUiStore } from '../../stores/ui.js';
|
import { useUiStore } from '../../stores/ui.js';
|
||||||
@@ -42,7 +42,6 @@ async function loadAll(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
await loadAppInfo();
|
await loadAppInfo();
|
||||||
await refreshAgent();
|
await refreshAgent();
|
||||||
await loadIgnoredVersion();
|
|
||||||
await appStore.refreshCacheStats();
|
await appStore.refreshCacheStats();
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@@ -110,51 +109,6 @@ async function openLogDir(): Promise<void> {
|
|||||||
if (!ok) ElMessage.warning('打开日志目录失败,请按上面的路径手动前往');
|
if (!ok) ElMessage.warning('打开日志目录失败,请按上面的路径手动前往');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ 更新 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新检查。
|
|
||||||
*
|
|
||||||
* 「立即检查」走 `checkForUpdates(true)`:**强制绕过主进程那 30 分钟缓存**。
|
|
||||||
* 这是本页与「关于」页的区别 —— 那边用户点检查也可能是缓存结果(省流量),
|
|
||||||
* 这边维护者要的是"现在到底拿得到什么",所以按钮默认就是强制的。
|
|
||||||
*/
|
|
||||||
const checking = ref(false);
|
|
||||||
const updateInfo = ref<UpdateInfo | null>(null);
|
|
||||||
const ignoredUpdateVersion = ref('');
|
|
||||||
|
|
||||||
async function checkUpdate(force: boolean): Promise<void> {
|
|
||||||
if (!window.desktop?.checkForUpdates) return;
|
|
||||||
checking.value = true;
|
|
||||||
try {
|
|
||||||
updateInfo.value = await window.desktop.checkForUpdates(force);
|
|
||||||
} finally {
|
|
||||||
checking.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadIgnoredVersion(): Promise<void> {
|
|
||||||
if (!window.desktop?.getConfig) return;
|
|
||||||
const stored = await window.desktop.getConfig().catch(() => null);
|
|
||||||
ignoredUpdateVersion.value = stored?.ignoredUpdateVersion ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ignoreVersion(): Promise<void> {
|
|
||||||
const version = updateInfo.value?.latestVersion;
|
|
||||||
if (!version || !window.desktop?.ignoreUpdateVersion) return;
|
|
||||||
await window.desktop.ignoreUpdateVersion(version);
|
|
||||||
ignoredUpdateVersion.value = version;
|
|
||||||
ElMessage.success(`已忽略 v${version}:启动时的自动检查不再提示它`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 忽略是可逆的(排查线上"用户说不再提示"时经常要把它清掉),顺手给一个恢复入口 */
|
|
||||||
async function clearIgnoredVersion(): Promise<void> {
|
|
||||||
if (!window.desktop?.saveConfig) return;
|
|
||||||
const saved = await window.desktop.saveConfig({ ignoredUpdateVersion: '' });
|
|
||||||
ignoredUpdateVersion.value = saved.ignoredUpdateVersion;
|
|
||||||
ElMessage.success('已恢复该版本的更新提示');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ 调试工具 */
|
/* ------------------------------------------------------------ 调试工具 */
|
||||||
|
|
||||||
const openingDevTools = ref(false);
|
const openingDevTools = ref(false);
|
||||||
@@ -211,8 +165,6 @@ async function clearCache(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadAll();
|
await loadAll();
|
||||||
// 带出启动自动检查的结果(这次命中主进程缓存,不会真的再发一次请求)
|
|
||||||
void checkUpdate(false);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -221,7 +173,6 @@ onMounted(async () => {
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">开发者</h2>
|
<h2 class="page-title">开发者</h2>
|
||||||
<p class="page-subtitle">版本与平台、设备上报、日志、更新与调试工具</p>
|
|
||||||
</div>
|
</div>
|
||||||
<el-button :loading="loading" data-test="dev-refresh" @click="loadAll">
|
<el-button :loading="loading" data-test="dev-refresh" @click="loadAll">
|
||||||
<el-icon><Refresh /></el-icon>
|
<el-icon><Refresh /></el-icon>
|
||||||
@@ -327,56 +278,6 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 更新 -->
|
|
||||||
<el-card shadow="never" class="mt-12">
|
|
||||||
<template #header><span>更新</span></template>
|
|
||||||
<div class="toolbar">
|
|
||||||
<el-button :loading="checking" data-test="dev-check-update" @click="checkUpdate(true)">
|
|
||||||
强制检查更新
|
|
||||||
</el-button>
|
|
||||||
<span class="text-muted">绕过主进程 30 分钟缓存,直接问 GitHub</span>
|
|
||||||
</div>
|
|
||||||
<el-descriptions :column="1" border size="small" class="mt-12">
|
|
||||||
<el-descriptions-item label="本次结果">
|
|
||||||
<template v-if="checking">正在检查…</template>
|
|
||||||
<template v-else-if="!updateInfo">尚未检查</template>
|
|
||||||
<template v-else-if="!updateInfo.ok">
|
|
||||||
<span class="text-muted">{{ updateInfo.error ?? '暂时无法检查更新' }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="updateInfo.hasUpdate">
|
|
||||||
<el-tag size="small" type="success" effect="light">
|
|
||||||
有新版本 v{{ updateInfo.latestVersion }}
|
|
||||||
</el-tag>
|
|
||||||
<span class="text-muted">当前 v{{ updateInfo.currentVersion }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<el-tag size="small" type="info" effect="plain">已是最新版本</el-tag>
|
|
||||||
<span class="text-muted">v{{ updateInfo.currentVersion }}</span>
|
|
||||||
</template>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="检查时间">
|
|
||||||
{{ updateInfo?.checkedAt ? formatDate(updateInfo.checkedAt, true) : '—' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="已忽略的版本">
|
|
||||||
<template v-if="ignoredUpdateVersion">
|
|
||||||
<span class="mono">v{{ ignoredUpdateVersion }}</span>
|
|
||||||
<el-button link type="primary" size="small" @click="clearIgnoredVersion">恢复提示</el-button>
|
|
||||||
</template>
|
|
||||||
<span v-else class="text-muted">无</span>
|
|
||||||
</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
<div class="toolbar mt-12">
|
|
||||||
<el-button
|
|
||||||
:disabled="!updateInfo?.latestVersion"
|
|
||||||
data-test="dev-ignore-version"
|
|
||||||
@click="ignoreVersion"
|
|
||||||
>
|
|
||||||
不再提示该版本
|
|
||||||
</el-button>
|
|
||||||
<span class="text-muted">写入配置后,启动时的自动检查会跳过它</span>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<!-- 调试工具 -->
|
<!-- 调试工具 -->
|
||||||
<el-card shadow="never" class="mt-12">
|
<el-card shadow="never" class="mt-12">
|
||||||
<template #header><span>调试工具</span></template>
|
<template #header><span>调试工具</span></template>
|
||||||
|
|||||||
@@ -308,7 +308,6 @@ onBeforeUnmount(() => {
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">通用</h2>
|
<h2 class="page-title">通用</h2>
|
||||||
<p class="page-subtitle">服务器连接、离线缓存与作业录入</p>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- 重看初次启动引导(首启时由 App.vue 自动弹出过一次) -->
|
<!-- 重看初次启动引导(首启时由 App.vue 自动弹出过一次) -->
|
||||||
<el-button @click="onboarding.open()">
|
<el-button @click="onboarding.open()">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { onBeforeRouteLeave, useRouter } from 'vue-router';
|
|||||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
import {
|
import {
|
||||||
CLASSISLAND_ISLAND_METRICS as METRICS,
|
CLASSISLAND_ISLAND_METRICS as METRICS,
|
||||||
|
CLASSISLAND_TOKENS,
|
||||||
DEFAULT_ISLAND_APPEARANCE,
|
DEFAULT_ISLAND_APPEARANCE,
|
||||||
ISLAND_COMPONENT_LABELS,
|
ISLAND_COMPONENT_LABELS,
|
||||||
defaultIslandLayouts,
|
defaultIslandLayouts,
|
||||||
@@ -37,7 +38,6 @@ const selectedId = ref(''),
|
|||||||
rowId = ref(''),
|
rowId = ref(''),
|
||||||
inspectorOpen = ref(false),
|
inspectorOpen = ref(false),
|
||||||
editMode = ref(false),
|
editMode = ref(false),
|
||||||
showTip = ref(true),
|
|
||||||
zoom = ref(1),
|
zoom = ref(1),
|
||||||
importInput = ref<HTMLInputElement>();
|
importInput = ref<HTMLInputElement>();
|
||||||
const scheme = computed(() =>
|
const scheme = computed(() =>
|
||||||
@@ -45,6 +45,63 @@ const scheme = computed(() =>
|
|||||||
);
|
);
|
||||||
const rows = computed(() => (surface.value === 'expanded' ? scheme.value.expandedRows : scheme.value.rows));
|
const rows = computed(() => (surface.value === 'expanded' ? scheme.value.expandedRows : scheme.value.rows));
|
||||||
const activeRow = computed(() => rows.value.find((row) => row.id === rowId.value) ?? rows.value[0]!);
|
const activeRow = computed(() => rows.value.find((row) => row.id === rowId.value) ?? rows.value[0]!);
|
||||||
|
const fontFields = [
|
||||||
|
{ key: 'secondaryFontSize', label: '辅助文字' },
|
||||||
|
{ key: 'bodyFontSize', label: '正文' },
|
||||||
|
{ key: 'emphasizedFontSize', label: '强调文字' },
|
||||||
|
{ key: 'largeFontSize', label: '大号文字' },
|
||||||
|
] as const;
|
||||||
|
const fontWeights = [
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.thin, label: '100 Thin' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.extraLight, label: '200 ExtraLight' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.light, label: '300 Light' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.normal, label: '400 Normal' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.medium, label: '500 Medium(默认)' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.semiBold, label: '600 SemiBold' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.bold, label: '700 Bold' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.extraBold, label: '800 ExtraBold' },
|
||||||
|
{ value: CLASSISLAND_TOKENS.fontWeights.black, label: '900 Black' },
|
||||||
|
] as const;
|
||||||
|
function rowStyle(row: IslandLayoutRow): Record<string, string> {
|
||||||
|
const style: Record<string, string> = {
|
||||||
|
'--row-gap': `${row.gap}px`,
|
||||||
|
opacity: String(row.opacity),
|
||||||
|
};
|
||||||
|
if (row.fontOverridesEnabled) {
|
||||||
|
style['--ci-fs-secondary'] = `${row.secondaryFontSize}px`;
|
||||||
|
style['--ci-fs-body'] = `${row.bodyFontSize}px`;
|
||||||
|
style['--ci-fs-emphasized'] = `${row.emphasizedFontSize}px`;
|
||||||
|
style['--ci-fs-large'] = `${row.largeFontSize}px`;
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
function previewStyle(): Record<string, string> {
|
||||||
|
const foreground: Record<string, string> = scheme.value.customForegroundEnabled
|
||||||
|
? {
|
||||||
|
'--ci-text-1': scheme.value.foreground,
|
||||||
|
'--ci-text-2': `color-mix(in srgb, ${scheme.value.foreground} 85.5%, transparent)`,
|
||||||
|
'--ci-text-3': `color-mix(in srgb, ${scheme.value.foreground} 77.3%, transparent)`,
|
||||||
|
'--ci-text-4': `color-mix(in srgb, ${scheme.value.foreground} 52.9%, transparent)`,
|
||||||
|
'--ci-text-5': `color-mix(in srgb, ${scheme.value.foreground} 36.5%, transparent)`,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
return {
|
||||||
|
zoom: String(scheme.value.scale * zoom.value),
|
||||||
|
'--preview-gap': `${scheme.value.spacing}px`,
|
||||||
|
'--preview-radius': `${scheme.value.radius}px`,
|
||||||
|
'--preview-background': scheme.value.customBackgroundEnabled
|
||||||
|
? `color-mix(in srgb, ${scheme.value.color} ${scheme.value.opacity * 100}%, transparent)`
|
||||||
|
: 'var(--ci-bg-secondary)',
|
||||||
|
'--ci-fs-secondary': `${scheme.value.secondaryFontSize}px`,
|
||||||
|
'--ci-fs-body': `${scheme.value.bodyFontSize}px`,
|
||||||
|
'--ci-fs-emphasized': `${scheme.value.emphasizedFontSize}px`,
|
||||||
|
'--ci-fs-large': `${scheme.value.largeFontSize}px`,
|
||||||
|
'--ci-font-weight': String(scheme.value.fontWeight),
|
||||||
|
'--ci-accent': appearance.value.resolvedAccent ?? appearance.value.accent,
|
||||||
|
fontSize: `${scheme.value.bodyFontSize}px`,
|
||||||
|
...foreground,
|
||||||
|
};
|
||||||
|
}
|
||||||
const state: IslandState = {
|
const state: IslandState = {
|
||||||
mode: 'hidden',
|
mode: 'hidden',
|
||||||
active: null,
|
active: null,
|
||||||
@@ -69,11 +126,6 @@ const library: { kind: IslandComponentKind; description: string }[] = [
|
|||||||
{ kind: 'group', description: '将多个组件组合到一个组件中显示。' },
|
{ kind: 'group', description: '将多个组件组合到一个组件中显示。' },
|
||||||
{ kind: 'stack', description: '将多个容器堆叠显示。' },
|
{ kind: 'stack', description: '将多个容器堆叠显示。' },
|
||||||
];
|
];
|
||||||
const messageLibrary: { kind: IslandComponentKind; description: string }[] = [
|
|
||||||
{ kind: 'notification', description: '显示班级收到的通知。' },
|
|
||||||
{ kind: 'homework', description: '显示班级作业提醒。' },
|
|
||||||
{ kind: 'call', description: '显示教师的叫人提醒。' },
|
|
||||||
];
|
|
||||||
const containers: readonly string[] = ['group', 'stack', 'slide', 'rolling'];
|
const containers: readonly string[] = ['group', 'stack', 'slide', 'rolling'];
|
||||||
function id() {
|
function id() {
|
||||||
return crypto.randomUUID();
|
return crypto.randomUUID();
|
||||||
@@ -156,6 +208,12 @@ function addRow() {
|
|||||||
main: false,
|
main: false,
|
||||||
allowNotifications: true,
|
allowNotifications: true,
|
||||||
gap: 8,
|
gap: 8,
|
||||||
|
opacity: CLASSISLAND_TOKENS.opacity.line,
|
||||||
|
fontOverridesEnabled: false,
|
||||||
|
secondaryFontSize: CLASSISLAND_TOKENS.fontSizes.secondary,
|
||||||
|
bodyFontSize: CLASSISLAND_TOKENS.fontSizes.body,
|
||||||
|
emphasizedFontSize: CLASSISLAND_TOKENS.fontSizes.emphasized,
|
||||||
|
largeFontSize: CLASSISLAND_TOKENS.fontSizes.large,
|
||||||
nodes: [],
|
nodes: [],
|
||||||
};
|
};
|
||||||
rows.value.push(row);
|
rows.value.push(row);
|
||||||
@@ -699,27 +757,14 @@ function dropPreview(event: PointerEvent) {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-else class="island-preview" :class="{ separated: scheme.separated }" :style="previewStyle()">
|
||||||
v-else
|
|
||||||
class="island-preview"
|
|
||||||
:class="{ separated: scheme.separated }"
|
|
||||||
:style="{
|
|
||||||
zoom: scheme.scale * zoom,
|
|
||||||
'--preview-gap': `${scheme.spacing}px`,
|
|
||||||
'--preview-radius': `${scheme.radius}px`,
|
|
||||||
'--secondary': `${(appearance.fontSize / 13) * 14}px`,
|
|
||||||
'--emphasized': `${(appearance.fontSize / 13) * 18}px`,
|
|
||||||
'--large': `${(appearance.fontSize / 13) * 20}px`,
|
|
||||||
fontSize: `${(appearance.fontSize / 13) * 16}px`,
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<section
|
<section
|
||||||
v-for="row in rows"
|
v-for="row in rows"
|
||||||
:key="row.id"
|
:key="row.id"
|
||||||
class="preview-row"
|
class="preview-row"
|
||||||
:class="{ 'drop-row': drop?.row.id === row.id && !drop.node }"
|
:class="{ 'drop-row': drop?.row.id === row.id && !drop.node }"
|
||||||
:data-row="row.id"
|
:data-row="row.id"
|
||||||
:style="{ gap: `${row.gap}px` }"
|
:style="rowStyle(row)"
|
||||||
@click.self="selectRow(row.id)"
|
@click.self="selectRow(row.id)"
|
||||||
>
|
>
|
||||||
<ComponentNode
|
<ComponentNode
|
||||||
@@ -773,34 +818,7 @@ function dropPreview(event: PointerEvent) {
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="message-library-title">班级消息</h4>
|
|
||||||
<div class="component-options message-options">
|
|
||||||
<button
|
|
||||||
v-for="item in messageLibrary"
|
|
||||||
:key="item.kind"
|
|
||||||
class="library-item"
|
|
||||||
:data-library-kind="item.kind"
|
|
||||||
:aria-label="`添加${ISLAND_COMPONENT_LABELS[item.kind]}`"
|
|
||||||
@pointerdown="beginDrag($event, { kind: item.kind, label: ISLAND_COMPONENT_LABELS[item.kind] })"
|
|
||||||
@click="add(item.kind)"
|
|
||||||
>
|
|
||||||
<ComponentIcon :kind="item.kind" />
|
|
||||||
<span>
|
|
||||||
<strong>{{ ISLAND_COMPONENT_LABELS[item.kind] }}</strong>
|
|
||||||
<span class="component-description">{{ item.description }}</span>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
<div v-if="showTip" class="editor-tip" role="note">
|
|
||||||
<el-icon class="tip-icon"><InfoFilled /></el-icon>
|
|
||||||
<span>
|
|
||||||
<strong>编辑提示:</strong>
|
|
||||||
现在可以使用「编辑模式」更加直观地编辑主界面上的组件!
|
|
||||||
</span>
|
|
||||||
<el-button @click="editMode = !editMode">{{ editMode ? '退出编辑模式' : '进入编辑模式' }}</el-button>
|
|
||||||
<button class="dismiss-tip" aria-label="关闭编辑提示" @click="showTip = false">×</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<el-skeleton v-else :rows="8" animated />
|
<el-skeleton v-else :rows="8" animated />
|
||||||
<input ref="importInput" type="file" accept="application/json,.json" hidden @change="importScheme" />
|
<input ref="importInput" type="file" accept="application/json,.json" hidden @change="importScheme" />
|
||||||
@@ -847,6 +865,30 @@ function dropPreview(event: PointerEvent) {
|
|||||||
<el-form-item label="组件间距">
|
<el-form-item label="组件间距">
|
||||||
<el-input-number v-model="activeRow.gap" :min="0" :max="64" @change="save" />
|
<el-input-number v-model="activeRow.gap" :min="0" :max="64" @change="save" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="整行透明度">
|
||||||
|
<el-slider
|
||||||
|
v-model="activeRow.opacity"
|
||||||
|
:min="0"
|
||||||
|
:max="1"
|
||||||
|
:step="0.05"
|
||||||
|
:format-tooltip="(value: number) => value.toFixed(2)"
|
||||||
|
@change="save"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="行级字号覆盖">
|
||||||
|
<el-switch v-model="activeRow.fontOverridesEnabled" @change="save" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-for="field in fontFields" :key="field.key" :label="`${field.label}字号(px)`">
|
||||||
|
<el-input-number
|
||||||
|
v-model="activeRow[field.key]"
|
||||||
|
:disabled="!activeRow.fontOverridesEnabled"
|
||||||
|
:min="CLASSISLAND_TOKENS.fontSizes.inputMin"
|
||||||
|
:max="CLASSISLAND_TOKENS.fontSizes.inputMax"
|
||||||
|
:step="CLASSISLAND_TOKENS.fontSizes.inputStep"
|
||||||
|
@change="save"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<p class="hint">行级字号只写到当前行根元素;关闭覆盖后回落到方案字号。</p>
|
||||||
<el-form-item label="允许显示提醒">
|
<el-form-item label="允许显示提醒">
|
||||||
<el-switch v-model="activeRow.allowNotifications" @change="save" />
|
<el-switch v-model="activeRow.allowNotifications" @change="save" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -872,20 +914,81 @@ function dropPreview(event: PointerEvent) {
|
|||||||
v-model="scheme.scale"
|
v-model="scheme.scale"
|
||||||
:min="METRICS.scaleMin"
|
:min="METRICS.scaleMin"
|
||||||
:max="METRICS.scaleMax"
|
:max="METRICS.scaleMax"
|
||||||
:step="0.05"
|
:step="CLASSISLAND_TOKENS.dpi.scaleStep"
|
||||||
@change="save"
|
@change="save"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="字体字重">
|
||||||
|
<el-select v-model="scheme.fontWeight" @change="save">
|
||||||
|
<el-option
|
||||||
|
v-for="weight in fontWeights"
|
||||||
|
:key="weight.value"
|
||||||
|
:label="weight.label"
|
||||||
|
:value="weight.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-for="field in fontFields" :key="field.key" :label="`${field.label}字号(px)`">
|
||||||
|
<el-input-number
|
||||||
|
v-model="scheme[field.key]"
|
||||||
|
:min="CLASSISLAND_TOKENS.fontSizes.inputMin"
|
||||||
|
:max="CLASSISLAND_TOKENS.fontSizes.inputMax"
|
||||||
|
:step="CLASSISLAND_TOKENS.fontSizes.inputStep"
|
||||||
|
@change="save"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="font-preview" aria-label="四档字号预览">
|
||||||
|
<span class="l1" :style="{ fontSize: `${scheme.secondaryFontSize}px` }">辅助文字</span>
|
||||||
|
<span class="l2" :style="{ fontSize: `${scheme.bodyFontSize}px` }">正文示例</span>
|
||||||
|
<span
|
||||||
|
class="l1"
|
||||||
|
:style="{ fontSize: `${scheme.emphasizedFontSize}px`, fontWeight: scheme.fontWeight }"
|
||||||
|
>
|
||||||
|
强调文字
|
||||||
|
</span>
|
||||||
|
<span class="l1" :style="{ fontSize: `${scheme.largeFontSize}px`, fontWeight: scheme.fontWeight }">
|
||||||
|
大号标题
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<el-form-item label="行间距">
|
<el-form-item label="行间距">
|
||||||
<el-slider v-model="scheme.spacing" :min="0" :max="METRICS.rowSpacingMax" @change="save" />
|
<el-slider v-model="scheme.spacing" :min="0" :max="METRICS.rowSpacingMax" @change="save" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="常态圆角">
|
<el-form-item label="常态圆角">
|
||||||
<el-slider v-model="scheme.radius" :min="0" :max="METRICS.radiusMax" @change="save" />
|
<el-slider
|
||||||
|
v-model="scheme.radius"
|
||||||
|
:min="0"
|
||||||
|
:max="METRICS.radiusMax"
|
||||||
|
:step="CLASSISLAND_TOKENS.radii.islandStep"
|
||||||
|
@change="save"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="自定义背景色">
|
||||||
|
<el-switch v-model="scheme.customBackgroundEnabled" @change="save" />
|
||||||
|
<el-color-picker v-if="scheme.customBackgroundEnabled" v-model="scheme.color" @change="save" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="背景不透明度">
|
||||||
|
<el-slider
|
||||||
|
v-model="scheme.opacity"
|
||||||
|
:min="0"
|
||||||
|
:max="1"
|
||||||
|
:step="0.05"
|
||||||
|
:show-tooltip="true"
|
||||||
|
:format-tooltip="(value: number) => value.toFixed(2)"
|
||||||
|
@change="save"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="自定义前景色">
|
||||||
|
<el-switch v-model="scheme.customForegroundEnabled" @change="save" />
|
||||||
|
<el-color-picker v-if="scheme.customForegroundEnabled" v-model="scheme.foreground" @change="save" />
|
||||||
|
</el-form-item>
|
||||||
|
<p class="hint">
|
||||||
|
关闭自定义前景色后回落当前亮/暗主题的五级文字色;开启后按 100% / 85.5% / 77.3% / 52.9% / 36.5%
|
||||||
|
生成颜色 alpha。
|
||||||
|
</p>
|
||||||
<el-form-item label="各行分离显示">
|
<el-form-item label="各行分离显示">
|
||||||
<el-switch v-model="scheme.separated" @change="save" />
|
<el-switch v-model="scheme.separated" @change="save" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<p class="hint">字体、透明度、位置和动画与灵动岛共用设置。</p>
|
<p class="hint">位置与动画与灵动岛共用设置。</p>
|
||||||
<el-button link type="primary" @click="router.push('/settings/island')">前往灵动岛外观设置</el-button>
|
<el-button link type="primary" @click="router.push('/settings/island')">前往灵动岛外观设置</el-button>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import {
|
import {
|
||||||
|
CLASSISLAND_TOKENS,
|
||||||
DEFAULT_ISLAND_APPEARANCE,
|
DEFAULT_ISLAND_APPEARANCE,
|
||||||
|
defaultIslandLayouts,
|
||||||
ISLAND_APPEARANCE_RANGES as RANGES,
|
ISLAND_APPEARANCE_RANGES as RANGES,
|
||||||
|
ISLAND_ACCENT_SOURCES,
|
||||||
ISLAND_POSITION_LABELS,
|
ISLAND_POSITION_LABELS,
|
||||||
ISLAND_POSITIONS,
|
ISLAND_POSITIONS,
|
||||||
ISLAND_STYLE_LABELS,
|
ISLAND_STYLE_LABELS,
|
||||||
ISLAND_STYLES,
|
ISLAND_STYLES,
|
||||||
type IslandAppearance,
|
type IslandAppearance,
|
||||||
|
type IslandAccentColorSource,
|
||||||
type IslandPosition,
|
type IslandPosition,
|
||||||
type IslandStyle,
|
type IslandStyle,
|
||||||
} from '@classhelper/shared';
|
} from '@classhelper/shared';
|
||||||
@@ -30,6 +34,13 @@ function editLayout() {
|
|||||||
void router.push('/settings/island/editor');
|
void router.push('/settings/island/editor');
|
||||||
}
|
}
|
||||||
const layoutMode = ref<'fixed' | 'custom'>('fixed');
|
const layoutMode = ref<'fixed' | 'custom'>('fixed');
|
||||||
|
const layoutSettings = ref(defaultIslandLayouts());
|
||||||
|
const activeScheme = computed(() =>
|
||||||
|
layoutSettings.value.schemes.find((s) => s.id === layoutSettings.value.activeSchemeId)!,
|
||||||
|
);
|
||||||
|
const currentRadius = computed(() =>
|
||||||
|
layoutMode.value === 'custom' ? activeScheme.value.radius : island.value.radius,
|
||||||
|
);
|
||||||
const residentEnabled = ref(false);
|
const residentEnabled = ref(false);
|
||||||
const pointerFadeEnabled = ref(true);
|
const pointerFadeEnabled = ref(true);
|
||||||
const pointerFadeReversed = ref(false);
|
const pointerFadeReversed = ref(false);
|
||||||
@@ -65,6 +76,7 @@ async function changePointerFade(
|
|||||||
}
|
}
|
||||||
async function loadLayout() {
|
async function loadLayout() {
|
||||||
const settings = (await window.desktop?.getConfig())?.islandLayout;
|
const settings = (await window.desktop?.getConfig())?.islandLayout;
|
||||||
|
if (settings) layoutSettings.value = settings;
|
||||||
layoutMode.value = settings?.layout ?? 'fixed';
|
layoutMode.value = settings?.layout ?? 'fixed';
|
||||||
residentEnabled.value = settings?.residentEnabled ?? false;
|
residentEnabled.value = settings?.residentEnabled ?? false;
|
||||||
pointerFadeEnabled.value = settings?.pointerFadeEnabled ?? true;
|
pointerFadeEnabled.value = settings?.pointerFadeEnabled ?? true;
|
||||||
@@ -103,9 +115,22 @@ async function loadIslandAppearance(): Promise<void> {
|
|||||||
/** 改动即生效:属性变化时先应用(实时预览),点"保存"再落盘 */
|
/** 改动即生效:属性变化时先应用(实时预览),点"保存"再落盘 */
|
||||||
function applyIslandAppearance(patch: Partial<IslandAppearance> = {}): void {
|
function applyIslandAppearance(patch: Partial<IslandAppearance> = {}): void {
|
||||||
island.value = { ...island.value, ...patch };
|
island.value = { ...island.value, ...patch };
|
||||||
|
if (layoutMode.value === 'custom' && patch.radius !== undefined) {
|
||||||
|
activeScheme.value.radius = patch.radius;
|
||||||
|
void window.desktop
|
||||||
|
?.saveConfig({ islandLayout: JSON.parse(JSON.stringify(layoutSettings.value)) })
|
||||||
|
.catch(() => ElMessage.error('圆角保存失败,请重试'));
|
||||||
|
}
|
||||||
window.desktop?.islandSetAppearance({ ...island.value });
|
window.desktop?.islandSetAppearance({ ...island.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setAccentPaletteColor(value: string | null): void {
|
||||||
|
if (!value) return;
|
||||||
|
const palette = [...island.value.accentPalette];
|
||||||
|
palette[island.value.accentPaletteIndex] = value;
|
||||||
|
applyIslandAppearance({ accentPalette: palette });
|
||||||
|
}
|
||||||
|
|
||||||
async function saveIslandAppearance(): Promise<void> {
|
async function saveIslandAppearance(): Promise<void> {
|
||||||
if (!window.desktop?.saveConfig) return;
|
if (!window.desktop?.saveConfig) return;
|
||||||
savingIsland.value = true;
|
savingIsland.value = true;
|
||||||
@@ -149,7 +174,6 @@ onMounted(async () => {
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">灵动岛</h2>
|
<h2 class="page-title">灵动岛</h2>
|
||||||
<p class="page-subtitle">自定义组件与 ClassIsland 提醒,共用停靠位置、动画开关与通知规则</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -231,9 +255,9 @@ onMounted(async () => {
|
|||||||
@input="(value: number) => applyIslandAppearance({ width: value })"
|
@input="(value: number) => applyIslandAppearance({ width: value })"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="`圆角 ${island.radius}px`">
|
<el-form-item :label="`圆角 ${currentRadius}px`">
|
||||||
<el-slider
|
<el-slider
|
||||||
:model-value="island.radius"
|
:model-value="currentRadius"
|
||||||
:min="RANGES.radius.min"
|
:min="RANGES.radius.min"
|
||||||
:max="RANGES.radius.max"
|
:max="RANGES.radius.max"
|
||||||
:step="1"
|
:step="1"
|
||||||
@@ -267,13 +291,49 @@ onMounted(async () => {
|
|||||||
@input="(value: number) => applyIslandAppearance({ speed: value })"
|
@input="(value: number) => applyIslandAppearance({ speed: value })"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="主题色">
|
<el-form-item label="强调色来源">
|
||||||
|
<el-select
|
||||||
|
:model-value="island.accentSource"
|
||||||
|
style="width: 180px"
|
||||||
|
@change="(value: IslandAccentColorSource) => applyIslandAppearance({ accentSource: value })"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in ISLAND_ACCENT_SOURCES"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<span class="text-muted ml-8">自定义 / 壁纸 / 跟随系统 / 屏幕主题色,未知来源回落 DodgerBlue</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="island.accentSource === 0" label="主题色">
|
||||||
<el-color-picker
|
<el-color-picker
|
||||||
:model-value="island.accent"
|
:model-value="island.accent"
|
||||||
@change="(value: string | null) => applyIslandAppearance({ accent: value ?? '#0a84ff' })"
|
@change="
|
||||||
|
(value: string | null) =>
|
||||||
|
applyIslandAppearance({ accent: value ?? CLASSISLAND_TOKENS.colors.light.primaryColor })
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<span class="text-muted ml-8">用于高亮、按钮与进度条</span>
|
<span class="text-muted ml-8">用于高亮、按钮与进度条</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item v-else-if="island.accentSource === 1 || island.accentSource === 3" label="调色板颜色">
|
||||||
|
<el-color-picker
|
||||||
|
:model-value="island.accentPalette[island.accentPaletteIndex]"
|
||||||
|
@change="setAccentPaletteColor"
|
||||||
|
/>
|
||||||
|
<el-input-number
|
||||||
|
:model-value="island.accentPaletteIndex"
|
||||||
|
:min="0"
|
||||||
|
:max="Math.max(0, island.accentPalette.length - 1)"
|
||||||
|
@change="
|
||||||
|
(value: number | undefined) => applyIslandAppearance({ accentPaletteIndex: Number(value ?? 0) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<span class="text-muted ml-8">按 SelectedPlatteIndex 取当前候选颜色</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-else label="主题色">
|
||||||
|
<span class="text-muted">跟随操作系统强调色;不可用时回落 DodgerBlue</span>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="视觉风格">
|
<el-form-item label="视觉风格">
|
||||||
<span v-if="layoutMode === 'custom'">ClassIsland · 半透明横条</span>
|
<span v-if="layoutMode === 'custom'">ClassIsland · 半透明横条</span>
|
||||||
<el-select
|
<el-select
|
||||||
|
|||||||
@@ -49,14 +49,13 @@ onMounted(loadGradeQuery);
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">提醒</h2>
|
<h2 class="page-title">提醒</h2>
|
||||||
<p class="page-subtitle">通知提醒与成绩查询状态</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-card shadow="never" class="lesson-channel-settings">
|
<el-card shadow="never" class="lesson-channel-settings">
|
||||||
<template #header>上下课提醒</template>
|
<template #header>上下课提醒</template>
|
||||||
<p class="text-muted">
|
<p class="text-muted">
|
||||||
沿用 ClassIsland 的遮罩、课前倒计时、上下课提示及下节课预告;课中显示课程进度,临近下课显示倒数。
|
课前倒计时、上下课提示及下节课预告保留遮罩;课中显示课程进度,临近下课在课程名右侧显示蓝色圆形秒数倒计时。
|
||||||
</p>
|
</p>
|
||||||
<div
|
<div
|
||||||
v-for="channel in [
|
v-for="channel in [
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type {
|
|||||||
* 主进程与渲染进程之间的桥接契约(preload 通过 contextBridge 暴露)。
|
* 主进程与渲染进程之间的桥接契约(preload 通过 contextBridge 暴露)。
|
||||||
* 渲染进程只依赖这些最小 API,不接触 Node.js。
|
* 渲染进程只依赖这些最小 API,不接触 Node.js。
|
||||||
*/
|
*/
|
||||||
import type { IslandAppearance, IslandNotification, IslandState, UpdateInfo } from '@classhelper/shared';
|
import type { IslandAppearance, IslandNotification, IslandState } from '@classhelper/shared';
|
||||||
import type { ClientAgentStatus } from '../main/client-agent.js';
|
import type { ClientAgentStatus } from '../main/client-agent.js';
|
||||||
import type { IslandBridge } from '../preload/island.js';
|
import type { IslandBridge } from '../preload/island.js';
|
||||||
|
|
||||||
@@ -48,23 +48,14 @@ export interface DesktopStoredConfig {
|
|||||||
* 录入作业时点一下就追加到标题/内容里,少打字(例如 P、大本、背诵)。
|
* 录入作业时点一下就追加到标题/内容里,少打字(例如 P、大本、背诵)。
|
||||||
*/
|
*/
|
||||||
homeworkPhrases: string[];
|
homeworkPhrases: string[];
|
||||||
/**
|
/** 兼容旧配置;新版引导是否展示由 onboardingVersion 决定。 */
|
||||||
* 是否已看过「初次启动引导」。
|
|
||||||
*
|
|
||||||
* 首次启动自动弹出一次(完成或跳过即记为看过并写入配置,之后不再自动弹出);
|
|
||||||
* 登录页与设置页的「使用引导」入口可随时重看(重看不改变该值)。
|
|
||||||
*/
|
|
||||||
onboardingDone: boolean;
|
onboardingDone: boolean;
|
||||||
|
onboardingVersion: number;
|
||||||
/** 界面主题:light=浅色(默认)/ dark=深色(黑夜模式) */
|
/** 界面主题:light=浅色(默认)/ dark=深色(黑夜模式) */
|
||||||
theme: 'light' | 'dark';
|
theme: 'light' | 'dark';
|
||||||
/** 主侧边栏是否折叠成图标栏(可由顶栏汉堡按钮切换) */
|
/** 主侧边栏是否折叠成图标栏(可由顶栏汉堡按钮切换) */
|
||||||
sidebarCollapsed: boolean;
|
sidebarCollapsed: boolean;
|
||||||
/**
|
/** 旧版主动更新检查的兼容字段,不再影响云端下发更新。 */
|
||||||
* 用户点过「忽略此版本」的版本号(空串 = 没忽略过)。
|
|
||||||
*
|
|
||||||
* 启动时的自动检查会跳过这个版本,避免每次开客户端都弹一次同样的提示;
|
|
||||||
* 在「关于」页手动检查时仍会正常显示结果。
|
|
||||||
*/
|
|
||||||
ignoredUpdateVersion: string;
|
ignoredUpdateVersion: string;
|
||||||
/**
|
/**
|
||||||
* 本机设备标识(UUID):这台机器在服务端的身份。
|
* 本机设备标识(UUID):这台机器在服务端的身份。
|
||||||
@@ -163,21 +154,6 @@ export interface DesktopBridge {
|
|||||||
getAppInfo(): Promise<DesktopAppInfo>;
|
getAppInfo(): Promise<DesktopAppInfo>;
|
||||||
openExternal(url: string): Promise<boolean>;
|
openExternal(url: string): Promise<boolean>;
|
||||||
|
|
||||||
/* 更新检查 */
|
|
||||||
/**
|
|
||||||
* 检查 GitHub 上有没有新版本(主进程直连,不经后端)。
|
|
||||||
*
|
|
||||||
* @param force true = 绕过主进程缓存(对应「关于」页里用户主动点的那次检查)
|
|
||||||
*
|
|
||||||
* 返回的 `ok:false` 是**正常结果**(教室机器没有外网 / GitHub 限流 / 超时),不是异常,
|
|
||||||
* 界面按"暂时查不到更新"呈现即可。
|
|
||||||
*/
|
|
||||||
checkForUpdates(force?: boolean): Promise<UpdateInfo>;
|
|
||||||
/** 忽略某个版本的更新提示(写入 config.json,启动自动检查不再提示它) */
|
|
||||||
ignoreUpdateVersion(version: string): Promise<void>;
|
|
||||||
/** 订阅"启动自动检查发现新版本"(仅新版本且未被忽略时触发一次) */
|
|
||||||
onUpdateAvailable(handler: (info: UpdateInfo) => void): void;
|
|
||||||
|
|
||||||
/* 灵动岛 */
|
/* 灵动岛 */
|
||||||
getIslandWeather(coordinates: { latitude: number; longitude: number }): Promise<IslandWeather>;
|
getIslandWeather(coordinates: { latitude: number; longitude: number }): Promise<IslandWeather>;
|
||||||
/** 把一条通知投递到灵动岛(payload 必须是纯数据,说明见 saveConfig) */
|
/** 把一条通知投递到灵动岛(payload 必须是纯数据,说明见 saveConfig) */
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@classhelper/server",
|
"name": "@classhelper/server",
|
||||||
"version": "1.4.3",
|
"version": "1.4.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "ClassHelper后端服务:REST API + Socket.IO 实时推送 + Prisma 数据访问",
|
"description": "ClassHelper后端服务:REST API + Socket.IO 实时推送 + Prisma 数据访问",
|
||||||
|
"//": "yaml:课表 YAML 导入的解析器(yaml@2,自带类型、无子依赖);仓库只有传递依赖 js-yaml,不要直接引用",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
"socket.io": "^4.8.3",
|
"socket.io": "^4.8.3",
|
||||||
"typescript": "~5.9.3",
|
"typescript": "~5.9.3",
|
||||||
"xlsx": "0.18.5",
|
"xlsx": "0.18.5",
|
||||||
|
"yaml": "^2.9.1",
|
||||||
"zod": "^4.6.2"
|
"zod": "^4.6.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE "AiPlanStep" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"auditId" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"ordinal" INTEGER NOT NULL,
|
||||||
|
"payload" TEXT NOT NULL,
|
||||||
|
"state" TEXT NOT NULL DEFAULT 'draft',
|
||||||
|
"result" TEXT NOT NULL DEFAULT '',
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX "AiPlanStep_auditId_ordinal_key" ON "AiPlanStep"("auditId", "ordinal");
|
||||||
|
CREATE INDEX "AiPlanStep_userId_createdAt_idx" ON "AiPlanStep"("userId", "createdAt");
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
CREATE TABLE "AiTask" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"state" TEXT NOT NULL DEFAULT 'preparing',
|
||||||
|
"input" TEXT NOT NULL,
|
||||||
|
"result" TEXT NOT NULL DEFAULT '',
|
||||||
|
"events" TEXT NOT NULL DEFAULT '',
|
||||||
|
"error" TEXT NOT NULL DEFAULT '',
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX "AiTask_userId_createdAt_idx" ON "AiTask"("userId", "createdAt");
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
ALTER TABLE "TimeLayout" ADD COLUMN "parentId" TEXT;
|
||||||
|
ALTER TABLE "TimeLayoutItem" ADD COLUMN "slotKey" TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE "TimeLayoutItem" ADD COLUMN "isAutoBreak" BOOLEAN NOT NULL DEFAULT false;
|
||||||
|
ALTER TABLE "AiTask" ADD COLUMN "conversationId" TEXT;
|
||||||
|
ALTER TABLE "AiTask" ADD COLUMN "turnNumber" INTEGER NOT NULL DEFAULT 1;
|
||||||
|
CREATE UNIQUE INDEX "AiTask_conversationId_turnNumber_key" ON "AiTask"("conversationId", "turnNumber");
|
||||||
|
CREATE TABLE "AiConversation" ("id" TEXT NOT NULL PRIMARY KEY, "userId" TEXT NOT NULL, "title" TEXT NOT NULL DEFAULT '', "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL);
|
||||||
|
CREATE INDEX "AiConversation_userId_updatedAt_idx" ON "AiConversation"("userId", "updatedAt");
|
||||||
@@ -401,6 +401,7 @@ model NotificationRead {
|
|||||||
|
|
||||||
/// 课表时间配置(ClassIsland 同款 JSON 导入后的节次时间表)
|
/// 课表时间配置(ClassIsland 同款 JSON 导入后的节次时间表)
|
||||||
model TimeLayout {
|
model TimeLayout {
|
||||||
|
parentId String?
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
classId String?
|
classId String?
|
||||||
name String
|
name String
|
||||||
@@ -648,6 +649,8 @@ model Exam {
|
|||||||
|
|
||||||
/// 服务端不用单机 Profile:全校共享时间表 + 班级日课表替代档案。
|
/// 服务端不用单机 Profile:全校共享时间表 + 班级日课表替代档案。
|
||||||
model TimeLayoutItem {
|
model TimeLayoutItem {
|
||||||
|
slotKey String @default("")
|
||||||
|
isAutoBreak Boolean @default(false)
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
timeLayoutId String
|
timeLayoutId String
|
||||||
position Int
|
position Int
|
||||||
@@ -813,3 +816,47 @@ model CoursewareReceipt {
|
|||||||
device ClientDevice @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
device ClientDevice @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
||||||
@@id([pushId, deviceId])
|
@@id([pushId, deviceId])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// AI 确认计划与执行去重;payload 加密保存,不保存明文凭据。
|
||||||
|
model AiPlanStep {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
auditId String
|
||||||
|
userId String
|
||||||
|
ordinal Int
|
||||||
|
payload String
|
||||||
|
state String @default("draft")
|
||||||
|
result String @default("")
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
@@unique([auditId, ordinal])
|
||||||
|
@@index([userId, createdAt])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 持久化后台任务;输入、结果和阶段消息加密,连接断开不取消任务。
|
||||||
|
model AiTask {
|
||||||
|
conversationId String?
|
||||||
|
turnNumber Int @default(1)
|
||||||
|
@@unique([conversationId, turnNumber])
|
||||||
|
id String @id @default(cuid())
|
||||||
|
userId String
|
||||||
|
state String @default("preparing")
|
||||||
|
input String
|
||||||
|
result String @default("")
|
||||||
|
events String @default("")
|
||||||
|
error String @default("")
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
@@index([userId, createdAt])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 账号所属对话;内容仍使用 AiTask 的加密输入与结果。
|
||||||
|
model AiConversation {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
userId String
|
||||||
|
title String @default("")
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
@@index([userId, updatedAt])
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
/** 由隔离 E2E 启动器调用,在独立临时班级验收 YAML 写入及权限。 */
|
||||||
|
export async function verifyClassPlanYamlApi({
|
||||||
|
api,
|
||||||
|
record,
|
||||||
|
adminToken,
|
||||||
|
teacherToken,
|
||||||
|
teacher2Token,
|
||||||
|
teacher1Id,
|
||||||
|
}) {
|
||||||
|
const created = await api('/classes', {
|
||||||
|
method: 'POST',
|
||||||
|
token: adminToken,
|
||||||
|
body: { grade: '高一', enrollmentYear: 2026, classIndex: 98, teacherId: teacher1Id },
|
||||||
|
});
|
||||||
|
const classId = created.payload?.data?.id;
|
||||||
|
record('YAML 验收使用独立临时班级', created.status === 201 && Boolean(classId));
|
||||||
|
if (!classId) return;
|
||||||
|
const text = readFileSync(new URL('../../../yml导入格式示例.yml', import.meta.url), 'utf8');
|
||||||
|
const call = (suffix, source = text, mode = 'merge', token = teacherToken) =>
|
||||||
|
api(`/imports/class-plan/yaml${suffix}`, {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: { classId, text: source, mode },
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const preview = await call('/preview');
|
||||||
|
const before = await api(`/class-plans?classId=${classId}`, { token: teacherToken });
|
||||||
|
record(
|
||||||
|
'YAML 示例预览:6 节、3 张课表、只读不写库',
|
||||||
|
preview.status === 200 &&
|
||||||
|
preview.payload?.data?.entries.length === 6 &&
|
||||||
|
preview.payload?.data?.planCount === 3 &&
|
||||||
|
preview.payload?.data?.errors.length === 0 &&
|
||||||
|
before.payload?.data?.length === 0,
|
||||||
|
);
|
||||||
|
const first = await call('');
|
||||||
|
const list = await api(`/class-plans?classId=${classId}`, { token: teacherToken });
|
||||||
|
const plans = list.payload?.data ?? [];
|
||||||
|
const ids = plans.map((plan) => plan.id).sort();
|
||||||
|
record(
|
||||||
|
'YAML 示例落库并保留单双周',
|
||||||
|
first.status === 200 &&
|
||||||
|
plans.length === 3 &&
|
||||||
|
plans.some((plan) => plan.weekCountDiv === 1 && plan.weekCountDivTotal === 2) &&
|
||||||
|
plans.some((plan) => plan.weekCountDiv === 2 && plan.weekCountDivTotal === 2),
|
||||||
|
);
|
||||||
|
const entries = plans.flatMap((plan) => plan.entries ?? []);
|
||||||
|
record(
|
||||||
|
'YAML 教室写入课次地点',
|
||||||
|
entries.length === 6 && entries.every((entry) => ['101', '102', '103', '104'].includes(entry.location)),
|
||||||
|
);
|
||||||
|
const courses = await api(`/courses?classId=${classId}`, { token: teacherToken });
|
||||||
|
record(
|
||||||
|
'YAML 简称落库且教师字段不改变任课授权',
|
||||||
|
courses.payload?.data?.length === 4 &&
|
||||||
|
courses.payload.data.every((course) => course.teacherId === teacher1Id && course.initial),
|
||||||
|
);
|
||||||
|
const again = await call('');
|
||||||
|
const merged = await api(`/class-plans?classId=${classId}`, { token: teacherToken });
|
||||||
|
record(
|
||||||
|
'YAML 重复合并更新原对象,不产生重复课表',
|
||||||
|
again.status === 200 &&
|
||||||
|
JSON.stringify(merged.payload?.data?.map((plan) => plan.id).sort()) === JSON.stringify(ids),
|
||||||
|
);
|
||||||
|
const rejected = await call('', 'version: 1\nschedules: broken', 'replace');
|
||||||
|
const after = await api(`/class-plans?classId=${classId}`, { token: teacherToken });
|
||||||
|
record(
|
||||||
|
'YAML 非法覆盖返回 400 且原课表保留',
|
||||||
|
rejected.status === 400 &&
|
||||||
|
JSON.stringify(after.payload?.data?.map((plan) => plan.id).sort()) === JSON.stringify(ids),
|
||||||
|
);
|
||||||
|
const denied = await call('', text, 'replace', teacher2Token);
|
||||||
|
record('YAML 导入拒绝跨班教师', denied.status === 403);
|
||||||
|
const tooLarge = await call('/preview', '#中文'.repeat(1_200_000));
|
||||||
|
record('YAML 按 UTF-8 字节限制 8 MB,超限返回 413', tooLarge.status === 413);
|
||||||
|
const replacement = await call('', text, 'replace');
|
||||||
|
const replaced = await api(`/class-plans?classId=${classId}`, { token: teacherToken });
|
||||||
|
record(
|
||||||
|
'YAML 覆盖导入成功且保留三张课表',
|
||||||
|
replacement.status === 200 && replaced.payload?.data?.length === 3,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
const removed = await api(`/classes/${classId}`, { method: 'DELETE', token: adminToken });
|
||||||
|
record('YAML 临时班级验收数据清理', removed.status === 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/** 纯解析回归,不访问业务库。用 node --import tsx scripts/verify-class-plan-yaml.ts 执行。 */
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { CLASS_PLAN_YAML_SAMPLE } from '@classhelper/shared';
|
||||||
|
import {
|
||||||
|
buildClassIslandProfile,
|
||||||
|
parseClassPlanYaml,
|
||||||
|
} from '../src/modules/imports/class-plan-yaml.service.js';
|
||||||
|
|
||||||
|
const example = readFileSync(new URL('../../../yml导入格式示例.yml', import.meta.url), 'utf8');
|
||||||
|
const parsed = parseClassPlanYaml(example);
|
||||||
|
assert.deepEqual(parsed.errors, []);
|
||||||
|
assert.equal(parsed.entries.length, 6);
|
||||||
|
assert.equal(parsed.planCount, 3);
|
||||||
|
assert.deepEqual(
|
||||||
|
parsed.entries.map((entry) => entry.weekParity),
|
||||||
|
['ALL', 'ALL', 'ODD', 'ODD', 'EVEN', 'EVEN'],
|
||||||
|
);
|
||||||
|
assert.equal(parsed.entries[0]?.startTime, '08:00');
|
||||||
|
assert.equal(parsed.entries[0]?.location, '101');
|
||||||
|
assert.equal(parsed.subjects[0]?.initial, '数');
|
||||||
|
const profile = buildClassIslandProfile(parsed, 30);
|
||||||
|
assert.equal(Object.keys(profile.ClassPlans as object).length, 3);
|
||||||
|
assert.equal(Object.keys(profile.TimeLayouts as object).length, 1);
|
||||||
|
console.log('[PASS] 用户示例:省略冒号、HHMMSS、简称、教室及单双周');
|
||||||
|
|
||||||
|
assert.deepEqual(parseClassPlanYaml(CLASS_PLAN_YAML_SAMPLE).errors, []);
|
||||||
|
const standard = `version: 1
|
||||||
|
subjects:
|
||||||
|
- name: 数学
|
||||||
|
schedules:
|
||||||
|
- name: 周日
|
||||||
|
enable_day: 7
|
||||||
|
weeks: all
|
||||||
|
classes:
|
||||||
|
- subject: 数学
|
||||||
|
start_time: 080000
|
||||||
|
end_time: '090000'
|
||||||
|
`;
|
||||||
|
assert.deepEqual(parseClassPlanYaml(standard).errors, []);
|
||||||
|
assert.equal(parseClassPlanYaml(standard).entries[0]?.dayOfWeek, 7);
|
||||||
|
assert.deepEqual(
|
||||||
|
parseClassPlanYaml(standard.replace('080000', "'08:00'").replace('090000', '09:00:00')).errors,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
console.log('[PASS] 标准 YAML:六位数字/字符串、冒号时间、周日映射');
|
||||||
|
|
||||||
|
for (const [name, invalid] of [
|
||||||
|
['空文件', ''],
|
||||||
|
['不支持的版本', standard.replace('version: 1', 'version: 2')],
|
||||||
|
['小数星期', standard.replace('enable_day: 7', 'enable_day: 1.5')],
|
||||||
|
['非法小时', standard.replace('080000', '250000')],
|
||||||
|
['非法分钟', standard.replace('080000', '086000')],
|
||||||
|
['非零秒', standard.replace('080000', '080001')],
|
||||||
|
['反向时间', standard.replace('090000', '070000')],
|
||||||
|
['未知单双周', standard.replace('weeks: all', 'weeks: unknown')],
|
||||||
|
['重复字段', standard.replace('version: 1', 'version: 1\nversion: 1')],
|
||||||
|
['同日相位冲突', standard + standard.slice(standard.indexOf(' - name: 周日'))],
|
||||||
|
] as const) {
|
||||||
|
assert.ok(parseClassPlanYaml(invalid).errors.length > 0, name);
|
||||||
|
}
|
||||||
|
console.log('[PASS] 错误输入被拒绝,避免部分导入或丢失时间精度');
|
||||||
@@ -437,11 +437,20 @@ try {
|
|||||||
coursewareCategory('a.7z') === 'archive',
|
coursewareCategory('a.7z') === 'archive',
|
||||||
);
|
);
|
||||||
await restoreSnapshot(prisma, 'sqlite', snapshot);
|
await restoreSnapshot(prisma, 'sqlite', snapshot);
|
||||||
|
const restoredFolders = await prisma.coursewareFolder.findMany();
|
||||||
check(
|
check(
|
||||||
'恢复数据库后保留课件共享和回执数据',
|
'恢复数据库后保留课件共享和回执数据',
|
||||||
(await prisma.courseware.count()) === 3 &&
|
(await prisma.courseware.count()) === 3 &&
|
||||||
(await prisma.coursewareReceipt.count()) === 1 &&
|
(await prisma.coursewareReceipt.count()) === 1 &&
|
||||||
(await prisma.coursewareFolder.count()) === 1,
|
restoredFolders.length === snapshot.data.CoursewareFolder.length &&
|
||||||
|
snapshot.data.CoursewareFolder.every((expected) =>
|
||||||
|
restoredFolders.some(
|
||||||
|
(actual) =>
|
||||||
|
actual.id === expected.id &&
|
||||||
|
actual.path === expected.path &&
|
||||||
|
actual.teacherId === expected.teacherId,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
console.log(`=== 课件隔离验收:${count}/${count} 项通过 ===`);
|
console.log(`=== 课件隔离验收:${count}/${count} 项通过 ===`);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { readFileSync } from 'node:fs';
|
|||||||
* VERIFY_BASE_URL 默认 http://127.0.0.1:4000
|
* VERIFY_BASE_URL 默认 http://127.0.0.1:4000
|
||||||
*/
|
*/
|
||||||
import { io } from 'socket.io-client';
|
import { io } from 'socket.io-client';
|
||||||
|
import { verifyClassPlanYamlApi } from './verify-class-plan-yaml-api.mjs';
|
||||||
|
|
||||||
const BASE_URL = process.env.VERIFY_BASE_URL ?? `http://127.0.0.1:${process.env.PORT ?? 4000}`;
|
const BASE_URL = process.env.VERIFY_BASE_URL ?? `http://127.0.0.1:${process.env.PORT ?? 4000}`;
|
||||||
const TIME_LIMIT_MS = 5000;
|
const TIME_LIMIT_MS = 5000;
|
||||||
@@ -442,6 +443,8 @@ async function main() {
|
|||||||
`删除课表 ${removedSchedules} 条、课程 ${removedImportedCourses} 门`,
|
`删除课表 ${removedSchedules} 条、课程 ${removedImportedCourses} 门`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await verifyClassPlanYamlApi({ api, record, adminToken, teacherToken, teacher2Token, teacher1Id });
|
||||||
|
|
||||||
// ---------------------------------------------------------------- 3. WebSocket 连接
|
// ---------------------------------------------------------------- 3. WebSocket 连接
|
||||||
const socket = io(BASE_URL, {
|
const socket = io(BASE_URL, {
|
||||||
auth: { token: studentToken, clientType: 'desktop' },
|
auth: { token: studentToken, clientType: 'desktop' },
|
||||||
@@ -2212,7 +2215,9 @@ async function main() {
|
|||||||
mergeImport.status === 200 &&
|
mergeImport.status === 200 &&
|
||||||
mergeData?.merged === 1 &&
|
mergeData?.merged === 1 &&
|
||||||
mergeData?.replaced === 1 &&
|
mergeData?.replaced === 1 &&
|
||||||
mergeData?.layout?.items?.length === 4,
|
mergeData?.layout?.items?.length === 5 &&
|
||||||
|
mergeData.layout.items.filter((item) => item.type === 'class').length === 3 &&
|
||||||
|
mergeData.layout.items.filter((item) => item.type === 'break').length === 2,
|
||||||
`合并=${mergeData?.merged} 新增=${mergeData?.replaced} 共=${mergeData?.layout?.items?.length}`,
|
`合并=${mergeData?.merged} 新增=${mergeData?.replaced} 共=${mergeData?.layout?.items?.length}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3218,7 +3223,8 @@ async function main() {
|
|||||||
// 教师名单表格导入:教师预览 403;管理员预览 + 提交(教师与班级无关,classId 可省略)
|
// 教师名单表格导入:教师预览 403;管理员预览 + 提交(教师与班级无关,classId 可省略)
|
||||||
const teacherCsv =
|
const teacherCsv =
|
||||||
'\ufeff工号,姓名,初始密码,角色\n' +
|
'\ufeff工号,姓名,初始密码,角色\n' +
|
||||||
`imp_t_${Date.now().toString().slice(-8)},冒烟导入教师,import123456,教师\n`;
|
`imp_t_${Date.now().toString().slice(-8)},冒烟导入教师,import123456,教师\n` +
|
||||||
|
`imp_t_${Date.now().toString().slice(-8)}_b,冒烟导入教师乙,import123456,教师\n`;
|
||||||
const teacherCsvBase64 = Buffer.from(teacherCsv, 'utf8').toString('base64');
|
const teacherCsvBase64 = Buffer.from(teacherCsv, 'utf8').toString('base64');
|
||||||
const importedTeacherUsername = teacherCsv.split('\n')[1]?.split(',')[0] ?? '';
|
const importedTeacherUsername = teacherCsv.split('\n')[1]?.split(',')[0] ?? '';
|
||||||
|
|
||||||
@@ -3245,7 +3251,10 @@ async function main() {
|
|||||||
});
|
});
|
||||||
const importedTeacherLogin = await api('/auth/login', {
|
const importedTeacherLogin = await api('/auth/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: { username: importedTeacherUsername, password: 'import123456' },
|
body: {
|
||||||
|
username: importedTeacherUsername,
|
||||||
|
password: adminTeacherCommit.payload?.data?.credentials?.[0]?.password ?? '',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
record(
|
record(
|
||||||
'教师名单表格导入(教师 403 / 管理员预览+导入成功,且导入账号可登录)',
|
'教师名单表格导入(教师 403 / 管理员预览+导入成功,且导入账号可登录)',
|
||||||
@@ -3253,13 +3262,47 @@ async function main() {
|
|||||||
adminTeacherPreview.status === 200 &&
|
adminTeacherPreview.status === 200 &&
|
||||||
Boolean(adminTeacherPreview.payload?.data?.suggestedMapping?.username) &&
|
Boolean(adminTeacherPreview.payload?.data?.suggestedMapping?.username) &&
|
||||||
adminTeacherCommit.status === 200 &&
|
adminTeacherCommit.status === 200 &&
|
||||||
adminTeacherCommit.payload?.data?.inserted === 1 &&
|
adminTeacherCommit.payload?.data?.inserted === 2 &&
|
||||||
|
adminTeacherCommit.payload?.data?.credentials?.[0]?.password !== 'import123456' &&
|
||||||
importedTeacherLogin.status === 200,
|
importedTeacherLogin.status === 200,
|
||||||
`教师预览=${teacherPreviewDenied.status} 管理员预览=${adminTeacherPreview.status} ` +
|
`教师预览=${teacherPreviewDenied.status} 管理员预览=${adminTeacherPreview.status} ` +
|
||||||
`建议映射=${JSON.stringify(adminTeacherPreview.payload?.data?.suggestedMapping ?? {})} ` +
|
`建议映射=${JSON.stringify(adminTeacherPreview.payload?.data?.suggestedMapping ?? {})} ` +
|
||||||
`导入新增=${adminTeacherCommit.payload?.data?.inserted ?? '-'} 登录=${importedTeacherLogin.status}`,
|
`导入新增=${adminTeacherCommit.payload?.data?.inserted ?? '-'} 登录=${importedTeacherLogin.status}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const importedCredentials = adminTeacherCommit.payload?.data?.credentials ?? [];
|
||||||
|
const repeatedImport = await api('/imports/table/commit', {
|
||||||
|
method: 'POST',
|
||||||
|
token: adminToken,
|
||||||
|
body: {
|
||||||
|
kind: 'teachers',
|
||||||
|
fileName: 'teachers.csv',
|
||||||
|
contentBase64: teacherCsvBase64,
|
||||||
|
mapping: { username: '工号', name: '姓名', role: '角色' },
|
||||||
|
mode: 'upsert',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const repeatLogin = await api('/auth/login', {
|
||||||
|
method: 'POST',
|
||||||
|
body: { username: importedTeacherUsername, password: importedCredentials[0]?.password ?? '' },
|
||||||
|
});
|
||||||
|
const importAudits = await api('/permissions/audit?pageSize=100', { token: adminToken });
|
||||||
|
const teacherImportAudits = (importAudits.payload?.data?.items ?? []).filter(
|
||||||
|
(item) => item.action === 'import-commitTeachers',
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
'教师导入逐人生成随机密码,重复导入不重置且审计不含凭据',
|
||||||
|
importedCredentials.length === 2 &&
|
||||||
|
new Set(importedCredentials.map((c) => c.password)).size === 2 &&
|
||||||
|
importedCredentials.every((c) => c.password.length >= 16 && c.password !== 'import123456') &&
|
||||||
|
repeatedImport.payload?.data?.updated === 2 &&
|
||||||
|
repeatedImport.payload?.data?.credentials?.length === 0 &&
|
||||||
|
repeatLogin.status === 200 &&
|
||||||
|
teacherImportAudits.length > 0 &&
|
||||||
|
teacherImportAudits.every((item) => !/password|credentials/.test(item.afterJson)),
|
||||||
|
`凭据=${importedCredentials.length} 重复更新=${repeatedImport.payload?.data?.updated ?? '-'} 登录=${repeatLogin.status}`,
|
||||||
|
);
|
||||||
|
|
||||||
// 删除护栏:还是班主任的账号不允许删除;没有班级职责的可以删
|
// 删除护栏:还是班主任的账号不允许删除;没有班级职责的可以删
|
||||||
const deleteHeadTeacher = teacher1
|
const deleteHeadTeacher = teacher1
|
||||||
? await api(`/teachers/${teacher1.id}`, { method: 'DELETE', token: adminToken })
|
? await api(`/teachers/${teacher1.id}`, { method: 'DELETE', token: adminToken })
|
||||||
@@ -3656,10 +3699,10 @@ async function main() {
|
|||||||
await api(`/classes/${probeClassId}`, { method: 'DELETE', token: adminToken });
|
await api(`/classes/${probeClassId}`, { method: 'DELETE', token: adminToken });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const importedTeacherRow = (await api('/teachers', { token: adminToken })).payload?.data?.find(
|
const importedTeacherRows = (await api('/teachers', { token: adminToken })).payload?.data?.filter((item) =>
|
||||||
(item) => item.username === importedTeacherUsername,
|
importedCredentials.some((credential) => credential.username === item.username),
|
||||||
);
|
);
|
||||||
if (importedTeacherRow) {
|
for (const importedTeacherRow of importedTeacherRows ?? []) {
|
||||||
await api(`/teachers/${importedTeacherRow.id}`, { method: 'DELETE', token: adminToken });
|
await api(`/teachers/${importedTeacherRow.id}`, { method: 'DELETE', token: adminToken });
|
||||||
}
|
}
|
||||||
const isProbeAccount = (username) =>
|
const isProbeAccount = (username) =>
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ export type ApiErrorCode =
|
|||||||
| 'AI_TIMEOUT'
|
| 'AI_TIMEOUT'
|
||||||
/** 大模型:返回的内容不是可用的结构化动作(已记日志,不把原始回复回传给前端) */
|
/** 大模型:返回的内容不是可用的结构化动作(已记日志,不把原始回复回传给前端) */
|
||||||
| 'AI_INVALID_OUTPUT'
|
| 'AI_INVALID_OUTPUT'
|
||||||
|
| 'AI_TASK_INCOMPLETE'
|
||||||
|
| 'AI_MODELS_UNAVAILABLE'
|
||||||
|
| 'AI_PROVIDER_ERROR'
|
||||||
|
| 'AI_READ_FAILED'
|
||||||
|
| 'AI_RESULT_UNCERTAIN'
|
||||||
| 'TOO_MANY_REQUESTS'
|
| 'TOO_MANY_REQUESTS'
|
||||||
/** 上课时间段发布紧急通知需要二次确认(前端据此弹出全屏警告 + 3 秒倒计时) */
|
/** 上课时间段发布紧急通知需要二次确认(前端据此弹出全屏警告 + 3 秒倒计时) */
|
||||||
| 'URGENT_DURING_CLASS'
|
| 'URGENT_DURING_CLASS'
|
||||||
|
|||||||