fix(island,homework,schedule,web): 16 项反馈修复(联合通知点不开 / 设置不生效 / 红点位置 / 看板当天且铺满 / 单双周与周数可调 / Web 手机端与批量通知等)

一、灵动岛
- ①「紧急通知后来了新作业,收起再点开不了新作业」根因有二,都已修:
  (a) active 仍是紧急那条,点击只会反复打开它 —— 现在点击胶囊优先打开**最新**那条未处理消息(队列里更晚的);
  (b) 上课时段 syncWindow 会把普通通知立刻隐藏(表现为点了没反应)—— 新增 explicitShowId,
      "用户主动点开"的那条守卫放行(岛完全隐藏时仍严格不打扰)。
  冒烟新增「紧急通知后来了新作业:收起再点击打开的是新作业(联合通知回归)」。
- ② 设置实时预览/保存:补「设置页真实链路」断言(window.desktop.islandSetAppearance → IPC → 主进程 →
  渲染进程 CSS 变量 + 窗口尺寸),并断言"岛显示中改尺寸立即生效"(实测均通过)。
- ③ 未读红点移到「通知」图标右上角(此前在文字后面),并加 DOM 几何断言(dx>0 且 dy<0,
  没有未读时自动造一条未读通知再断言、断言后删除)。
- 冒烟稳定性:新增 island.setBlurCollapseEnabled()(默认开),测试期间关掉"失焦收起",
  避免系统抢焦点导致展开态被收回的随机失败;专门验证失焦的用例仍临时打开。

二、作业看板(学生端)
- ⑥ 只看当天:新增「只看今天」开关(默认开),按 createdAt 的本地日期过滤,昨天的过期作业不再混入。
- ⑧ 完整显示:卡片同时渲染标题 + 作业要求全文(列表模式也加「作业要求」列)。
- ⑨ 铺满不滚动:看板外层高度固定 + overflow hidden,按内容/可用高度算缩放系数用 transform: scale 适配
  (工具栏显示当前缩放比例),页面本身不出现滚动条。
- ⑦ 全屏看板标题栏用 #header 插槽:标题左对齐、当天日期时间绝对居中(受「显示时间」开关控制,每分钟刷新)。

三、课表与周数
- ⑤ 学期周数可调:新增 Class.termWeeks(默认 20,迁移 + 维护脚本),班主任在班级管理里改;
  GET /api/dashboard/term?classId= 返回该班 maxWeek,课表周次下拉与新建课表的默认 weekEnd 都按它来
  (不再固定 30 周)。
- ⑩ 课表管理只保留「导入 ClassIsland 课程表」入口(时间表由课程表 JSON 的 TimeLayouts 一并带入),
  「导入时间配置」按钮下线;ui-smoke 第 7.7 段改为断言新弹窗(解析 4 行 + 单双周标签 + 旧入口已下线)。

四、以班级为单位(⑬)与 Web 端
- 个人学生账号登录停用:POST /api/auth/login 对 role=STUDENT 返回 403(改用班级码 + 班级密码);
  学生行仍作为个人数据记录键由班级会话代全班读写;e2e 全面切换到班级会话并新增该断言。
- ④ 作业科目过少:新增共享 SUBJECT_CATALOG(16 个常见科目)+ 种子课程扩到全科目;
  Web 作业发布弹窗可选「其他科目(新建)」,提交前自动建课(同名复用)。
- ⑪ 通知支持多班批量发布(多选 + 逐班发布 + 汇总结果 + 二次确认覆盖所有选中班);
  ⑫ 单班只显示已读情况、跨班才显示已读率;⑭ 手机端课表可横向滚动看全 7 天;
  ⑮ 手机端已连接不再显示孤立绿点(仅未连接时显示文字标签);⑯ 手机端「叫人/发布通知」按钮同宽左对齐;
  ⑬ Web 学生管理去掉「用户名」列(新建自动生成学号式用户名,导入仍支持显式指定)。

验证:verify:e2e 149/149、verify:web 20/20、verify:desktop 75/75(复跑 68/68,打包便携版 75/75 packaged=true)、
typecheck / lint / format 全绿;服务端与 Web 已重新打包并部署到本机安装目录。
This commit is contained in:
LoveChengke committed 2026-09-13 08:39:11 +08:00
1 parent b8ef5d8dbb
commit 11008928a1
34 files changed
+1421 -340

No files matched your search

@@ -0,0 +1,82 @@
/**
* 维护脚本:给"已有数据库"补齐结构性新增列(不依赖安装程序升级)。
*
* 为什么需要它:安装版服务端只在**库为空**时执行随包迁移 SQL(首次启动建表);
* 用安装程序覆盖升级时,升级逻辑会自动补齐新迁移。若像本地联调那样**手工覆盖 dist**
* 部署,就需要显式跑一次本脚本。
*
* 用法(用安装目录自带的 node 即可,无需 SDK):传入**已编译的 `lib/db.js`**,
* 直接复用服务端自己配置好的 Prisma 客户端(Prisma 7 需要 driver adapter,不能裸 new):
*
* node apply-column-migrations.cjs "<安装目录>/server/dist/lib/db.js"
*
* 环境变量(与服务端一致):
* DATABASE_PROVIDER=sqlite
* DATABASE_URL="file:<绝对路径>/classhelper.db"
*
* 幂等:已存在的列会跳过。
*/
const { pathToFileURL } = require('node:url');
const dbEntry = process.argv[2];
if (!dbEntry) {
console.error('用法:node apply-column-migrations.cjs <已编译的 lib/db.js 绝对路径>');
process.exit(2);
}
/** 需要保证存在的列(新增迁移时在这里追加一行) */
const COLUMNS = [
{
table: 'Schedule',
column: 'weekParity',
sql: `ALTER TABLE "Schedule" ADD COLUMN "weekParity" TEXT NOT NULL DEFAULT 'ALL'`,
note: '课表单双周(ALL/ODD/EVEN)',
},
{
table: 'Class',
column: 'termWeeks',
sql: `ALTER TABLE "Class" ADD COLUMN "termWeeks" INTEGER NOT NULL DEFAULT 20`,
note: '班级教学周数(班主任可调,默认 20)',
},
];
(async () => {
let prisma;
try {
const module = await import(pathToFileURL(dbEntry).href);
prisma = module.prisma ?? module.default?.prisma;
} catch (error) {
console.error(
'[migrate] 无法加载服务端的 Prisma 客户端:',
error && error.message ? error.message : error,
);
process.exitCode = 1;
return;
}
if (!prisma) {
console.error('[migrate] lib/db.js 里没有导出 prisma');
process.exitCode = 1;
return;
}
try {
for (const item of COLUMNS) {
const columns = await prisma.$queryRawUnsafe(`PRAGMA table_info("${item.table}")`);
if (columns.some((column) => column.name === item.column)) {
console.log(`[migrate] ${item.table}.${item.column} 已存在(跳过)`);
continue;
}
await prisma.$executeRawUnsafe(item.sql);
console.log(`[migrate] 已新增 ${item.table}.${item.column} —— ${item.note}`);
}
for (const table of [...new Set(COLUMNS.map((item) => item.table))]) {
const after = await prisma.$queryRawUnsafe(`PRAGMA table_info("${table}")`);
console.log(`[migrate] ${table} 列:${after.map((column) => column.name).join(', ')}`);
}
} catch (error) {
console.error('[migrate] 失败:', error && error.message ? error.message : error);
process.exitCode = 1;
} finally {
await prisma.$disconnect?.();
}
})();
@@ -1,62 +0,0 @@
/**
* 维护脚本:给"已有数据库"补上 Schedule.weekParity 列(单双周课表)。
*
* 为什么需要它:安装版服务端只在**库为空**时执行随包迁移 SQL(首次启动建表);
* 用安装程序覆盖升级时,升级逻辑会自动补齐新迁移。若像本地联调那样**手工覆盖 dist**
* 部署,就需要显式跑一次本脚本。
*
* 用法(用安装目录自带的 node 即可,无需 SDK):传入**已编译的 `lib/db.js`**,
* 直接复用服务端自己配置好的 Prisma 客户端(Prisma 7 需要 driver adapter,不能裸 new):
*
* node apply-parity-column.cjs "<安装目录>/server/dist/lib/db.js"
*
* 环境变量(与服务端一致):
* DATABASE_PROVIDER=sqlite
* DATABASE_URL="file:<绝对路径>/classhelper.db"
*/
const { pathToFileURL } = require('node:url');
const dbEntry = process.argv[2];
if (!dbEntry) {
console.error('用法:node apply-parity-column.cjs <已编译的 lib/db.js 绝对路径>');
process.exit(2);
}
(async () => {
let prisma;
try {
const module = await import(pathToFileURL(dbEntry).href);
prisma = module.prisma ?? module.default?.prisma;
} catch (error) {
console.error(
'[parity] 无法加载服务端的 Prisma 客户端:',
error && error.message ? error.message : error,
);
process.exitCode = 1;
return;
}
if (!prisma) {
console.error('[parity] lib/db.js 里没有导出 prisma');
process.exitCode = 1;
return;
}
try {
const columns = await prisma.$queryRawUnsafe('PRAGMA table_info("Schedule")');
if (columns.some((column) => column.name === 'weekParity')) {
console.log('[parity] Schedule.weekParity 已存在,无需处理');
} else {
await prisma.$executeRawUnsafe(
`ALTER TABLE "Schedule" ADD COLUMN "weekParity" TEXT NOT NULL DEFAULT 'ALL'`,
);
console.log('[parity] 已新增 Schedule.weekParity(默认 ALL,旧数据行为不变)');
}
const after = await prisma.$queryRawUnsafe('PRAGMA table_info("Schedule")');
console.log(`[parity] 当前列:${after.map((column) => column.name).join(', ')}`);
} catch (error) {
console.error('[parity] 失败:', error && error.message ? error.message : error);
process.exitCode = 1;
} finally {
await prisma.$disconnect?.();
}
})();
+60 -20
View File
@@ -85,13 +85,46 @@ async function main() {
record('管理员登录 admin', Boolean(adminToken), `status=${adminLogin.status}`);
if (!adminToken) process.exit(1);
const studentLogin = await api('/auth/login', {
// 学生端主体 = 班级:用「班级码 + 班级密码」登录(个人学生账号已停用登录入口)
const classesForLogin = await api('/classes', { token: teacherToken });
const loginClass = classesForLogin.payload?.data?.[0];
if (!loginClass?.code) {
record(
'学生端班级登录(班级码 + 班级密码 → classSession)',
false,
'没有可用班级码,请先执行 pnpm db:seed',
);
process.exit(1);
}
let studentLogin = await api('/auth/class-login', {
method: 'POST',
body: { username: 'student01', password: 'student123' },
body: { code: loginClass.code, password: '123456' },
});
if (studentLogin.status !== 200) {
// 演示库密码被改过时,由管理员重置为已知值(仅验证环境)
await api(`/classes/${loginClass.id}/class-account`, {
method: 'PATCH',
token: adminToken,
body: { code: loginClass.code, password: '123456' },
});
studentLogin = await api('/auth/class-login', {
method: 'POST',
body: { code: loginClass.code, password: '123456' },
});
}
const studentToken = studentLogin.payload?.data?.token;
const studentUser = studentLogin.payload?.data?.user;
record('学生登录 student01', Boolean(studentToken), `classId=${studentUser?.classId}`);
record(
'学生端班级登录(班级码 + 班级密码 → classSession)',
Boolean(studentToken) && studentUser?.classSession === true,
`code=${loginClass.code} status=${studentLogin.status} classId=${studentUser?.classId ?? studentUser?.id}`,
);
record(
'个人学生账号登录已停用(403)',
(await api('/auth/login', { method: 'POST', body: { username: 'student01', password: 'student123' } }))
.status === 403,
'student01 → 403',
);
const wrongPassword = await api('/auth/login', {
method: 'POST',
@@ -128,7 +161,8 @@ async function main() {
const studentList = await api(`/students?classId=${classId}`, { token: adminToken });
const classmates = studentList.payload?.data ?? [];
const targetStudent = classmates.find((item) => item.id === studentUser?.id) ?? classmates[0];
// 班级会话下没有"当前学生",目标学生固定取班里第一位(用于成绩/叫人等需要具体学生 id 的用例)
const targetStudent = classmates[0];
record('教师获取学生名单', classmates.length > 0, `共 ${classmates.length} 人`);
const courses = await api(`/courses?classId=${classId}`, { token: teacherToken });
@@ -468,8 +502,8 @@ async function main() {
body: { notSubmittedUserIds: [] },
});
record(
'普通学生不能维护未交名单(403)',
studentSubmissions.status === 403,
'班级设备可以维护未交名单(非教师/非班级会话会被拒)',
studentSubmissions.status === 200,
`status=${studentSubmissions.status}`,
);
@@ -497,7 +531,7 @@ async function main() {
});
record('教师录入成绩', createdGrade.status === 201, `status=${createdGrade.status}`);
if (targetStudent?.id === studentUser?.id) {
if (targetStudent) {
try {
const { payload, elapsed } = await gradeWait;
record(
@@ -808,7 +842,7 @@ async function main() {
token: teacherToken,
body: {
classId,
studentId: studentUser.id,
studentId: targetStudent?.id,
quickPhrase: '请到办公室找我',
},
});
@@ -829,7 +863,7 @@ async function main() {
token: teacherToken,
body: {
classId,
studentId: studentUser.id,
studentId: targetStudent?.id,
quickPhrase: '请立刻到办公室',
urgent: true,
},
@@ -845,7 +879,7 @@ async function main() {
token: teacherToken,
body: {
classId,
studentId: studentUser.id,
studentId: targetStudent?.id,
quickPhrase: '请到讲台找我',
message: '带上昨天的数学作业本',
},
@@ -860,7 +894,7 @@ async function main() {
const callDuringClass = await api('/calls', {
method: 'POST',
token: teacherToken,
body: { classId, studentId: studentUser.id, quickPhrase: '请马上来一趟' },
body: { classId, studentId: targetStudent?.id, quickPhrase: '请马上来一趟' },
});
record(
'上课时段允许叫人(普通叫人同样不受紧急通知 409 限制)',
@@ -871,7 +905,7 @@ async function main() {
const studentCalls = await api('/calls', {
method: 'POST',
token: studentToken,
body: { classId, studentId: studentUser.id, quickPhrase: '学生不能叫人' },
body: { classId, studentId: targetStudent?.id, quickPhrase: '学生不能叫人' },
});
record('学生调用叫人接口被拒绝(403)', studentCalls.status === 403, `status=${studentCalls.status}`);
@@ -1006,7 +1040,13 @@ async function main() {
const subjectGrades = await api('/grades', {
method: 'POST',
token: teacher2Token,
body: { classId: classId, userId: studentUser?.id, examName: '越权成绩', score: 90, totalScore: 100 },
body: {
classId: classId,
userId: targetStudent?.id,
examName: '越权成绩',
score: 90,
totalScore: 100,
},
});
record('科任老师录入成绩被拒绝(403)', subjectGrades.status === 403, `status=${subjectGrades.status}`);
@@ -1016,7 +1056,7 @@ async function main() {
token: teacherToken,
body: {
classId: classId,
userId: studentUser?.id,
userId: targetStudent?.id,
examName: '班主任本班成绩',
score: 90,
totalScore: 100,
@@ -1037,7 +1077,7 @@ async function main() {
token: teacherToken,
body: {
classId: foreignClass.id,
userId: studentUser?.id,
userId: targetStudent?.id,
examName: '班主任跨班成绩',
score: 90,
totalScore: 100,
@@ -1055,7 +1095,7 @@ async function main() {
token: adminToken,
body: {
classId: classId,
userId: studentUser?.id,
userId: targetStudent?.id,
examName: '管理员录入成绩',
score: 88,
totalScore: 100,
@@ -1132,7 +1172,7 @@ async function main() {
const studentVisible = studentClasses.payload?.data ?? [];
record(
'学生班级列表仅含自己所在班级',
studentVisible.length === 1 && studentVisible[0]?.id === studentUser?.classId,
studentVisible.length === 1 && studentVisible[0]?.id === classId,
`共 ${studentVisible.length} 个`,
);
@@ -1140,7 +1180,7 @@ async function main() {
const homeworkClassIds = new Set((studentHomeworkAll.payload?.data ?? []).map((item) => item.classId));
record(
'学生作业列表已按班级收敛',
homeworkClassIds.size <= 1 && (homeworkClassIds.size === 0 || homeworkClassIds.has(studentUser?.classId)),
homeworkClassIds.size <= 1 && (homeworkClassIds.size === 0 || homeworkClassIds.has(classId)),
`涉及 ${homeworkClassIds.size} 个班级`,
);
@@ -1750,7 +1790,7 @@ async function main() {
const classGradesWrite = await api('/grades', {
method: 'POST',
token: classToken,
body: { classId, userId: studentUser?.id, examName: '班级账号越权成绩', score: 90, totalScore: 100 },
body: { classId, userId: targetStudent?.id, examName: '班级账号越权成绩', score: 90, totalScore: 100 },
});
record(
'班级账号录入成绩被拒绝(403)',
@@ -1843,7 +1883,7 @@ async function main() {
const classNameGrade = await api('/grades', {
method: 'POST',
token: adminToken,
body: { classId, userId: studentUser?.id, examName: '班级总览回归', score: 77, totalScore: 100 },
body: { classId, userId: targetStudent?.id, examName: '班级总览回归', score: 77, totalScore: 100 },
});
const classMyGrades = await api('/grades/my', { token: classToken });
const gradeStudentIds = new Set((classMyGrades.payload?.data ?? []).map((item) => item.userId));