feat:完成首页、分类页内容管理功能开发
This commit is contained in:
+40
-14
@@ -125,30 +125,44 @@ type PageContentUpdatePayload = {
|
||||
|
||||
### 3.1 管理 UI
|
||||
|
||||
首页管理 tab 分为四个区块:
|
||||
首页管理页分为以下区块:
|
||||
|
||||
|
||||
| 区块 | 对应字段 | 管理方式 |
|
||||
| ------ | -------------- | ----------------------------------- |
|
||||
| 分类 tab | `categoryTabs` | 跟随 `CATEGORY_LIST_WITH_ALL`,一般不单独管理 |
|
||||
| 年龄入口 | `ageBands` | 跟随 `AGE_BANDS`,可管理描述文案 |
|
||||
| 今日推荐 | `featured` | 手动选择 3-5 个 active worksheet |
|
||||
| 热门推荐 | `hot` | 手动选择或按 downloads 自动生成 |
|
||||
| 今日推荐 | `featured` | 自动取 downloads 最多的 5 个 active worksheet,支持手动微调 |
|
||||
| 热门推荐 | `hot` | 自动取 likes 最多的 5 个 active worksheet,支持手动微调 |
|
||||
| 分类分区 | `sections` | 每个分类选择若干 active worksheet,支持排序 |
|
||||
|
||||
|
||||
交互流程:
|
||||
### 3.2 自动刷新与定时任务
|
||||
|
||||
今日推荐和热门推荐采用**自动化 + 手动微调**的方式:
|
||||
|
||||
- **默认数据**:页面加载时自动查询 active worksheets,按 `downloads desc` 取前 5 填入 featured,按 `likes desc` 取前 5 填入 hot
|
||||
- **定时任务**:云函数 `homeAutoRefresh` 配置定时触发器,每日 22:00 自动执行,查询最新 top5 数据更新 `page-config.json` 中的 `home.featured` 和 `home.hot`
|
||||
- **开关控制**:通过 `settings` 集合中 `homeAutoRefresh` 文档的 `enabled` 字段控制。管理页提供暂停/启动按钮,调用 `homeTimerControl` 云函数切换状态。`homeAutoRefresh` 执行时先检查此标记,`enabled === false` 则跳过
|
||||
- **手动微调**:用户可在自动填充的基础上手动添加/移除 worksheet,点击「更新首页数据」手动生成
|
||||
|
||||
```
|
||||
首页 tab 展示当前配置
|
||||
→ 每个位置点击「选择内容」
|
||||
→ 弹出 worksheet 选择器(筛选 active 内容)
|
||||
→ 保存配置
|
||||
→ 点击「更新首页数据」
|
||||
→ 调用 pageContentUpdate({ page: 'home', data: ... })
|
||||
管理页 onLoad
|
||||
→ 查询 active worksheets
|
||||
→ 按 downloads desc 取前 5 → featured
|
||||
→ 按 likes desc 取前 5 → hot
|
||||
→ 用户可手动微调
|
||||
→ 点击「更新首页数据」→ pageContentBuild({ page: 'home', ... })
|
||||
|
||||
定时任务(每日 22:00)
|
||||
→ homeAutoRefresh 云函数
|
||||
→ 检查 settings/homeAutoRefresh.enabled
|
||||
→ 查询 top5 downloads → featured
|
||||
→ 查询 top5 likes → hot
|
||||
→ 更新 page-config.json 中 home.featured 和 home.hot
|
||||
```
|
||||
|
||||
### 3.2 数据结构
|
||||
### 3.3 数据结构
|
||||
|
||||
```ts
|
||||
type HomePageData = {
|
||||
@@ -168,11 +182,21 @@ type HomePageData = {
|
||||
| -------------- | ---------------------------------------------- |
|
||||
| `categoryTabs` | 由 `CATEGORY_LIST_WITH_ALL` 生成 |
|
||||
| `ageBands` | 由 `AGE_BANDS` 生成 |
|
||||
| `featured` | 优先使用手动选择,不足时补 `isNew == true` |
|
||||
| `hot` | 优先使用手动选择,不足时补 `isHot == true` 或 downloads 高的内容 |
|
||||
| `featured` | 自动:downloads 最多的 5 个 active worksheet |
|
||||
| `hot` | 自动:likes 最多的 5 个 active worksheet |
|
||||
| `sections` | 使用配置中的 worksheetIds,不足时从该分类 active 内容补齐 |
|
||||
|
||||
|
||||
### 3.4 相关云函数
|
||||
|
||||
|
||||
| 云函数 | 职责 |
|
||||
| ------------------- | ------------------------------------------- |
|
||||
| `pageContentBuild` | 手动更新首页全量数据(featured + hot + sections) |
|
||||
| `homeAutoRefresh` | 定时任务,每日 22:00 自动更新 featured 和 hot |
|
||||
| `homeTimerControl` | 暂停/启动定时任务(更新 settings 集合标记位) |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 四、分类页内容管理
|
||||
@@ -445,7 +469,9 @@ supportPages/debug/debug
|
||||
| 文件 / 模块 | 职责 |
|
||||
| ----------------------------------- | ------------------------------ |
|
||||
| `supportPages/contentManage/` | 三 tab 内容管理页 |
|
||||
| `cloudfunctions/pageContentUpdate/` | 更新 `page-config.json` 中指定页面的配置 |
|
||||
| `cloudfunctions/pageContentBuild/` | 生成 `page-config.json` 中指定页面的配置 |
|
||||
| `cloudfunctions/homeAutoRefresh/` | 定时任务,每日自动更新首页推荐位数据 |
|
||||
| `cloudfunctions/homeTimerControl/` | 暂停/启动首页定时刷新任务 |
|
||||
| `pages/age/age.config.ts` | 分龄页兜底配置(年龄段、能力目标、默认 worksheet) |
|
||||
| `pages/home/home.data.ts` | 首页兜底数据 |
|
||||
| `pages/category/category.data.ts` | 分类页兜底数据 |
|
||||
|
||||
Reference in New Issue
Block a user