Repository navigation
完善主页与网页webxmoj - #18
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Claude finished @PythonSmall-Q's task in 4m 17s —— View job 评审结论已完成对本次 PR 的静态审阅。整体结构清晰,文档与实现的大部分细节能对上(分页大小、构建命令、Markdown 扩展、Prism 语言、缓存/轮询行为等均核对无误),未发现安全或性能问题。共有 6 处建议,其中 2 处会影响发布流程可用性,其余为文档准确性/可访问性细节,均已在对应 diff 行留下行内评论。 需要关注的问题
已核对且未发现问题
关于
|
|
@copilot 修复test failure并针对正确的评论修复,错误的可以忽略 |
已检查失败日志:唯一失败是实时社区测试登录 |
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Updated project website and documentation links in README.
|
Claude finished @PythonSmall-Q's task in 5m 38s —— View job 评审结论已完成本轮同步后的静态复核。上一轮 6 条意见中 5 条已正确处理;本轮新增改动里有 2 个需要处理的问题(1 个测试失败 + 1 个自定义域发布风险)和 4 处文档/可用性偏差,均已在对应 diff 行留下行内评论。
需要关注的问题
上一轮意见的处理情况
已核对且未发现问题
验证说明
|
|
Claude finished @zsTree0830's task in 6m 54s —— View job 代码审查完成
|
| snapshot: async (cacheOnly = false) => (cacheOnly ? homeSnapshotCache : loadHomeSnapshot()), | ||
| }, | ||
| monthly: { | ||
| board: async (cacheFirst = false) => (cacheFirst ? monthlyBoardCache : loadMonthlyBoard()), |
There was a problem hiding this comment.
home.snapshot / monthly.board 在共享类型中被声明为非空返回,但这里在“缓存优先”分支可能返回 null:
electron/preload.ts:25:snapshot: (cacheOnly = false) => invoke<HomeSnapshot>(...)electron/preload.ts:81:board: (cacheFirst = false) => invoke<MonthlyBoard>(...)- 桌面端实现(
electron/main.ts:362-374、298-308)在cacheOnly/cacheFirst且缓存为空时会回落到网络请求,因此永远不会返回null。
而网页实现 cacheOnly ? homeSnapshotCache : loadHomeSnapshot() 在缓存为空时直接返回 null,installWebApi 末尾的 as unknown as XmojApi 又把这个 HomeSnapshot | null 断言掉了,编译器无法发现差异。
目前调用方恰好做了空值保护(Home.vue:10 的 .catch(() => null)、Monthly.vue:25 的 cached?.cards),但这是隐式契约:任何按声明类型编写的新调用方(例如直接 (await fetchHomeSnapshot(true)).cards)都会在网页版首次进入页面或缓存被 cache.clear 清空后抛 TypeError。
建议二选一:
- 与桌面端行为对齐,缓存为空时回落到网络加载(注意
Home.vue的loadCacheFirst随后还会再调一次 fresh,桌面端也是同样两次请求,可接受); - 或把
electron/preload.ts的返回类型放宽为HomeSnapshot | null/MonthlyBoard | null,并同步更新src/services/api.ts的签名,让类型契约与实际行为一致。
|
看一下这个
Message ID: ***@***.***>
|
冲突解决:
- src/stores/navigation.ts:合并网页路由能力(activeContestId、viewContest/viewContestProblem、URL 同步)与 dev 的竞赛提交上下文(activeContest={contestId,contestPid});submitProblem 兼容 contestId 数值与 {contestId,contestPid} 对象。
- src/pages/Contests.vue / src/pages/ProblemView.vue:合并双方改动(懒加载 ContestReplay、竞赛题目提交按钮、标程查看、返回竞赛),图标导入取并集。
- src/stores/navigation.ts 相对导入改为带 .ts 扩展名,与仓库其它模块一致,保证 Node 测试加载器可用。
修复 PR #18 审查意见:网页版 home.snapshot(cacheOnly) 与 monthly.board(cacheFirst) 在缓存为空(首次进入页面或 cache.clear 之后)会返回 null,而共享类型与桌面端实现 均保证返回非空值,按类型声明编写的新调用方会在网页版首次进入页面或 cache.clear 后踩坑。 现与桌面端一致:有缓存时优先返回缓存,缓存为空时正常加载。
|
Claude finished @zsTree0830's task in 6m 9s —— View job 审查结论已完成对最新提交(
上一轮意见的复核
本轮发现的问题
仓库规则检查
范围提示(不影响合并)
验证说明
|
|
Claude finished @zsTree0830's task in 3m 22s —— View job 审查结论已复核 PR #18 的最新状态( 仓库规则全部符合,但上一轮提出的 4 个问题本轮仍未处理,已在对应 diff 行留下行内评论。
仍需处理的问题
已核对且未发现问题
范围提示(不影响合并)
验证说明本次为静态审查:工作区没有 |
| mail: { | ||
| list: async () => communityCall('GetMailList'), | ||
| get: async (otherUser: string) => communityCall('GetMail', { OtherUser: otherUser }), | ||
| send: async (toUser: string, content: string) => | ||
| communityCall('SendMail', { ToUser: toUser, Content: content }), | ||
| }, |
There was a problem hiding this comment.
网页版没有实现 bbs.readMention / mail.readMention。src/components/NotificationToasts.vue:48/53 在点击通知时会调用 markBbsMentionRead / markMailMentionRead,即 window.xmoj.bbs.readMention(mentionId);网页版这两个方法都不存在,属同步抛出的 TypeError,.catch() 接不到,于是 open() 中断、dismiss(notice) 不会执行,toast 不会消失,社区服务端也不会标记已读(刷新后会再次出现)。
functions/api/community.ts:12 已把 ReadBBSMention / ReadMailMention 加入白名单并校验 MentionID,只差客户端这两个方法。请补上:
readMention: async (mentionId: number) => communityCall('ReadBBSMention', { MentionID: mentionId }),
readMention: async (mentionId: number) => communityCall('ReadMailMention', { MentionID: mentionId }),| @@ -0,0 +1,3 @@ | |||
| /* | |||
There was a problem hiding this comment.
public/ 下只有 _headers,没有 _redirects 或 404.html。网页版用 history.pushState 写入真实路径(/contests/{id}、/problem/{id}、/discussion/{id},见 src/stores/web-route.ts 的 pathForWebRoute),README 也承诺「浏览器刷新、前进和后退会恢复对应视图」;但 Cloudflare Pages 找不到同名静态资源时会直接返回 404,所以直接打开或刷新 /contests/12 是 404,只有从 / 点进去才正常。
建议在本目录新增 public/_redirects(vite.web.config.ts 的 publicDir 会把该文件复制到 web-dist 根目录):
/* /index.html 200
Pages 会先匹配 functions/ 中的路由,/api/* 仍由 Pages Functions 处理;部署后请验证 /api/session、/api/home 未被回退规则覆盖,并确认刷新 /contests/12 能返回页面。
| }, | ||
| }, | ||
| home: { | ||
| snapshot: async (cacheOnly = false) => (cacheOnly && homeSnapshotCache ? homeSnapshotCache : loadHomeSnapshot()), |
There was a problem hiding this comment.
useCachedResource.loadCacheFirst()(src/composables/useAsyncResource.ts)会先 cached()、再无条件 fresh()。网页版在缓存为空时这里的 snapshot(true) 会走 loadHomeSnapshot() 发一次网络请求,等它 resolve 后 fresh() 又调用 loadHomeSnapshot();homeSnapshotRequest 的去重只覆盖并发请求,不覆盖这种先后调用,因此首次进入首页固定请求两次 /api/home,Home.vue 还会多一次无谓更新。
第 340 行的 monthly.board 同理,而且 Monthly.vue 的 load() 本身还会显式调用 fetchMonthlyBoard(true) 与 fetchMonthlyBoard(false),首次进入月赛同样两次请求。
建议给 homeSnapshotCache / monthlyBoardCache 加一个很短的新鲜窗口(例如 5–10 秒内直接复用,思路同 problemsetCache 的 PROBLEMSET_CACHE_TTL_MS),或让紧随其后的 fresh() 复用刚完成的请求。
| headers: { 'Cache-Control': 'no-store' }, | ||
| }); | ||
| } | ||
| return Response.json(await response.json(), { |
There was a problem hiding this comment.
这里把上游 JSON 原样转发,但上游字段是 createdBy,而桌面端 electron/judge-api.ts 会把它映射成 creator。网页版缺了这一步,导致 src/pages/Contests.vue:268 的「创建者」在网页版永远为空;functions/api/contest-detail.ts:67 的 contest: raw.contest 同理(对应 Contests.vue:363 的创建者)。
建议与桌面端保持一致:
const data = await response.json() as { list?: Array<Record<string, unknown>> };
const list = (data.list ?? []).map(contest => ({
...contest,
creator: contest.creator ?? contest.createdBy ?? null,
}));
return Response.json({ ...data, list }, {
headers: { 'Cache-Control': 'private, no-store' },
});详情接口至少也要补 creator: raw.contest.creator ?? raw.contest.createdBy ?? null。
|
好像忘记做readmention了
At 2026-11-18 23:24:42, "github-actions[bot]" ***@***.***> wrote:
@github-actions[bot] commented on this pull request.
In functions/api/contest-list.ts:
+ const authorization = await authorizeJudgeSession(request, env);
+ if ('response' in authorization) return authorization.response;
+ const upstreamUrl = new URL('/api/contest/list', XMOJ_ORIGIN);
+ upstreamUrl.searchParams.set('pageNum', rawPage);
+ try {
+ const response = await fetchUpstream(upstreamUrl, {
+ headers: { Accept: 'application/json', Cookie: `PHPSESSID=${authorization.session.sessionId}` },
+ signal: request.signal,
+ }, ['www.xmoj.tech', 'xmoj.tech']);
+ if (!response.ok || !response.headers.get('content-type')?.includes('json')) {
+ return Response.json({ error: '暂时无法读取比赛列表' }, {
+ status: 502,
+ headers: { 'Cache-Control': 'no-store' },
+ });
+ }
+ return Response.json(await response.json(), {
这里把上游 JSON 原样转发,但上游字段是 createdBy,而桌面端 electron/judge-api.ts 会把它映射成 creator。网页版缺了这一步,导致 src/pages/Contests.vue:268 的「创建者」在网页版永远为空;functions/api/contest-detail.ts:67 的 contest: raw.contest 同理(对应 Contests.vue:363 的创建者)。
建议与桌面端保持一致:
constdata=awaitresponse.json()as{list?: Array<Record<string,unknown>>};constlist=(data.list??[]).map(contest=>({
...contest,creator: contest.creator??contest.createdBy??null,}));returnResponse.json({ ...data, list },{headers: {'Cache-Control': 'private, no-store'},});
详情接口至少也要补 creator: raw.contest.creator ?? raw.contest.createdBy ?? null。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you were mentioned.Message ID: ***@***.***>
|

这个 PR 的目的是什么?
完善项目主页和全面的中文使用文档,并将静态站点发布方式调整为写入
github-pages分支。这个 PR 是如何实现的?
website/的全部静态内容构建并发布到github-pages分支;README 补充发布配置说明。你做了哪些验证?
git diff --check— 通过。ruby -e 'require "yaml"; YAML.load_file(".github/workflows/pages.yml")'— 工作流 YAML 解析通过。检查单
git rebase)