nomadro/apps/miniprogram/tt/README.md
eric 534400f554 Merge stash WIP onto BMI A/B: join-group, live config, channel tracking.
Keep Douyin homeVariant BMI router intact while restoring admin join-group controls, TLS-safe config fetch, and ntfy channel labels.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 15:42:09 +08:00

91 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Nomadro 抖音小程序(独立目录)
与微信(`../src/`)、小红书(`../xhs/`)**分目录开发,互不影响**。
| 项 | 值 |
|---|---|
| AppID | `tt995defe007255b2701` |
| 源码 | `src/` |
| 产物 | `dist/`(gitignore;本地 `pnpm build` 生成) |
| 工程配置 | `project.tt.json`(`miniprogramRoot: ./dist/`) |
| TabBar | **无** |
| 首页 | **A/B**:默认 `homeVariant=bmi`(BMI 健康管理过审);后台可切 `hub` 正式门户 |
| 支付 | 默认关闭 / 离线免费(无微信虚拟支付) |
| 隐私 | `usePrivacyCheck: true`(官方隐私弹窗) |
官方文档:
- [使用指南](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/introduction/usage-guide)
- [隐私协议配置](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/open-capacity/basic-capacities/privacy-agreement)
- [隐私协议开发](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/tutorial/security-requirements/privacy-authorize)
- [`tt.showModal`](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/interface/interfeedback/tt-show-modal)(按钮文案 ≤4 字)
- [`tt.setClipboardData`](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/device/pasting-board/tt-set-clipboard-data)
## 开发
```bash
cd apps/miniprogram/tt
pnpm install
pnpm dev # webpack5 watch → dist/
pnpm build # 生产构建 + copy-static + validate:size
```
伞仓:`pnpm --dir apps/miniprogram/tt build` / `pnpm build:tt`。
抖音开发者工具:**打开本目录 `tt/`**(读 `project.tt.json` → `dist/`)。
## 导航复制外链(剪切板)
小程序不能直接打开外链。流程按官方:
1. 点击卡片 → **`tt.showModal`**(「复制」/「关闭」,callback,不 await 隐私查询)
2. 确认 → **`tt.setClipboardData`**
3. **不要**注册 `tt.onNeedPrivacyAuthorization` → 由**官方隐私弹窗**授权(`usePrivacyCheck: true`)
4. `showModal` 失败时才用自定义底栏兜底
### 后台必须声明剪切板(否则报 10202 / 104179)
**不在**「开发配置 → Webhook」。路径:
**设置 → 基础设置 → 类目与配置 → 用户隐私保护协议 → 去完善**
→ 涉及收集个人信息 → **添加信息类型 → 剪切板**
→ 用途例:`复制导航外链,供用户到浏览器打开` → 填联系方式 → 预览 → **确定并生成协议**
## 电子书(离线 hackrobot)
| 项 | 约定 |
|---|---|
| 正文 | `src/data/nomadCodeBook.ts` · 41 章 |
| 生成 | 伞仓 `pnpm pack:hackrobot-book` |
| 配图 | `/packageBook/assets/book-images/*.webp`(包内全量,勿用「配图已省略」占位) |
| 运行时 | `FORCE_OFFLINE_BOOK`,不拉线上旧目录 |
| 阅读 | **连续竖滑**:首屏渐进挂载章节(避免一次解析 41 章卡死);目录跳章 `ensureMountedThrough`;全书挂完才出「全书读完」 |
| 滚动 | 目录跳转只用短回钉;用户滑离即停 `pageScrollTo`;跳章锁定期勿增章(否则会抖回封面) |
| 过审 | 默认 BMI 首页(健康管理类目);后台 `homeVariant=hub` 切回门户;门户默认隐藏「出海导航」;小册正文不嵌公众号二维码;加群由 `joinGroupWechat`/`joinGroupDouyin` 开关决定;「稍后再说」仅关闭弹窗 |
## 包体积(官方)
| 项 | 上限 |
|---|---|
| 主包 | ≤ 4MB |
| 单个分包(`packageBook`) | ≤ 2MB |
| 全部合计 | ≤ 16MB |
构建结束自动 `copy-static` + `validate:size`。
## 验收
1. [ ] 导入 `tt/`,AppID 正确;`pnpm build` 后预览 `dist/`
2. [ ] **过审默认**:首页为 BMI 健康管理(身高/体重/结果/本地记录);无门户入口
3. [ ] 后台将 `homeVariant` 切为 `hub` 后,首页变为门户(导航/小册/社群按开关)
4. [ ] 门户:红标 logo;顶栏避开状态栏;导航复制外链正常
5. [ ] 小册可连续上下滑;目录跳章后上下滑**不会**弹回封面 / 原地抖
6. [ ] 目录可立刻点;章内无「下一章」条;配图正常显示
7. [ ] 断网仍可打开小册;`validate:size` 通过(`packageBook` ≤2MB)
## 禁止
- 勿改上级 `src/` / `xhs/` 来编抖音
- 勿把 `tt/node_modules`、`tt/dist` 提交进 Git