nomadro/apps/miniprogram/weapp/README.md
Eric 017008dd7c Harden weapp/API P0 paths: VIP auth, ebook login, WAL limits, game stub.
Drop Three from weapp game, mount VIP library on unified API, and auto-enable local debug without manual .env.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 19:06:50 +08:00

52 lines
2.3 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`。
发版对照:视觉标准 tag `20261011`;启动路径本轮 tag `20261011b`。
## 包体与代码质量
| 项 | 做法 |
|----|------|
| 主包 ≤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` 设备商城**。
`config/index.ts` 对 VIP / 商城 / 社群 scss 走 **真 px**(`pxExclude`),避免 `designWidth:750` 把字号压成一半。
| 页 | 说明 |
|----|------|
| `vip-memo` / `vip-memo-detail` | 知识星球风格:精华/收藏/Markdown;本地缓存秒开 + 静默刷新 |
| `vip-store` / `vip-store-detail` / `vip-store-orders` | 虚拟卡 + 实物;微信收货地址 |
| `book` / `reader` | 数字游民小册;后台提审开则读备用合规书(无「提审」UI 文案) |
电子书 / 课时内容从 `src/modules/vip/app/data` 抽取:
```bash
python apps/miniprogram/h5/scripts/extract-vip-ebooks.py
python apps/miniprogram/h5/scripts/extract-vip-lessons.py
```