nomadro/apps/miniprogram/weapp/README.md
Eric 932f912087 Ship WeChat VIP↔Web bridge, netdisk sheet, and per-lesson materials gate for audit.
Freeze pre4 as the in-review weapp package; document pre5 as the next iteration branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-24 20:14:31 +08:00

56 lines
2.6 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.

# 微信 weapp
源码与 Taro H5 **共用** `../h5/src`(`sourceRoot: ../h5/src`)。
```bash
pnpm install
pnpm --dir apps/miniprogram/weapp build:weapp # 或根目录 pnpm build:weapp / dev:weapp
# 微信开发者工具打开本目录(读 dist/)
```
改页面请改 `apps/miniprogram/h5/src`,不要再复制一份 weapp/src。
## 首页路径
| 路径 | 说明 |
|------|------|
| **`pages/home/`** | **唯一首页源码**(启动页 / 话题 / 体验码) |
| `pages/index/` | 兼容旧路径:`reLaunch` → home(勿与 home 共用组件入口,否则无页面 wxss → 微信 ENOENT) |
`home/index.scss` 已进 `pxExclude`(真 px)。话题链接填:`pages/home/index`。
发版对照:视觉 `20261011` · 启动路径 `20261011b` · **审核包 `20261011-2`(已提交上线审核,分支 `pre4` 冻结)**。
下一轮迭代请切 **`pre5`**。
## 包体与代码质量
| 项 | 做法 |
|----|------|
| 主包 ≤1.5MB | `app.config.ts`:首页/我的留主包,其余 `subPackages`;`mini.optimizeMainPackage.enable` |
| 组件按需注入 | `lazyCodeLoading: "requiredComponents"` |
| 图片合计 ≤200K | 导航图标不进包,运行时 `https://nomadro.cn/icons/*.webp`(后台 download/图片域名放行 `nomadro.cn`) |
| 安全区 | `utils/safeArea.ts` → `safePx()` 大写 `PX`,避免内联被转 rpx |
| game 冷冻 | weapp 用 `index.weapp.tsx` stub(无 Three.js);H5 完整游戏 |
`scripts/copy-weapp-static.mjs`:清历史 `icons/`,只同步必要 `assets`(如公众号二维码)。
## VIP(原生页,禁止 web-view)
对齐门户 / nomadvip:`vip` 落地 · `vip-course` 专题 · `vip-lesson` 课时 · `vip-ebook` 电子书 · **`vip-memo` 知识社群** · **`vip-store` 设备商城** · **`vip-account` Web 账号打通**。
`config/index.ts` 对 VIP / 商城 / 社群 / LoginModal / NetdiskModal scss 走 **真 px/rem**(`pxExclude`),禁止照抄 Web 桌面弹窗尺寸。
| 页 | 说明 |
|----|------|
| `vip` | 落地;网盘下载弹窗;Web 打通开关开时「已有账号登录 / 绑定邮箱」 |
| `vip-account` | Web VIP 登录/绑邮箱(可被 Modal 覆盖,页仍保留) |
| `vip-lesson` | 原生 Video;资料区仅 `lessonMaterials[key]` 有 url 才显示 |
| `vip-memo` / `vip-memo-detail` | 知识星球风格;本地缓存秒开 |
| `vip-store*` | 虚拟卡 + 实物;微信收货地址 |
| `book` / `reader` | 数字游民小册;Youtube 笔记 `reader?id=default` |
电子书 / 课时内容从 `src/modules/vip/app/data` 抽取:
```bash
python apps/miniprogram/h5/scripts/extract-vip-ebooks.py
python apps/miniprogram/h5/scripts/extract-vip-lessons.py
```