-
Data Governance Dev authored
背景(按踩坑时间线): 1. start.py 用 print("✓ 关键依赖齐全"),Windows 默认 GBK console 抛 UnicodeEncodeError, 整个启动流程在 09:45 死在第一行 2. app.py main() 函数引用 LOG_DIR 但没 import,跑 main() 直接 NameError; 之前走 uvicorn 启动不跑 main() 所以没暴露 3. 浏览器访问 http://localhost:8766/#/id-card 时页面空白 —— FastAPI 对 SPA 路由(hash 路由 path 是 /,history 路由会触发 404)没有兜底,Vue Router 没机会接管 改动: - start.py:入口处 sys.stdout.reconfigure(encoding='utf-8', errors='replace'); ✓ → [OK],✗ → [FAIL](Windows GBK 永远安全) - app.py:同上加 stdout reconfigure;从 _logging 多 import LOG_DIR; 加 @app.exception_handler(404) 做 SPA fallback: · /api/* 404 → JSON(前端 fetch 期待 JSON) · 其他路径 404 → dist/index.html(让 Vue Router 接管) 顺手: - CLAUDE.md 加规则:「永远不要使用数据操作语句,本工具只做查询!」 验证: - start.py 启动不再因为 ✓ 崩 - GET /id-card 现在返回 200 + index.html(之前 404) - GET /api/nonexistent 仍返回 404 JSON 踩坑见 work-logs/2026-08-17.md 第五、七章。97a82545