SpecialX
081cb5fbc3
feat(portal-shell): homework 模块 7 页迁移(教师域 §9.1 B2)
...
§9.1 教师域 homework 模块完整迁移(继 exams 之后第二个 B2 模块):
7 页路由结构(与旧 teacher-portal 同构):
- /shell/teacher/homework:列表页(?classId/status/q 筛选)
- /shell/teacher/homework/new:布置作业表单页
- /shell/teacher/homework/[id]:详情 + 内联批改(含提交列表 + recordGrade 表单)
- /shell/teacher/homework/submissions:跨作业提交评审列表
- /shell/teacher/homework/submissions/[submissionId]:单份提交批改 + AI 建议 + 上下份导航
- /shell/teacher/homework/submissions/[submissionId]/scan-grading:扫描批改工作台(三栏)
- /shell/teacher/homework/assignments/[id]/submissions:按作业批量批改 + 统计 + AI 批量评分
数据契约(混合):
- ✅ homework(id: ID!) 真实查询(schema 已就绪,详情页用)
- ❌ 列表/mutation/submissions/grading/aiBatchGrading 全部 @contract-pending MSW 兜底
· 9 个 hook 走 MSW,待后端补齐 mutation 后切换真实 fetcher
§11.3 DoD 11 项验收:
1. route-permissions:EXACT + PREFIX 表 /shell/teacher/homework 已配置
2. 页面模板:list/new 用 ListPageShell/FormPageShell;detail/grading 用 DetailPageShell;
scan-grading 用 WorkbenchPageShell(三栏,未使用 emptyNode)
3. 三态:loading(Skeleton)/error(errorNode 或 errorSummary)/empty(emptyNode) 全实现
4. lib/api hooks:homework.ts 10 个 hooks(useHomework 真实 + 9 个 MSW)
5. @contract-pending MSW:graphql-data.ts 扩展 6 块 mock + 10 个 switch case
6. i18n:homework 节点扩展 8 个分区共 130+ keys(list/detail/new/submissions/grading/
scan/assignment/error)中英对齐
7. lint:0 errors(4 warnings 在 __generated__)
8. lint:tokens:0 errors
9. notify:mutation 反馈走 @/shared/lib/notify(非 sonner 直引)
10. vitest:transformations 纯函数单测齐全,全量 323/323 通过(新增 ~50 测试)
11. typecheck:0 errors(noUncheckedIndexedAccess 安全访问)
附带修复:
- 修复 2 处遗留 broken link:
· widgets/sidebar/quick-actions: /homework/new → /shell/teacher/homework/new
· widgets/topbar/global-search: /homework → /shell/teacher/homework
- scripts/check-page-count.ts baseline 同步 13 → 26(与 exams 6 + homework 7 一致)
剩余模块:grades(5)+lesson-plans(6)+questions(1)+textbooks(2)+attendance(4)+classes(3)+
students(1)+course-plans(2)+elective(3)+error-book(1)+diagnostic(2)+analytics(2)+ai-*(3)+
knowledge-graph(1)+practice(1)+schedule-changes(1)+leave(1) 共 39 页。
2026-07-22 18:11:15 +08:00
SpecialX
dca25fc42f
feat(portal-shell): exams 三子页面迁移(analytics/build/edit)
...
§9.1 教师域 exams 模块补完(继 d066da5 列表/详情/表单后):
- /shell/teacher/exams/[id]/analytics:详情页(图表)- 混合契约
· 基础统计 ✅ assignmentAnalysis(data-ana 子图,schema 已就绪)
· 扩展字段(排名/每题正确率)❌ MSW 兜底(@contract-pending)
· 含 Summary/Distribution/QuestionAccuracy/Rankings 四区
- /shell/teacher/exams/[id]/build:工作台页(组卷)@contract-pending
· 三栏:题库候选 / 已选题目 / 预览
· 支持搜索/类型/难度筛选,添加/移除/上移/下移/改分
- /shell/teacher/exams/[id]/edit:工作台页(富文本试卷)@contract-pending
· contentEditable + 工具栏(B/I/U/H1-H3/列表)
· 右栏试卷属性面板
§11.3 DoD 11 项验收:
1. route-permissions:PREFIX 表 /shell/teacher/exams/ 已覆盖
2. 页面模板:analytics 用 DetailPageShell;build/edit 用 WorkbenchPageShell
3. 三态:loading/error/empty 均实现(workbench 用 errorNode 合并 empty)
4. lib/api hooks:useExamAnalytics/useExamBuild/useQuestionsLibrary/
useSaveExamBuild/useExamRichEditor/useSaveExamRichContent 6 个
5. @contract-pending MSW 模式:graphql-data.ts 扩展 6 个 case
6. i18n:analytics(19 keys)+build(28 keys)+edit(13 keys) 中英对齐
7. lint:0 errors(4 warnings 在 __generated__)
8. lint:tokens:0 errors
9. notify:success/error/warning 走 @/shared/lib/notify(非 sonner 直引)
10. vitest:transformations 新增 10 函数 22 测试,全量 273/273 通过
11. typecheck:0 errors(noUncheckedIndexedAccess 安全 swap 写法)
剩余:proctoring 标注"二期 WS"按 §9.1 暂缓。
2026-07-22 17:38:51 +08:00
SpecialX
d066da563f
feat(portal-shell): 教师域考试管理页面迁移(P2)
...
按 ARCHITECTURE.md §9.1/§10 P2 要求,迁移教师域 exams 模块:
- 列表页 /shell/teacher/exams(ListPageShell + URL 状态 + 客户端二次筛选)
- 详情页 /shell/teacher/exams/[id](DetailPageShell + 真实 exam(id) 查询)
- 新建页 /shell/teacher/exams/new(FormPageShell + MSW 兜底)
- 纯函数 transformations.ts + 19 个 vitest 单测
- @contract-pending:exams(classId) 列表查询、createExam mutation 走 MSW
- 三态 UI(loading/error/empty)+ 路由级 loading.tsx/error.tsx
- i18n:zh-CN/en 双语补全,无硬编码中文
- MSW handlers 支持 variables 透传
§11.3 DoD 验收:
- lint: 0 errors(4 个 __generated__ 预存警告)
- typecheck: 0 errors
- test: 250/250 passed(含 19 个新增 transformations 测试)
- lint:tokens: 0 errors
2026-07-22 17:02:05 +08:00
SpecialX
0beeff6329
feat(portal-shell): restore codegen typescript-operations for data-ana domain (P1-7)
...
ARCHITECTURE.md §10 P1-7: dashboard domain's 6 operations strictly
match the schema, so disable skipDocumentsValidation for that output
and restore per-operation type generation.
Changes:
- codegen.yml: add dashboard-types.ts output (typescript +
typescript-operations plugins, skipDocumentsValidation: false);
move documents config into each generates entry
- dashboard.ts: remove 14 handwritten interfaces and 6 internal query
type aliases; derive types via NonNullable<GetXxxQuery['xxx']> so
the public hook API shape stays unchanged
- admin/student/teacher page.tsx: add ?? "--" / ?? 0 null guards on
StatCard value props to match schema nullable semantics (parent page
already uses toFixed chain, no change needed)
Acceptance (ARCHITECTURE.md §10 P1-7):
- codegen 3 outputs all SUCCESS
- tsc 0 errors / eslint 0 errors / vitest 231 passed / next build ok
- 6 operations strictly match schema with 0 errors
Refs: ARCHITECTURE.md §5.3 data layer / §10 P1-7
2026-07-22 15:37:06 +08:00
SpecialX
9358372657
feat(portal-shell): add MSW mock layer with production bundle exclusion (P1-5)
...
MSW v2.7.0 fallback layer covering dashboard/users/exams/grades domains.
NEXT_PUBLIC_MSW=1 enables browser Service Worker + SSR route handler mock
responses without backend. Production build excludes all mock data via
Turbopack resolveAlias redirecting @/mocks to empty stub.
Acceptance: build bundle (client+server) verified clean of mock strings;
typecheck/lint/vitest (231 tests) all pass.
2026-07-22 14:48:30 +08:00
SpecialX
da05c9107a
feat(portal-shell): integrate next-intl + merge messages from teacher-portal (P1-4)
...
- Add next-intl v4.13.2 with cookie-based locale (no i18n routing)
- Create src/i18n/request.ts reading NEXT_LOCALE cookie
- Merge zh-CN/en messages from teacher-portal + add shell.dev.templates namespace
- Wrap next.config.js with withNextIntl plugin (Turbopack resolveAlias)
- Refactor RootLayout to async + NextIntlClientProvider + getLocale/getMessages
- Replace ThemeI18nProvider with ThemeProvider (theme-only, i18n removed)
- Remove locale/setLocale from PluginStore
- Rework locale-switcher to useLocale/useTranslations + router.refresh
- Update dev/templates page to use getTranslations (Server Component)
- Fix WorkbenchPageShell test (loading prop + center instead of children)
Verified: locale switch via NEXT_LOCALE cookie changes <html lang> and messages
zh-CN: 保存/取消/切换侧栏 | en: Save/Cancel/Toggle sidebar
typecheck 0 errors | lint 0 errors 2 warnings (generated) | vitest 231 passed
2026-07-22 13:40:44 +08:00
SpecialX
994441c2dc
feat(portal-shell): add page templates quartet (list/detail/form/workbench) (P1-3)
...
P1-3 验收通过:4 个页面模板 + 4 个 dev 示例页 + 三态规范。
新增文件:
- src/shared/components/page-templates/
- list-page.tsx:ListPageShell + ListPageSkeleton
- detail-page.tsx:DetailPageShell + DetailSection + DetailField + DetailPageSkeleton
- form-page.tsx:FormPageShell + FormPageSkeleton
- workbench-page.tsx:WorkbenchPageShell + WorkbenchPanel + WorkbenchPageSkeleton
- index.ts:barrel 导出
- src/app/shell/dev/templates/
- page.tsx:索引页(4 个模板入口)
- list/page.tsx:列表页示例(支持 ?state=loading|empty|success)
- detail/page.tsx:详情页示例
- form/page.tsx:表单页示例
- workbench/page.tsx:工作台页示例
- src/shared/components/__tests__/page-templates.test.tsx:19 个单测
修改文件:
- src/shared/lib/route-permissions.ts:新增 PREFIX /shell/dev/(空 config = 仅校验登录)
- ARCHITECTURE.md:P1-3 状态回填 ✅ + 验收证据
路径命名修正:
- 原 ARCHITECTURE.md 写 /shell/_dev/templates/*,但 Next.js 将下划线开头的
文件夹视为"私有文件夹"(不参与路由),实测被 [[...route]] catch-all 兜底接管。
- 改用 dev 命名后,显式路由优先匹配,catch-all 不再触发。
三态规范验证:
- GET /shell/dev/templates/list?state=loading → 200,含 animate-pulse 骨架
- GET /shell/dev/templates/list?state=empty → 200,含"暂无数据"空态
- GET /shell/dev/templates/list(默认 success)→ 200,含表格数据
质量校验:
- tsc --noEmit 通过
- eslint(新/改文件)通过
- vitest run 全量 21 test files / 231 tests 全部通过(212 原有 + 19 新增)
Refs: apps/portal-shell/ARCHITECTURE.md §7.3 页面四种类型与模板、
§7.4 页面级数据获取模式、§11.3 每页硬性清单(DoD)三态规范
2026-07-22 13:02:11 +08:00
SpecialX
03e3ec4f60
fix(portal-shell): wrap sidebar in client component to respect RSC boundary
...
P1-1 regression introduced by layout.tsx RSC refactor: navigation.ts
exports `icon: LucideIcon` (function refs) which cannot cross the RSC
boundary from a Server Component to a Client Component.
Fix:
- Introduce ShellSidebar (Client Component) that owns the navigation
filtering + icon refs entirely on the client side.
- layout.tsx (RSC) now only passes serializable strings (`role` and
`permsBitmap`) to ShellSidebar; no function references cross the
boundary.
Error before fix:
Error: Functions cannot be passed directly to Client Components
unless you explicitly expose it by marking it with "use server".
{$$typeof: ..., render: function LayoutDashboard}
Refs: apps/portal-shell/ARCHITECTURE.md §7.2 AppFrame, §10 P1-1,
§11.7 red line #5 (fail-closed identity).
2026-07-22 12:47:00 +08:00
SpecialX
98058eb16b
feat(portal-shell): wire dashboards to real data-ana queries (P1-2)
...
- add dashboard.graphql.ts with 6 real aggregate queries
(teacherDashboard / studentDashboard / parentDashboard /
adminDashboard / warnings / errorBookStats), snake_case aligned
- add dashboard.ts with 6 hooks + full domain model types
- add 4 role dashboard pages (teacher/student/parent/admin)
using DashboardShell + StatCard + DashboardSection with
loading / error / success tri-state
- update [[...route]]/page.tsx to redirect /shell -> /shell/{role}
- retire 6 fake contract queries and hooks (grades/homeworks/
schedule/attendance/exams/announcements) and mark widget
placeholders as migrated
- update universal.test.ts to drop retired hook tests
- mark ARCHITECTURE.md P1-2 as completed with acceptance evidence
2026-07-22 12:33:22 +08:00
SpecialX
f92fdf8efe
feat(portal-shell): wire AppFrame + navigation + permission filter (P1-1)
...
实现 ARCHITECTURE.md §10 P1-1:
- 新增 src/shared/lib/navigation.ts:27 项静态导航注册表,
按 teacher/student/parent/admin 四角色分区,group 字段用于角色过滤
- 新增 src/app/shell/layout.tsx:RSC AppFrame,从 headers() 读取
middleware 注入的身份头,batchCheckRoutePermission 按位图二次过滤
- 新增 src/shared/components/layout/user-menu.tsx:顶部用户菜单,
显示 userId + role,登出 POST /api/auth/logout
- 新增 src/shared/lib/__tests__/navigation.test.ts:P1-1 验收单测
(7 用例:href 登记一致性 + 4 角色隔离 + 权限检查)
- 修改 src/shared/lib/route-permissions.ts:补全 7 个列表页根路由
的 EXACT 登记(/shell/admin/announcements、/shell/admin/classes、
/shell/teacher/exams 等),与 PREFIX 表互补避免 catch-all 拒绝
验收:
- vitest run navigation → 7/7 passed
- tsc --noEmit 通过;eslint(5 文件)通过
回填 ARCHITECTURE.md §10 P1-1 状态为 ✅ ,附验收证据。
关联:ARCHITECTURE.md §7.2 AppFrame / §10 P1-1
2026-07-22 12:17:16 +08:00
SpecialX
cfb7b005fd
feat(portal-shell): v2.1 P0 auth + middleware + login + graphql proxy
...
- 新增 ARCHITECTURE.md v3.0:portal-shell 架构权威文档
涵盖 §3.4 V3-A2/A3 认证链、§4 GraphQL 联邦、§5 安全、
§6 部署、§10 P0-P3 验收清单
- 新增 middleware.ts:认证 + 路由门禁
httpOnly cookie edu_session(JWT)读取
DEV_MODE 合成 dev-user/teacher 身份(NODE_ENV!=production &&
NEXT_PUBLIC_DEV_MODE=true)
生产模式 jose JWKS RS256 验签(iss/aud 校验)
路由权限位图注入 x-user-id/x-user-role/x-user-permissions 头
/shell/** 强制 checkRoutePermission,拒绝跳 /shell/forbidden
- 新增 instrumentation.ts:生产环境 DEV_MODE 强制 false
防止生产环境误开 DEV_MODE 合成身份
- 新增 app/api/auth/login/route.ts + logout/route.ts
登录走 api-gateway /v1/iam/login
设置 httpOnly + Secure + SameSite=Strict cookie
- 新增 app/api/graphql/route.ts:同域 GraphQL 代理
转发到 apollo-router,注入 router-authorization 头
- 新增 app/login/page.tsx + login-form.tsx
zod 表单校验,next 参数支持
- 新增 app/shell/forbidden/page.tsx:403 页面
- 更新 route-permissions.ts:补全 P0 路由权限映射
- 更新 permission-bitmap.ts(shared-ts):位图编码/解码
- 更新 apollo-client.ts:DEV_MODE APQ 关闭,错误处理
- 更新 config-fetcher.ts:config-service 直连降级
- 更新 ApolloProvider.tsx:SSR/RSC 兼容
- 更新 eslint.config.js:design-tokens/no-hardcoded-fonts
白名单调整
2026-07-22 11:35:36 +08:00
SpecialX
9cedf0c437
feat(portal-shell): v2.0 P0 shadcn standardization + security + streaming + error handling
...
- shadcn/ui 标准化:废弃纸感令牌,统一 bg-background/text-foreground 等
- Tailwind v4 + @theme inline,移除 tailwind.config.js
- React 19 use() + Suspense 流式渲染,首屏骨架秒出
- 三级错误边界:Route → Section → Widget 层层兜底
- 错误上报:useErrorReport → sendBeacon → /api/log mock 端点
- 三层安全边界:L1 角色门禁 / L2 权限点门禁 / L3 数据范围
- 权限位图 base36 压缩:67 权限点 → ~14 字符,JWT 体积减少 ≥ 99%
- notify 统一 Toast 封装,禁止业务直接 import sonner
- PluginBoundary 替代 PluginLoader(错误边界 + Suspense + Skeleton 三件套)
验证:typecheck 0 错误 / lint 0 错误 / build 6 路由生成成功
2026-07-17 16:10:05 +08:00
SpecialX
514e26ebb4
feat(portal-shell): implement portal-shell with apollo-router integration
...
M8: portal-shell unified frontend shell (Modular Monolith + micro-kernel).
- Apollo Client -> apollo-router (port 4010, RSC prefetch)
- 5 layouts: classic/focus/split/triple/canvas
- Registry + PluginLoader (dynamic import ssr:false)
- 3-layer props merge, Zustand PluginStore
- 4 widgets: grades/notification-bell/user-menu/class-selector
- config-service: new pluginConfig GraphQL resolver
- apollo-router: CORS + header propagation for portal-shell
- docker-compose.yml: portal-shell service block
2026-07-15 08:06:09 +08:00