Skip to content

完善首页布局、侧栏和个人主页 - #13

Closed
PythonSmall-Q wants to merge 3 commits into
devfrom
copilot/feature-left-sidebar-display
Closed

PythonSmall-Q wants to merge 3 commits into
devfrom
copilot/feature-left-sidebar-display

Conversation

@PythonSmall-Q

@PythonSmall-Q PythonSmall-Q commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

未经人工测试

这个 PR 的目的是什么?

改善首页信息布局和导航侧栏体验,让讨论通知直达帖子,并补充个人主页的评分与统计图表。

这个 PR 是如何实现的?

  • 首页与侧栏:首页改为桌面双栏、窄屏单栏;新增侧栏常驻切换并保存状态,缩短侧栏动画。
  • 讨论通知:通知保留帖子编号和页码,点击“查看”直接打开帖子详情。
  • 个人主页:解析判题统计和每日提交数据,展示评分、判题结果分布及提交趋势。
  • 未缓存代码:不再把 not-cached 当作源代码显示,并提示代码暂不可查看。测试点详情展示尚未实现。

你做了哪些验证?

  • npm run typecheck
  • npm run test:native-views、npm run test:e2e-readiness
  • 离线测试:npm test、test:cache、test:async-resource、test:poller、test:markdown
  • npm run build:dir
  • CodeQL:未发现告警

检查单

  • 我已测试过我的更改;
  • 如果日后出现与该更改相关的问题,我愿意协助维护该更改;
  • 我确认有权提交这些内容,并同意其按照本项目的 GPL-3.0 许可证发布;
  • 我已压缩任何不重要的提交;(git rebase)
  • 我已确认没有其他与此目的重复的 PR;
  • 我已考虑并确认此提交对他人有价值;
  • 我接受此提交可能不会被采用,且维护者有权关闭此 PR。

Copilot AI and others added 3 commits October 25, 2026 05:47
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
@claude

claude Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Claude finished @PythonSmall-Q's task in 3m 20s —— View job


PR 审查:完善首页布局、侧栏和个人主页

  • 读取仓库约定与项目配置(无 CLAUDE.md,按仓库规则检查)
  • 查看 PR 完整 diff(基于 origin/dev)
  • 分析改动文件:electron/profile.ts、electron/sources.ts、侧栏组件、Home/UserProfile/Discussion 等
  • 检查仓库特定规则(无注释、原生页面、主进程 HTTP、CACHE_VERSION)
  • 提交审查意见(含行内评论)

总体评价

方向不错:首页改为双栏信息密度更合理,个人主页补上了判题统计/趋势,侧栏常驻状态能持久化,Discussion 也能从通知直达帖子。整体代码风格与现有实现一致,没有引入新依赖。

不过有 1 个功能性 bug 和 1 个统计逻辑错误,建议修复后再合并。

主要问题

1. [高] 已在讨论页时,点击 BBS 通知无反应,并残留过期 target
src/pages/Discussion.vue:219 只在 onMounted 消费一次 discussionTarget;而 src/App.vue:73 用的是 v-else-if="view === 'discussion'",当 currentView 从 'discussion' 再赋值为 'discussion' 时组件不会重新挂载,通知点击静默失效。target 还会留在 store 中,之后切换页面再回来时被意外消费。
详见行内评论。

2. [中] 失败次数漏掉编译错误
electron/profile.ts:47 用 result >= 5 && result <= 10 统计失败,但 electron/parsers.ts:392 中 11 是 Compile Error,导致评分里的成功率被高估。建议改为 <= 11(仍排除 0–3 的 pending)。

3. [中低] Ctrl+B 会隐式把侧栏设为“常驻”
setOpen 新增默认参数 persist = true,而 toggleSidebar() 走的是默认值,因此键盘快捷键每次切换都会写入 pinnedOpen 与 localStorage,与悬停展开(persist = false)语义不一致。请确认是否为预期。

4. [低] 首页右栏为空时仍占位
src/pages/Home.vue:161 的右列无条件渲染;当倒计时与服务公告都为空时,左侧内容被限制在 1.4fr,右侧留大片空白。

5. [低] 饼图配色重复定义
src/pages/UserProfile.vue:54 与模板 :178 各写了一份颜色数组,建议提取常量。

其他建议

  • UserProfile.vue:142 展示的“评分”是本地启发式计算结果(calculateRating),并非站点官方数据,建议标注为“综合评分(本地估算)”或加 tooltip,避免误解。
  • 本 PR 标注“未经人工测试”。新增的 tests/native-views.ts 用例使用的是构造 HTML/假响应,只能保证解析函数按假设工作,无法验证真实 userinfo.php 的 #statics 结构、d1/d2.push 写法与 $("#submission") 选择器。建议补充一次真实页面的联调(或增加 test:live-* 类用例)后再合并。
  • parseActivity 只识别 $.plot($("#submission")...) 所在脚本中的 dN.push([ts,count]);若站点改为数组赋值或其他 series 名称,数据会静默为空且无提示。

仓库规则检查

  • ✅ 无新注释:diff 中新增行没有注释/JSDoc,且本次还删除了 Home.vue 中的若干旧注释。
  • ✅ 原生页面:未新增 <webview>、window.open、target="_blank" 或 shell.openExternal。
  • ✅ 主进程 HTTP:getsource.php / userinfo.php 的读取仍在 electron/ 主进程完成,渲染进程未新增 fetch。
  • ✅ CACHE_VERSION:UserProfile 虽然新增了字段,但 profile: 不在 electron/cache.ts:13-22 的 PERSISTED_PREFIXES 中,不会被写入磁盘,因此没有改变持久化 payload 形状,无需提升版本号。

验证说明

本环境未安装 node_modules,npm ci 需要审批且被拒绝,因此未能运行 npm run typecheck 与 npm run test:native-views。以上结论基于静态阅读;建议在本地/CI 补齐类型检查与上述测试。

@zsTree0830

Copy link
Copy Markdown
Member

@PythonSmall-Q 欸我刚说要开始改 PR 怎么就交过来了()

Comment thread src/pages/Discussion.vue
await loadPosts();
const target = navigation.consumeDiscussionTarget();
if (target)
await openThread(target.postId, target.page);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里只在 onMounted 时消费一次 discussionTarget,但 App.vue 是用 v-else-if="view === 'discussion'" 渲染 Discussion 的:当用户已经停留在讨论页(比如正在看另一个帖子)时,点击 BBS 通知只会把 currentView 重新赋值为 'discussion',组件不会重新挂载,onMounted 不会再执行,因此点击“看起来没反应”。

更糟的是 target 会留在 store 里,等用户先切到别的页面再切回讨论页时被消费,意外打开之前那条通知对应的帖子。

建议把 pending target 以响应式 ref 暴露出来,在 Discussion 内 watch 并在消费后清空;或者让 openDiscussion 通过已注册的 handler 直接调用 openThread,而不是依赖挂载时机。

Fix this →

Comment thread electron/profile.ts
const acceptedTotal = findCount(rows, /^(正确|通过|accepted)$/i);
const solved = solvedTotal ?? problems.length;
const failures = stats
.filter((entry) => entry.result >= 5 && entry.result <= 10)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

electron/parsers.ts:392 里 11 对应的是 Compile Error。这里的 >= 5 && <= 10 会把编译错误排除在失败数之外,导致 calculateRating 里的成功率偏高(把 CE 当成了成功提交)。若意图是统计所有非 AC 的终态,区间应改为 <= 11,同时继续排除 0–3 的 pending 状态。

Fix this →

Comment on lines +37 to +40
function setOpen(value: boolean, persist = true) {
open.value = value;
if (persist) {
pinnedOpen.value = value;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setOpen 的默认 persist = true 会隐藏一个行为变化:toggleSidebar()(Ctrl+B 快捷键)调用的是 setOpen(!open.value),于是每按一次快捷键都会把 pinnedOpen 改成当前状态并写入 localStorage。结果是用快捷键“打开”侧栏会变成永久常驻,和悬停展开时显式传 false 的行为不一致(Sidebar.vue:43 等处)。

如果快捷键只应切换显隐,应传 false;如果确实想让 Ctrl+B 设置常驻,请确认这是预期产品行为,并考虑在代码或 UI 上说明。

Comment thread src/pages/Home.vue
class="absolute top-2 right-2 size-4 text-foreground opacity-0 drop-shadow transition-opacity group-hover:opacity-100"
/>
</button>
<div class="space-y-6">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

右侧列会始终渲染,即使 countdown 和 notice 都为空。此时网格仍是 1.4fr / 1fr,左侧内容只占约 58% 宽度,右边留出一整块空白。建议给这一列加 v-if="countdown.length > 0 || notice",或在两者皆空时退化为单列布局。

Comment thread src/pages/UserProfile.vue
const total = stats.reduce((sum, item) => sum + item.count, 0);
if (total === 0)
return '';
const colors = ['#f87171', '#818cf8', '#4ade80', '#f472b6', '#c084fc', '#a8a29e'];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这套颜色在 resultPie 里定义了一次,模板图例(UserProfile.vue:178)里又原样写了一遍,并各自 % 6。后续调整配色时很容易只改一处导致饼图与图例不一致。建议提取为一个模块级常量,或让 resultPie computed 一并返回 colors。

@PythonSmall-Q

Copy link
Copy Markdown
Member Author

@zsTree0830 你自己修吧我要去学校上课了

@zsTree0830

Copy link
Copy Markdown
Member

算了等下我把我写的传上来
这个 PR 修的东西不够多
很多功能都有 Bug

@zsTree0830 zsTree0830 closed this Oct 25, 2026
@zsTree0830
zsTree0830 deleted the copilot/feature-left-sidebar-display branch October 26, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants