feat(desktop+web+server): ClassIsland 风格 UI、灵动岛动画/交互修复、作业上岛与"叫人"功能
## 灵动岛修复与动画优化(用户反馈) - **收回不再出现"方框"闪烁**:卡片改为**固定逻辑尺寸 + 顶部居中锚定**, 窗口只负责露出/裁切透明区域。此前卡片随窗口拉伸,形变过程中会看到被拉扁的圆角方块, 胶囊里的铃铛/文字还会被垂直居中而"从上跳到下";两条问题同源,现已消除。 冒烟用 15 次采样断言卡片尺寸恒为固定值(`396x308` / `260x38`),一旦出现中间值即失败。 - **点击屏幕任意位置收回**:展开态临时 `setFocusable(true)` 并取焦,点到别处即失焦 → 自动回缩为胶囊; 收起后立即释放可聚焦性。断言覆盖 `focusable=true → 失焦后 mode=pill、focusable=false`。 - 动画继续打磨:危险/叫人形态改为**内部光晕**(卡片四周再留 4px 透明边,彻底避免窗口边界裁切出硬边)、 尖角与圆角统一、形态尺寸各异(胶囊 268×44 / 详情 404×316 / 紧急 424×344 / 叫人 440×360)。 ## 灵动岛"标为已读"真正同步通知中心 - 新增链路:灵动岛 `mark-read` → 主进程 `setMarkReadHandler` → 主窗口渲染进程 → `notificationApi.markRead` + 刷新 store(未读红点即时减少)。 - 真机链路断言:点击"标为已读"后 `read=false → true`、未读数 `1 → 0`(此前只从灵动岛队列移除)。 ## 作业发布也上岛 - `homework:new` → 灵动岛 `kind=homework`:胶囊显示"新作业"(青蓝描边 + 书本图标), 展开显示作业说明与"截止时间:…"。 ## 新增"叫人"功能 - 服务端:新模块 `modules/calls`(`POST /api/calls`)——校验班级可写 + 学生属于该班, 落库一条 HIGH 级通知(进通知中心、可用已读状态),广播 `notification:new` 到班级房间, 并定向 `call:new` 给被叫学生。 - 共享层:`CALL_QUICK_PHRASES`(8 条快捷短语)、`buildCallTitle()`("请 XXX 同学找 XXX 老师",老师名已含"老师"不重复)、 `ServerToClientEvents['call:new']`、`CreateCallRequest`。 - Web 管理端:学生管理列表新增 **叫人** 按钮 → 弹窗显示对象、快捷短语(点选/取消)、自定义消息(优先),发送即通知。 - 客户端:`call:new` → 灵动岛 `kind=call`,**上课时段也立即展开**(老师正在等这名学生), 琥珀金卡片 +"叫人"徽标 +"收到"按钮,90 秒后自动收起。 ## 客户端界面改为 ClassIsland 同款 Fluent 风格 - 主题令牌:Mica 浅底 `#f3f3f3`、亚克力卡片 `rgba(255,255,255,.7)` + `backdrop-filter`、 强调色 `#0F6CBD`、半透明描边、卡片 8px / 控件 4px 圆角、极轻阴影。 - Element Plus 变量整体对齐(`--el-color-primary`、圆角、表头/行分隔、滚动条等)。 - 侧边导航改为 Fluent NavigationView 观感:白色半透明底、选中项强调色淡底 + 左侧 3px 强调条; 品牌标改为强调色渐变圆角方块。附客户端五个页面实拍(`docs/screenshots/client/`)。 ## 验证 - `pnpm verify:e2e` **68/68**(新增 6 项叫人:201 + 标题模板、自定义消息优先、上课时段允许、学生 403、通知中心可见、清理) - `pnpm verify:desktop` **33/33**(新增:卡片固定尺寸、点击任意处收回、标为已读同步、作业上岛、叫人上课中立即展开、真实通知链路) - `pnpm verify:web` **16/16**(新增叫人入口:弹窗、8 条快捷短语、自定义输入、短语可选中) - `pnpm lint` / `format:check` / `typecheck` 全部通过;服务端安装包已重打并安装验证
This commit is contained in:
1 parent
f759aac0a2
commit
219f6ae83a
28 files changed
+1555
-156
No files matched your search
@@ -215,6 +215,109 @@ export async function onlineScenario(): Promise<SmokeCheckResult> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冒烟自检 5(需后端在线):真实通知链路 → 灵动岛。
|
||||
*
|
||||
* 前面的灵动岛用例直接调 IPC 验证"状态机",这一条走**真机链路**:
|
||||
* 教师账号给"当前登录学生所在班级"发一条通知 → 服务端 Socket.IO 广播 →
|
||||
* 客户端 realtime store → bridge → 主进程灵动岛。主进程随后断言灵动岛弹出胶囊,
|
||||
* 并继续验证"在灵动岛点标为已读 → 通知中心同步为已读"。
|
||||
*/
|
||||
export async function islandRealtimeScenario(): Promise<{
|
||||
ok: boolean;
|
||||
detail: string;
|
||||
notificationId?: string;
|
||||
teacherToken?: string;
|
||||
title?: string;
|
||||
classId?: string;
|
||||
inClass?: boolean;
|
||||
}> {
|
||||
const [{ useAuthStore }, { getIslandClassContext }] = await Promise.all([
|
||||
import('../stores/auth.js'),
|
||||
import('../island/bridge.js'),
|
||||
]);
|
||||
const auth = useAuthStore();
|
||||
const serverUrl = 'http://127.0.0.1:4000';
|
||||
const classId = auth.classId ?? null;
|
||||
if (!classId) return { ok: false, detail: '当前学生没有班级,无法投递通知' };
|
||||
|
||||
const title = `灵动岛真机链路自检 ${Date.now()}`;
|
||||
try {
|
||||
const login = await fetch(`${serverUrl}/api/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ username: 'teacher1', password: 'teacher123' }),
|
||||
}).then((response) => response.json());
|
||||
const teacherToken: string | undefined = login?.data?.token;
|
||||
if (!teacherToken) return { ok: false, detail: `教师登录失败:${JSON.stringify(login).slice(0, 120)}` };
|
||||
|
||||
const created = await fetch(`${serverUrl}/api/notifications`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json', authorization: `Bearer ${teacherToken}` },
|
||||
body: JSON.stringify({
|
||||
classId,
|
||||
title,
|
||||
content: '自动化验证:这条通知用于确认「服务端广播 → 客户端实时通道 → 灵动岛」整条链路可用。',
|
||||
priority: 'NORMAL',
|
||||
}),
|
||||
}).then((response) => response.json());
|
||||
const notificationId: string | undefined = created?.data?.id;
|
||||
if (!notificationId)
|
||||
return { ok: false, detail: `发布通知失败:${JSON.stringify(created).slice(0, 160)}` };
|
||||
|
||||
const context = getIslandClassContext();
|
||||
return {
|
||||
ok: true,
|
||||
detail: `classId=${classId} 通知=${notificationId} 客户端判定上课中=${context.inClass}`,
|
||||
notificationId,
|
||||
teacherToken,
|
||||
title,
|
||||
classId,
|
||||
inClass: context.inClass,
|
||||
};
|
||||
} catch (error) {
|
||||
return { ok: false, detail: `投递失败:${error instanceof Error ? error.message : String(error)}` };
|
||||
}
|
||||
}
|
||||
|
||||
/** 冒烟收尾:删除真实链路自检产生的通知 */
|
||||
export async function islandRealtimeCleanup(
|
||||
notificationId: string,
|
||||
teacherToken: string,
|
||||
): Promise<SmokeCheckResult> {
|
||||
try {
|
||||
const response = await fetch(`http://127.0.0.1:4000/api/notifications/${notificationId}`, {
|
||||
method: 'DELETE',
|
||||
headers: { authorization: `Bearer ${teacherToken}` },
|
||||
});
|
||||
return { ok: response.ok, detail: `清理通知 ${notificationId} → HTTP ${response.status}` };
|
||||
} catch (error) {
|
||||
return { ok: false, detail: error instanceof Error ? error.message : String(error) };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取某条通知在本地通知中心里的已读状态。
|
||||
* 用于验证"灵动岛点标为已读 → 通知中心也变成已读、未读数下降"。
|
||||
*/
|
||||
export async function islandReadState(notificationId: string): Promise<{
|
||||
found: boolean;
|
||||
read: boolean;
|
||||
unreadCount: number;
|
||||
title: string;
|
||||
}> {
|
||||
const { useNotificationStore } = await import('../stores/notifications.js');
|
||||
const store = useNotificationStore();
|
||||
if (store.items.length === 0) await store.load().catch(() => undefined);
|
||||
const target = store.items.find((item) => item.id === notificationId);
|
||||
return {
|
||||
found: Boolean(target),
|
||||
read: Boolean(target?.read),
|
||||
unreadCount: store.unreadCount,
|
||||
title: target?.title ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
/** 冒烟收尾:断开实时通道并退出登录,保证下次冒烟从登录页开始 */
|
||||
export async function sessionCleanup(): Promise<SmokeCheckResult> {
|
||||
const [{ useAuthStore }, { useRealtimeStore }] = await Promise.all([
|
||||
@@ -237,6 +340,9 @@ export function registerSmokeHooks(): void {
|
||||
offlineScenario,
|
||||
layoutNavigationSelfTest,
|
||||
onlineScenario,
|
||||
islandRealtimeScenario,
|
||||
islandRealtimeCleanup,
|
||||
islandReadState,
|
||||
sessionCleanup,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user