feat: 前端迁移 React 18 + Vite 5 脚手架与保真移植的控制器

为什么:index.html 单体 4600 行 ES5 已到维护极限,迁移到 Vite 工程
获得热更新、类型检查与模块化能力。迁移策略是保真优先——业务逻辑
不重写为 React 组件(行为漂移风险),而是逐字移植为
legacy.ts/auth.ts 两个 @ts-nocheck 控制器模块;React 只接管静态
骨架与响应式显隐(tab/modal/drawer/toast),动态列表/播放器/歌词
仍走 id + innerHTML 命令式更新。

关键决策:
- boot 包装:旧脚本原在 body 末尾可直取 DOM,模块化后顶层事件
  绑定会在 import 求值时打在 null 上,全部副作用包进
  __legacyBoot()/__authBoot() 由 App useEffect 骨架落盘后调用
- 轻量 store:单一可变 AppState + notify() + useSyncExternalStore,
  沿用旧版"改 state 后手动通知"心智模型
- modalBus:弹窗栈 + useSyncExternalStore,Escape 走 closeTopmost,
  stats/cookie 弹窗经 __legacyApi 调 legacy 内部专用关闭(清定时器/
  复位视图)
- vite 固定产物文件名(无内容 hash),保证 index.html 字节级稳定,
  golden sha256 契约才跨构建成立
This commit is contained in:
snowy-yang committed 2026-09-27 18:34:49 +08:00
1 parent 0dbbb3ed63
commit 3a089caff2
15 files changed
+11089

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E%F0%9F%8E%B5%3C/text%3E%3C/svg%3E"
/>
<title>云村小助手</title>
</head>
<body>
<div id="root"></div>
<script>
window.__errs = []
window.addEventListener('error', function (e) {
window.__errs.push((e.message || String(e)) + ' @ ' + (e.filename || '?') + ':' + e.lineno)
})
window.addEventListener('unhandledrejection', function (e) {
window.__errs.push('PROMISE: ' + ((e.reason && e.reason.message) || String(e.reason)))
})
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>