refactor(rendering): 采用混合渲染,取数归服务端、交互留客户端 - #17
Merged
Merged
Conversation
- 新增 lib/access-rules.ts 与 lib/access.ts:相册与文件集的可见性规则收敛成
一套纯函数,服务端组件与 route handler 共用,替换 14 处复制粘贴的判断;
同时每次请求复核 User.status,被拒绝的账号立即降级为匿名视图
- 补齐缺失的渲染基础设施:loading/error/global-error、按段的 Suspense 与
形状对齐的骨架屏、统一的 EmptyState 与 ErrorAlert
- /files 与 /share/[token] 由 CSR 壳改为服务端渲染,首屏不再依赖串行 XHR;
分享密码改走 POST + path 作用域的 httpOnly cookie,不再出现在查询串里
- /album/[id] 与 /admin 改为按 URL 取数并流式:照片与成员/分享链接分页(?p=),
控制台只查询当前 tab,文档负载从四张无界表降到一页数据
- 修复相册搜索:/api/search 现在返回 {categories, photos} 并兑现 categoryId;
此前它查的是 File 表并返回 {items},搜索框因此永远显示"没有匹配结果"
- 修复 CI:vitest 此前未安装,pnpm test 与 pnpm build 都会失败;补上依赖并
为 access-rules 加 23 条规则矩阵用例(含 owner-relative 的私有文件集规则)
- /api/photos 的打包下载补上可见性过滤:原来猜到 id 就能取到无权相册的原图
需要执行:pnpm prisma:push(prisma/schema.prisma 为 Photo 加了
@@index([categoryId, createdAt]),建议先推 dev 数据库)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
需要执行:pnpm prisma:push(prisma/schema.prisma 为 Photo 加了 @@index([categoryId, createdAt]),建议先推 dev 数据库)