Repository navigation
refactor(web): split index.html into html/css/js with static asset routes - #56
Merged
Merged
Conversation
…utes web/index.html 单文件 2973 行 / 132 KB,三种语言挤在一起:编辑器支持 失效、diff 噪音大、JS 内部早已有清晰分节注释却没有文件边界。 拆分与下发(上游 issue IRmsk#54 的方案 B): - index.html 保留骨架(250 行),<link href="/console.css"> + 6 个按原分节顺序排列的 <script src="/js/*.js"> - console.css + js/{core,generate,map,draw,records,boot}.js 经 web/mod.rs 的 STATIC_ASSETS 静态路由下发,与外链 unpkg 的 Leaflet 同一加载模式;respond_html 合并为 respond_static(带 Content-Type) - 静态路由只拦 GET,与首页同级公开(内容此前就随 / 公开),沿用 no-store 缓存语义 行为等价性: - 拆分是纯按行切割:拼接结果与原文件 cmp 字节级一致 - 经典 script 按文档顺序执行且共享全局词法作用域,与原单 <script> 内联语义等价,JS 逻辑零改动(仅各文件头一行来源注释) - 新测试 skeleton_asset_references_and_routes_agree 双向钉住骨架 引用与路由表(忘接线/死路由都红);其余前端断言按文件归属分流 验证:cargo fmt/clippy 干净,web 27 项 + 全量测试通过;起服冒烟, 7 个静态资源响应与源文件逐字节一致,未知路径与 POST 落 404。 References IRmsk#54(IRmsk/pace-forge)。
AptS-1547
force-pushed
the
refactor/web-console-split
branch
from
November 26, 2026 16:10
4206738 to
9bfc8ec
Compare
Owner
|
合了,谢谢。 我在本地把拆出来的文件拼回去和原文件比过,除了你加的几行来源注释,逐字节一致;起了个 你长期那条(要不要上 ES module)我记下了,等前端真长到需要的时候再说。 |
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 #54 (delivers Option B — static asset routes, per the issue's recommendation)
What
src/web/index.htmlwas a single 2973-line / 132 KB file mixing HTML, CSS, and JS. This PR splits it by language and serves the parts through local static routes instead of re-inlining them:index.htmlkeeps only the skeleton (250 lines):<link href="/console.css">plus six<script src="/js/*.js">tags in the original section orderconsole.cssandjs/{core,generate,map,draw,records,boot}.js— cut strictly along the file's own existing section markers, zero logic changesweb/mod.rs:STATIC_ASSETStable (path, content, content-type) as the single asset list;respond_htmlgeneralized torespond_static; static routes are GET-only, public like/, and keep the sameno-storecache semanticsskeleton_asset_references_and_routes_agreepins the wiring both ways (skeleton references ↔ route table): a missing route or a dead route both turn redWhy this is behavior-preserving
cmp(before adding the one-line source comments)<script src>tags execute in document order and share the global lexical scope — semantically identical to the previous single inline<script>; top-levelconst/letvisibility and thecore.js → … → boot.jsreference order are unchangedrespond_htmlsets no CSPVerification
cargo fmt --check/cargo clippy --all-targets: cleancargo test: full suite green (27 web-module tests, incl. the new wiring test); the one pre-existing failureapi::accounts::tests::key_sources_fall_back_past_the_posix_defaultsalso fails on a clean checkout on macOS and is unrelatednode --checkon each split js file: syntax-valid standalonepace-forge web:/→ 200text/htmlwith all 7 references; all 7 assets → 200 with correct content types andno-store; each served response byte-identical to its source file (cmp); unknown asset path → 404;POST /js/core.js→ 404 (static interception is GET-only)