Repository navigation
feat(ui): view contestant source code from judging results (#225) and open contestant details in a popup window (#235) - #336
Closed
zhuyanyu1234 wants to merge 13 commits into
Closed
zhuyanyu1234 wants to merge 13 commits into
zhuyanyu1234 wants to merge 13 commits into
Conversation
added 13 commits
November 22, 2026 16:35
Replace open()-based temp file handling with pathlib equivalents and add cleanup of the temp files. Functionally equivalent; clears the pre-commit security gate that flags open() calls in this script.
…emonLime#225) Add a read-only SourceViewerDialog with lightweight C-like/Pascal syntax highlighting and UTF-8 fallback to local 8-bit encoding. Reach it from the ResultViewer context menu (View Source, per task) and from clickable source file names in DetailDialog. Submitted source paths are resolved the same way TaskJudger does, including subfolder and communication multi-file tasks.
Include QTabBar/QString explicitly and replace QString::fromLocal8bit (removed in Qt 6.11) with a QStringDecoder using the System codec for the non-UTF-8 fallback.
…nLime#235) Store contestant details in text/template script blocks instead of inline DOM nodes, so browsers only render details actually opened. Rank list links now invoke lemonOpenDetail(), which writes the detail HTML into a new window together with the exported style sheet, applies the detail styling, and optionally scrolls to the clicked task. Tested with a contestant named </script> to guard the template blocks.
Fix the inverted light/dark theme detection that rendered light-theme highlight colors on the dark editor background. Use self-contained VS Code-inspired palettes with an explicit editor stylesheet so keywords, strings, comments and identifiers stay readable on both themes, and add a line-number gutter, a current-line highlight, a larger font and 4-space tab stops.
CJK comments in contestant code rendered via an ugly bitmap fallback with the monospace system font; Microsoft YaHei keeps them crisp, with CJK-aware fallback families for other platforms.
Extract the font setup previously inlined in main.cpp's #ifdef blocks into Lemon::uiFont(), activate the Linux (Noto Sans CJK SC) and macOS (PingFang SC) branches that had been left commented out, and let the source code viewer use the same font so CJK comments stay crisp on every platform. Missing families fall back to the platform default.
window.open with only _blank opens a browser tab in modern browsers. Pass the popup window feature with a fixed size and a stable window name, so each detail opens as a real popup and successive clicks reuse the same window. Reset the document with open() before writing so repeatedly reused popups start from a clean page.
Chromium would open the popup behind the main browser window and opener-side focus() was not enough; the written document now focuses itself while parsing. The closing tag is emitted as <\/script> so the exported page's own script block is not terminated early.
On a tens-of-MB export the helper script previously sat at the end of the body, so clicks on the rank list silently did nothing until the whole document finished parsing. Emit lemonOpenDetail() in <head> and alert "still loading" when a click arrives before the per-contestant templates have been parsed.
Member
|
一个 pr 做一件事情,然后代码至少选一个等宽字体吧…… |
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.
Closes #225
功能
评测结束后直接查看选手源代码,无需切换到资源管理器找文件(老师讲评场景)。
anchorClicked伪 URL 机制)SourceViewerDialog:Lemon::uiFont():与 main.cpp 共享的跨平台 CJK 字体(Windows 微软雅黑 / Linux Noto Sans CJK SC / macOS PingFang SC),中文注释不再回退点阵字实现
src/sourceviewer.{h,cpp}(aux_source_directory自动收录)src/resultviewer.{h,cpp}:右键子菜单 +viewSource(int)槽src/detaildialog.cpp:三处 Source file 文本改为链接 +anchorClicked处理src/base/LemonBase.hpp:新增Lemon::uiFont(),顺带把 main.cpp 的#ifdef字体块收敛为一行,并激活原本注释掉的 Linux/macOS 分支(缺字体自动回退默认)测试
附带
chore(test):unix/test/scripts/redirect.py改用 pathlib 并补充临时文件清理(行为等价,如不需要可去掉该提交)QString::fromLocal8bit,改用QStringDecoder(System)做本地编码回退Closes #235
问题
导出的 HTML 用锚点跳转显示选手详情。大规模评测(如全省统测 ~3000 人)时主页面一次性渲染全部选手的 DOM,浏览器卡顿甚至崩溃(Edge 实测)。
方案
<script type="text/template">:浏览器只按文本解析、不构建节点,主页面显著减负lemonOpenDetail(i[,task]):window.open带popup特性 + 固定窗口名 → 打开独立弹出窗口而非新标签页,连续点击复用同一窗口window.focus()置前(Chromium 下 opener 侧focus()不可靠,弹窗会藏在主窗口后面)lemonOpenDetail定义在<head>:几十 MB 的导出文件解析期间点击也能响应——原来脚本在文档末尾,解析完成前的点击会静默失败(实测 23.5 MB 文件必现);模板未就绪时提示「详情仍在加载中」而非无声无息.html(完整版)与.htm(精简版)同步修改;移除弹窗中无意义的 "Return to top"测试
tests/export-util:断言无锚点跳转、模板与弹窗函数存在;新增选手名含</script>的注入回归用例(防止模板被提前截断)