init: consolidate all ephron.ren PRDs and docs

This commit is contained in:
Ubuntu
2026-05-15 10:39:54 +08:00
parent 9568533314
commit ee8cddf8b8
21 changed files with 6991 additions and 2 deletions

View File

@@ -0,0 +1,119 @@
# Bug 修复方案:集合编辑页面文章无法勾选
## 问题描述
**页面**`https://blog.ephron.ren/admin/collections/edit/{key}`
**现象**点击文章列表中的文章项checkbox 不会被勾选,已选文章区域也不会更新。
**影响范围**
- 集合编辑页面collection_edit.html— 无法勾选文章
- 集合新建页面collection_new.html— 同样受影响
- 集合管理列表页admin/collections.html— 同样受影响
---
## 根因分析
### 直接原因
`blog/templates/base.html` **缺少 `{% block extra_scripts %}` 定义**
### 详细分析
1. `collection_edit.html` 第 261 行声明了:
```html
{% block extra_scripts %}
<script>
(() => {
// 文章选择逻辑togglePost、renderSelected、拖拽排序等
})();
</script>
{% endblock %}
```
2. 但 `base.html` 的模板结构只有:
```html
{% block extra_styles %}{% endblock %} ✅ 存在
{% block content %}{% endblock %} ✅ 存在
{% block extra_scripts %}{% endblock %} ❌ 缺失
```
3. 由于 `base.html` 未定义 `extra_scripts` blockJinja2 **直接忽略**子模板中该 block 的内容,导致整个文章选择的 JavaScript 代码**根本没有被渲染到页面**。
### 对比其他服务
| 服务 | base 模板 | extra_scripts 定义 |
|------|----------|------------------|
| blog | `blog/templates/base.html` | ❌ 缺失 |
| prompt | `prompt/templates/base.html` | ✅ 已有 |
| auth | `auth/templates/_design_system/page_shell.html` | ✅ 已有 |
| canvas | `canvas/templates/base.html` | ✅ 已有 |
| home | `home/templates/_design_system/page_shell.html` | ✅ 已有 |
---
## 修复方案
### 修改文件
`blog/templates/base.html`
### 修改内容
在 `</body>` 标签前添加 `{% block extra_scripts %}{% endblock %}`。
**修改前**(第 663-664 行):
```html
</script>
</body>
</html>
```
**修改后**
```html
</script>
{% block extra_scripts %}{% endblock %}
</body>
</html>
```
### 完整 Diff
```diff
--- a/blog/templates/base.html
+++ b/blog/templates/base.html
@@ -661,5 +661,6 @@
});
});
</script>
+ {% block extra_scripts %}{% endblock %}
</body>
</html>
```
---
## 验证方法
1. 部署后访问 `https://blog.ephron.ren/admin/collections/edit/{key}`
2. 点击文章列表中的任意文章项
3. 预期checkbox 被勾选,文章出现在「已选文章」区域
4. 再次点击同一文章
5. 预期checkbox 取消勾选,文章从「已选文章」区域移除
6. 点击「保存更新」
7. 预期:页面刷新后,之前勾选的文章仍然显示在「已选文章」区域
---
## 影响评估
- **风险等级**:低(纯新增 block 定义,不影响现有逻辑)
- **影响范围**blog 服务所有使用 `extra_scripts` block 的页面
- **回滚方案**:删除添加的一行即可
---
## 优先级
**高** — 集合编辑功能完全不可用,需要立即修复。