docs: update CODEBASE.md — fix index.html architecture, add OpenResty cache notes
This commit is contained in:
11
CODEBASE.md
11
CODEBASE.md
@@ -136,8 +136,8 @@
|
||||
|
||||
## ⚠️ 已知问题 & 注意事项
|
||||
|
||||
### 1. `index.html` vs `index_template.html` 双胞胎
|
||||
两个文件内容几乎相同。`index_template.html` 是早期版本,被 `extract_data.py` 引用但路径硬编码为 `/app/working/workspaces/default/llm_library.html`。**实际服务的是 `index.html`。** 如果改前端 HTML 结构,只需改 `index.html`。
|
||||
### 1. `index.html` vs `index_template.html` (2026-06-09 已修复)
|
||||
**已修复:** `index.html` 原来包含 286 行内联 JS,导致 `app.js` 的修改完全不生效。已改为 `<script src="/app.js?v=20260609"></script>`,HTML 和 JS 完全分离。`index_template.html` 保持为早期模板(也引用外部 script),用于备用。
|
||||
|
||||
### 2. MyMemory 免费翻译 vs pdf2zh
|
||||
`GET /api/translate/{arxiv_id}` 用的是 MyMemory 免费 API(质量一般),而真正的翻译是通过 `POST /api/translate/{paper_id}` 触发 pdf2zh + DeepSeek(生成中文 PDF)。两者是不同的翻译通道,不要混淆。
|
||||
@@ -151,7 +151,12 @@
|
||||
### 5. 搜索实现(2026-06-09 已修复)
|
||||
搜索已在 2026-06-09 升级为**实时下拉结果面板**。输入 ≥2 字符后,200ms debounce 后调用 `/api/papers?q=`,在下拉面板中显示匹配论文(标题高亮、模块/领域、年份、标签)。卡片同步绿框高亮。点击结果项跳转到对应模块弹窗。点外部或 Escape 关闭。
|
||||
|
||||
### 6. 数据一致性
|
||||
### 6. OpenResty 缓存问题
|
||||
宿主机 Nginx/OpenResty(1Panel 管理,容器名 `1Panel-openresty-mHac`)可能缓存静态文件响应。已通过 FastAPI 中间件添加 `Cache-Control: no-cache, no-store, must-revalidate` 头来阻止。如果仍有缓存问题,运行:
|
||||
```bash
|
||||
docker restart 1Panel-openresty-mHac
|
||||
```
|
||||
另外,`app.js` 和 `style.css` 的引用使用了版本号查询参数(`?v=20260609`),修改后递增版本号即可绕过所有缓存。
|
||||
`papers.json` 是唯一数据源。新增论文通过 API 写操作 → 自动更新 JSON → 前端下次请求时自动获取最新数据。**不要手动编辑 production 上的 papers.json 绕过 API**,可能导致并发写入问题。
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user