Ship Douyin tt/ miniprogram: offline reader, clipboard privacy, README.

Add apps/miniprogram/tt as a standalone Douyin app with official usePrivacyCheck + tt.showModal/setClipboardData flow, single-chapter offline reader, and document console privacy setup for clipboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-09-30 15:17:52 +08:00
parent 626f6b19e8
commit 1d3e513ae2
1109 changed files with 36248 additions and 1319 deletions

View File

@ -61,8 +61,8 @@ pnpm dev
```bash
cd apps/miniprogram && pnpm install
pnpm dev:weapp # 微信开发者工具打开 dist/weapp · AppID wxa55815dd741a540d
pnpm dev:tt # 抖音开发者工具打开 dist/tt · AppID tt995defe007255b2701
pnpm build:xhs # 小红书:xhs/release 离线包 → 小红书开发者工具导入
pnpm build:tt # 抖音:开发者工具打开 apps/miniprogram/tt · AppID tt995defe007255b2701
pnpm build:xhs # 小红书:上传 xhs/dist/nomadro-xhs-portal.zip(离线 41 章 + 包内图)
```
密钥、Tab、虚拟支付与三端验收细节:[`apps/miniprogram/README.md`](./apps/miniprogram/README.md)。
@ -88,15 +88,17 @@ pnpm build:xhs # 小红书:xhs/release 离线包 → 小红书开发者工
| 顺序 | 平台 | 命令 | 开发者工具导入目录 | AppID |
|------|------|------|--------------------|-------|
| 1 | 微信 | `pnpm dev:weapp` | `apps/miniprogram/dist/weapp` | `wxa55815dd741a540d` |
| 2 | 抖音 | `pnpm dev:tt` | `apps/miniprogram/dist/tt` | `tt995defe007255b2701` |
| 3 | 小红书 | `pnpm build:xhs` | `apps/miniprogram/xhs/release`(离线优先) | 见小红书后台 / README |
| 2 | 抖音 | `pnpm build:tt` | `apps/miniprogram/tt`(`project.tt.json` → `dist/`) | `tt995defe007255b2701` |
| 3 | 小红书 | `pnpm build:xhs` | 上传 `apps/miniprogram/xhs/dist/nomadro-xhs-portal.zip`;预览 `xhs/release` | 见小红书后台 / README |
每端建议勾选:
1. [ ] 首页能开;模块卡片与远程配置一致;断网/关 API 仍可用离线配置
2. [ ] Tab:首页 / 导航 / 小册 / 社群 / 我的;导航 links、小册封面→阅读器、社群列表不白屏
3. [ ] VIP / 小册虚拟支付:沙箱 `WX_PAY_ENV=1`(仅微信;抖音/小红书按各端能力测可测部分)
4. [ ] `/admin/config` 关闭某模块后,对应小程序页显示「已关闭」闸门
2. [ ] 首页三入口(导航 / 小册 / 社群)可进;**无底部 TabBar**;导航 links、小册封面→阅读器、社群列表不白屏;导航无「书籍」分类(数据仍在 links.json)
3. [ ] **抖音导航**:点卡片出 `tt.showModal` 复制链接;后台已在「用户隐私保护协议」声明**剪切板**(见 [`tt/README.md`](./apps/miniprogram/tt/README.md))
4. [ ] **抖音小册**:单章阅读、目录可点;滑动不会弹回第 1 章并误显「全书读完」
5. [ ] VIP / 小册虚拟支付:沙箱 `WX_PAY_ENV=1`(仅微信;抖音默认离线免费)
6. [ ] `/admin/config` 关闭某模块后,对应小程序页显示「已关闭」闸门
完整密钥表与支付清单见 [`apps/miniprogram/README.md`](./apps/miniprogram/README.md)。
@ -107,7 +109,7 @@ pnpm build:xhs # 小红书:xhs/release 离线包 → 小红书开发者工
3. 再部署 `82.157.112.245` 并线上冒烟
4. 更新本 README
分支常见:`pre1`。日常门户发布:
分支常见:`pre3`(小程序三端分目录);门户历史分支亦见 `pre1`。日常门户发布:
```bash
pnpm build
@ -142,6 +144,7 @@ python deploy/observability/_upload_next_deploy.py
- 支付分流:国内 zpay / xpay(xorpay);海外 Creem / NOWPayments;小程序虚拟支付见 `apps/api` + `apps/miniprogram`
- 门户 i18n:`zh` / `en` / `ja` / `vi` / `th`
- 备份回滚:见 [`deploy/backup/README.md`](./deploy/backup/README.md)
- **小程序电子书**:抖音/小红书离线固化 hackrobot 41 章(`pack-hackrobot-book.py`);XHS zip ≤10MB/≤200 文件;配图包内 WebP;抖音阅读器单章渲染 + 官方隐私剪切板复制;细节见 [`apps/miniprogram/README.md`](./apps/miniprogram/README.md) · [`tt/README.md`](./apps/miniprogram/tt/README.md)
## 部署

View File

@ -1,30 +1,36 @@
# Nomadro 统一小程序(三端 · 全量整合)
# Nomadro 统一小程序(三端 · **分目录**)
**不是入口壳。** `src/` 已并入垂直仓完整能力:
**三端互不影响**:各自目录改、各自构建、各自上传。
| 端 | 目录 | 命令 | 产物 |
|---|---|---|---|
| 微信小程序 + Taro H5 | **本仓根** `src/` `config/` | `pnpm dev:weapp` / `pnpm dev:h5` | `dist/weapp` · `:10086` |
| 抖音小程序 | **`tt/`** | `pnpm --dir tt dev` 或 `pnpm dev:tt` | `tt/dist` |
| 小红书小工具 | **`xhs/`** | `pnpm build:xhs` | `xhs/dist/nomadro-xhs-portal.zip` |
`src/` 已并入垂直仓能力(仅服务微信 / H5):
| 模块 | 源码出处 | 本仓页面 |
|------|----------|----------|
| 出海导航 | `apps/navmini` links + weapp UI | `pages/nav` |
| 电子书封面+阅读器+虚拟支付 | `apps/ebook/wemini/miniapp` **整包** | `pages/book` + `pages/reader` + `utils/payFlow` + Markdown 组件 |
| 旅居社群 | `apps/nomadweb/wemini` | `pages/community` `destinations` `destination` `meetups` `mine` |
| VIP | nomadvip 商品 + 虚拟支付 | `pages/vip` |
| 抖音 | `ebook/dymini` AppID / Taro tt | `pnpm build:tt` |
| 小红书 | 统一门户离线 SPA | `xhs/` → `xhs/dist/nomadro-xhs-portal.zip` |
| 电子书封面+阅读器+虚拟支付 | `apps/ebook/wemini/miniapp` **整包** | `pages/book` + `pages/reader` |
| 旅居社群 | `apps/nomadweb/wemini` | `pages/community` … `mine` |
| VIP | nomadvip | `pages/vip` |
抖音以 `tt/` 为独立 Taro 工程(种子对齐微信页面,之后各自演进);小红书为离线 SPA,无 Taro。
## 目标(全端)
用 **一套 Taro 源码** 覆盖 Next 已整合的四垂直能力,产出:
| 端 | 命令 | 对齐 |
| 端 | 命令 | 说明 |
|---|---|---|
| **Taro H5 / PC**(先验) | `pnpm dev:h5` → `:10086` | 视觉与路由对齐门户 Next(`/` `/nav` `/book` `/community` `/vip`) |
| 微信小程序 | `pnpm dev:weapp` | 同套页面 + TabBar + 虚拟支付 |
| 抖音小程序 | `pnpm dev:tt` | 同套页面 |
| 小红书小工具 | `pnpm build:xhs` | **统一门户**离线 ZIP(首页+导航+小册+社群+VIP,无 Taro 运行时) |
| **Taro H5 / PC**(先验) | `pnpm dev:h5` → `:10086` | 对齐门户 Next |
| 微信小程序 | `pnpm dev:weapp` | 无 TabBar(首页入口跳转)+ 虚拟支付 |
| 抖音小程序 | `pnpm --dir tt dev` | 见 [`tt/README.md`](./tt/README.md) |
| 小红书小工具 | `pnpm build:xhs` | 离线 ZIP |
**验收顺序**:Taro H5 → 微信 → 抖音 → 小红书。H5 过了再编三端。
**验收顺序**:Taro H5 → 微信 → 抖音 → 小红书。
首页源码对照:`components/sections/hero.tsx` + `app/hub.css` → `src/pages/index` + `src/styles/hub.scss`。H5 **无 TabBar**(与 Next 一致);微信/抖音保留五 Tab。
首页对照:`components/sections/hero.tsx` + `app/hub.css` → `src/pages/index`。H5 / 微信 **默认无 TabBar**(首页三入口卡片);仅 `TARO_APP_TABBAR=1` 才挂五 Tab。抖音无 TabBar、系统导航;小红书首页三入口横排。品牌标统一小红书同源红标(`#f06664` · `/icons/nomadro.webp`)。导航「书籍」分类在 `links.json` 标 `hidden: true`(数据保留、不展示)。
## 文档
@ -42,7 +48,8 @@
- 公开 API:`GET /api/config` · `GET /v1/config`(apps/api)
- 后台:`/admin/config` 开关模块 / 改文案 / VIP 价格
- 小程序:`services/remoteConfig.ts`(网络 → Storage → 包内默认)
- 电子书离线:`data/offlineBook.ts`;社群:`localCatalog`;小红书:`xhs/release` 整包
- 电子书离线:微信 `data/offlineBook.ts` / `src/data/nomadCodeBook.ts`;抖音 `tt/src/data/nomadCodeBook.ts`(默认强制离线 hackrobot);社群:`localCatalog`;小红书:`xhs/release` 整包(`portal-data.js`)
- 正文 SoT:`scripts/_hackrobot_book/info.md` → `pnpm pack:hackrobot-book` / `pnpm build:xhs` 写入三端(41 章 · 异度世界)
## 密钥(按项目要求写入)
@ -91,16 +98,23 @@ pnpm dev:h5 # → http://localhost:10086/ (compiler: vite,远快于 we
# /community-api → https://nomadweb.nomadro.com/api/v1
# 冒烟:python scripts/_h5_smoke.py(需本机已起 dev:h5)
# ② H5 过了再编三端
pnpm dev:weapp # → dist/weapp ,微信工具打开,AppID 见上
pnpm dev:tt # → dist/tt ,抖音工具,AppID tt995defe007255b2701
pnpm build:xhs # → xhs/dist/nomadro-xhs-portal.zip(统一门户离线包)
# build:xhs-book 已废弃:小册已并入门户包,勿再打独立 book zip
# ② 微信(只动根目录 src/)
pnpm dev:weapp # → dist/weapp ,微信工具打开本仓根(project.config.json)
# ③ 抖音(只动 tt/,与微信互不影响)
pnpm --dir tt install
pnpm --dir tt dev # → tt/dist ,抖音工具打开 apps/miniprogram/tt
# 或伞仓:pnpm dev:tt / pnpm build:tt
# ④ 小红书(只动 xhs/)
pnpm build:xhs # → xhs/dist/nomadro-xhs-portal.zip
# build:xhs-book 已废弃:小册已并入门户包
# 仅重打电子书配图/正文(不打 zip):pnpm pack:hackrobot-book
```
**验收顺序**:Taro H5 → 微信 → 抖音 → 小红书(小红书无 Taro 运行时,用离线 zip)。
H5 首页视觉对齐门户 `app/hub.css`(`src/styles/hub.scss`);Tab:首页 / 导航 / **小册** / 社群 / 我的。
H5 首页视觉对齐门户 `app/hub.css`(`src/styles/hub.scss`);默认无 TabBar,首页卡片进导航 / 小册 / 社群。
建议:根仓 `pnpm dev` 先起门户,再开小程序,便于拉 `http://localhost:3000/api/config`(拉不到则用包内默认,小红书尤其依赖离线包)。
@ -119,10 +133,16 @@ H5 首页视觉对齐门户 `app/hub.css`(`src/styles/hub.scss`);Tab:首
### 抖音开发者工具
1. `pnpm dev:tt`,导入 `dist/tt`,AppID `tt995defe007255b2701`
2. [ ] 首页与 Tab 可开;导航 / 小册 / 社群不白屏
3. [ ] 远程配置/离线兜底行为与微信一致(支付能力按抖音侧实际能力勾选)
1. `cd tt && pnpm install && pnpm build`(或伞仓 `pnpm build:tt`)
2. 导入目录 **`apps/miniprogram/tt`**(读 `project.tt.json` → `dist/`),AppID `tt995defe007255b2701`
3. [ ] 首页三入口;红标 logo;顶栏避开状态栏
4. [ ] 导航点链接 → 系统 Modal「复制/关闭」→ `tt.setClipboardData` 成功
(后台:**设置 → 基础设置 → 类目与配置 → 用户隐私保护协议** 声明「剪切板」;非 Webhook)
5. [ ] 小册单章阅读;滑动不弹回第 1 章;仅末章「全书读完」;目录可点
6. [ ] `usePrivacyCheck: true`;未注册自定义 `onNeedPrivacyAuthorization`(走官方隐私弹窗)
7. [ ] **只改 `tt/`**,勿动根 `src/` / `xhs/`
细节与官方文档链接见 [`tt/README.md`](./tt/README.md)。
### 小红书小工具(离线优先 · 统一门户)
官方能力清单:https://miniapp-sandbox.xiaohongshu.com/minitool/doc
@ -131,17 +151,36 @@ H5 首页视觉对齐门户 `app/hub.css`(`src/styles/hub.scss`);Tab:首
cd apps/miniprogram
pnpm build:xhs
# 上传:xhs/dist/nomadro-xhs-portal.zip
# 本地预览目录:xhs/release/(仅 index.html + app.js + styles.css + icons/)
# 本地预览目录:xhs/release/(index.html + app.js + styles.css + icons/ + images/)
```
| 项 | 约定 |
|---|---|
| 产物 | **仅一个**根目录 `index.html`(另含 `app.js` / `styles.css` / `icons/`) |
| 产物 | **仅一个**根目录 `index.html`(另含 `app.js` / `styles.css` / `icons/` / `images/`) |
| 入口内容 | 首页 hub + 出海导航 + 数字游民小册 + 旅居社群 + VIP(SPA 切页) |
| 源码 | `xhs/tool/` → `assemble.py` 合并 CSS/JS → `xhs/release/` → `pack.py` 打 zip |
| 联网 | **禁止**;配置与文案走包内 `portal-data.js`,有网也不依赖业务 API |
| 脚本 | **禁止**内联 `onclick` / 内联 `<script>`;事件一律 `addEventListener` |
#### 构建链路(`pnpm build:xhs`)
顺序固定,**勿单独 `xhs:export` 后不重打 hackrobot**(会把旧样例书写回):
1. `pack-hackrobot-book.py` — 从 `scripts/_hackrobot_book/info.md` 生成 41 章正文 + 预算内 WebP
2. `export-xhs-offline.mjs` — 同步导航 / 社群 / VIP;书优先读 `tt/src/data/nomadCodeBook.ts`(≥10 章)
3. `pack-hackrobot-book.py` 再跑一遍 — **覆盖**顶层 `PORTAL_DATA.book`(阅读器读这里,不是 `config.modules.book`)
4. `assemble.py` → `validate_size.py` → `pack.py` → `xhs/dist/nomadro-xhs-portal.zip`
#### 电子书 / 配图方案
| 项 | 约定 |
|---|---|
| 正文 | hackrobot《数字游民:地理套利与自动化杠杆》· **41 章** · 作者异度世界 |
| 配图 | 包内 `images/*.webp`,路径 `![alt](./images/xxx.webp)`;禁 CDN / 禁 `file://` |
| 体积预算 | 配图约 ≤2.8MB、**最多 120 张**;超额改占位「完整图见公众号异度世界」 |
| 渲染 | `book/markdown.js`:图片先停 `@@IMGn@@`,转义后再展开 `<img>`(避免把标签当正文显示) |
| zip 上限 | **≤10MB** · **≤200 文件**(`validate_size.py` 硬校验) |
#### 平台硬限制(上传 / 真机)
1. **禁止多个 HTML**:zip 内若出现 `nav.html` / `book.html` 等会部署失败——报错「仅允许保留一个入口文件 index.html」。
@ -152,11 +191,13 @@ pnpm build:xhs
#### 验收清单
1. [ ] 上传 `nomadro-xhs-portal.zip` 成功(根目录仅一个 `index.html`)
1. [ ] 上传 `nomadro-xhs-portal.zip` 成功(根目录仅一个 `index.html`;文件数 ≤200)
2. [ ] 断网可开:首页 / 导航 / 小册 / 社群 / VIP
3. [ ] 子页点「首页」回到门户首页
4. [ ] 导航:左侧菜单打开分类;上滑时顶栏不漏内容
5. [ ] 小册 / 社群顶栏透明,顶部有与首页类似的光晕色调
3. [ ] 小册目录为 **41 章**(前言 / 自动化杠杆…),**不是** 7 章「清迈/林远」样例
4. [ ] 前言等章配图正常显示(不是屏幕上的原文 `<img>` HTML)
5. [ ] 子页点「首页」回到门户首页
6. [ ] 导航:左侧菜单打开分类;上滑时顶栏不漏内容
7. [ ] 小册 / 社群顶栏透明,顶部有与首页类似的光晕色调
## 部署前检查清单
@ -170,19 +211,19 @@ pnpm build:xhs
## 目录
```
src/pages/book|reader ← ebook/wemini 完整阅读链路
src/pages/nav ← navmini 链接库
src/pages/community|… ← nomadweb 社群
src/components/MiniModuleGate.tsx ← 远程配置模块闸门
src/utils/payFlow.ts ← 电子书虚拟支付
src/utils/virtualPay.ts ← VIP 支付
src/services/ebookApi.ts ← 电子书 API
src/services/api.ts ← 社群 API + localCatalog
src/services/remoteConfig.ts ← 冷启动预拉 + 离线兜底
xhs/
tool/ ← 离线 SPA 源(index.html / app.js / *.css)
scripts/assemble.py ← 打 release
scripts/pack.py ← 打 zip(强制仅一个根 index.html)
release/ ← 组装产物(预览用)
dist/nomadro-xhs-portal.zip ← 上传创作服务平台
src/ ← 微信 + H5(勿用 TARO_APP_TARGET=tt 编抖音)
data/nomadCodeBook.ts ← pack-hackrobot-book 写入(与 tt 同源正文)
config/ project.config.json
dist/weapp · dist/h5
scripts/
pack-hackrobot-book.py ← 抖音/小红书离线电子书 + 配图预算
export-xhs-offline.mjs ← 小红书门户种子
_hackrobot_book/info.md ← 正文 SoT
tt/ ← 抖音独立工程(见 tt/README.md)
src/ config/ project.tt.json → dist/
src/data/nomadCodeBook.ts · packageBook/assets/book-images/
xhs/ ← 小红书离线 SPA
tool/portal-data.js · tool/book/{book-data.js,markdown.js,images/}
scripts/ assemble · validate_size · pack
release/ · dist/nomadro-xhs-portal.zip
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -3,19 +3,10 @@ import { defineConfig, type UserConfigExport } from '@tarojs/cli'
const target = process.env.TARO_APP_TARGET || process.env.TARO_ENV || 'weapp'
const isH5 = target === 'h5'
const outputRoot =
target === 'h5'
? 'dist/h5'
: target === 'tt'
? 'dist/tt'
: target === 'xhs'
? 'dist/xhs'
: 'dist/weapp'
/** 本目录仅微信 + H5;抖音见 tt/,小红书见 xhs/ */
const outputRoot = isH5 ? 'dist/h5' : 'dist/weapp'
const defaultApi =
target === 'tt'
? 'https://dyapi.nomadro.cn'
: 'https://api.nomadro.cn'
const defaultApi = 'https://api.nomadro.cn'
const iconsDir = path.resolve(__dirname, '..', 'src', 'assets', 'icons')
@ -56,7 +47,8 @@ const pxExclude = (file: string) =>
/[\\/]pages[\\/]nav[\\/]index\.scss/.test(file) ||
/[\\/]pages[\\/]book[\\/]index\.scss/.test(file) ||
/[\\/]pages[\\/]community[\\/]index\.scss/.test(file) ||
/[\\/]pages[\\/]vip[\\/]index\.scss/.test(file)
/[\\/]pages[\\/]vip[\\/]index\.scss/.test(file) ||
/[\\/]components[\\/]WechatOaModal\.scss/.test(file)
export default defineConfig(async (merge) => {
const baseConfig: UserConfigExport = {
@ -124,6 +116,9 @@ export default defineConfig(async (merge) => {
if (isH5) return
// eslint-disable-next-line @typescript-eslint/no-var-requires
const CopyWebpackPlugin = require('copy-webpack-plugin')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { execSync } = require('child_process')
const miniRoot = path.resolve(__dirname, '..')
chain.plugin('nomadro-copy-icons').use(CopyWebpackPlugin, [
{
patterns: [
@ -135,6 +130,23 @@ export default defineConfig(async (merge) => {
],
},
])
// watch/build 每次产出后:静态资源 + 分享开关(Taro 会丢掉 enableShare*)
chain.plugin('nomadro-after-emit-static').use(
class NomadroAfterEmitStatic {
apply(compiler: { hooks: { afterEmit: { tap: (n: string, cb: () => void) => void } } }) {
compiler.hooks.afterEmit.tap('NomadroAfterEmitStatic', () => {
try {
execSync('node ./scripts/copy-weapp-static.mjs', {
cwd: miniRoot,
stdio: 'inherit',
})
} catch (e) {
console.warn('[nomadro-after-emit-static]', (e as Error).message)
}
})
}
},
)
},
// Vite root=src,publicDir 默认 src/public → /icons/*
modifyViteConfig(viteConfig: { publicDir?: string; appType?: string }) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -2,28 +2,30 @@
"name": "@nomadro/miniprogram",
"version": "0.1.0",
"private": true,
"description": "Nomadro 统一小程序 — 微信 / 抖音 / 小红书(Taro 4 + React,能力对齐 apps 垂直仓)",
"description": "Nomadro 小程序伞仓 — 微信(根目录) / 抖音(tt/) / 小红书(xhs/) 分目录、互不影响",
"scripts": {
"build:h5": "cross-env TARO_APP_TARGET=h5 node ./node_modules/@tarojs/cli/bin/taro build --type h5",
"dev:h5": "cross-env TARO_APP_TARGET=h5 node ./node_modules/@tarojs/cli/bin/taro build --type h5 --watch",
"build:weapp": "cross-env TARO_APP_TARGET=weapp node ./node_modules/@tarojs/cli/bin/taro build --type weapp && node ./scripts/copy-weapp-static.mjs",
"dev:weapp": "cross-env TARO_APP_TARGET=weapp node ./node_modules/@tarojs/cli/bin/taro build --type weapp --watch",
"postdev:weapp-static": "cross-env TARO_APP_TARGET=weapp node ./scripts/copy-weapp-static.mjs",
"copy:weapp-static": "cross-env TARO_APP_TARGET=weapp node ./scripts/copy-weapp-static.mjs",
"build:tt": "cross-env TARO_APP_TARGET=tt node ./node_modules/@tarojs/cli/bin/taro build --type tt && cross-env TARO_APP_TARGET=tt node ./scripts/copy-weapp-static.mjs",
"dev:tt": "cross-env TARO_APP_TARGET=tt node ./node_modules/@tarojs/cli/bin/taro build --type tt --watch",
"build:xhs-taro": "cross-env TARO_ENV=weapp TARO_APP_TARGET=xhs taro build --type weapp && cross-env TARO_APP_TARGET=xhs node ./scripts/copy-weapp-static.mjs",
"copy:weapp-static": "node ./scripts/copy-weapp-static.mjs",
"dev:tt": "pnpm --dir tt install && pnpm --dir tt dev",
"build:tt": "pnpm --dir tt install && pnpm --dir tt build",
"dev:tt:vite": "pnpm --dir tt install && pnpm --dir tt dev:vite",
"build:tt:vite": "pnpm --dir tt install && pnpm --dir tt build:vite",
"xhs:sync": "python xhs/scripts/sync_data.py",
"xhs:assemble": "python xhs/scripts/assemble.py",
"xhs:pack": "python xhs/scripts/pack.py",
"xhs:assemble-book": "python xhs/scripts/assemble_book.py",
"xhs:pack-book": "python xhs/scripts/pack_book.py",
"xhs:export": "node ./scripts/export-xhs-offline.mjs",
"build:xhs": "npm run xhs:export && npm run xhs:assemble && npm run xhs:pack",
"build:xhs": "python ./scripts/pack-hackrobot-book.py && npm run xhs:export && python ./scripts/pack-hackrobot-book.py && npm run xhs:assemble && python ./xhs/scripts/validate_size.py && npm run xhs:pack",
"pack:hackrobot-book": "python ./scripts/pack-hackrobot-book.py",
"build:xhs-book": "echo skip: book is inside portal — use pnpm build:xhs",
"build:xhs-all": "npm run build:xhs",
"pack:nomad-code": "node ./scripts/pack-nomad-code.mjs",
"dev:all": "echo use: pnpm dev:weapp | pnpm dev:tt | pnpm build:xhs"
"dev:all": "echo use: pnpm dev:weapp | pnpm --dir tt dev | pnpm build:xhs"
},
"browserslist": [
"last 3 versions",
@ -36,7 +38,6 @@
"@tarojs/helper": "4.0.9",
"@tarojs/plugin-framework-react": "4.0.9",
"@tarojs/plugin-platform-h5": "^4.0.9",
"@tarojs/plugin-platform-tt": "4.0.9",
"@tarojs/plugin-platform-weapp": "4.0.9",
"@tarojs/react": "4.0.9",
"@tarojs/router": "^4.0.9",

View File

@ -23,9 +23,6 @@ importers:
'@tarojs/plugin-platform-h5':
specifier: ^4.0.9
version: 4.2.1(@tarojs/taro@4.0.9(7215ff9359ae71a4558bee11770f0d84))(@types/react@18.3.31)(html-webpack-plugin@5.6.8(webpack@5.91.0(@swc/core@1.3.96)(clean-css@5.3.3)(cssnano@6.1.2(postcss@8.5.28))(csso@5.0.5)(esbuild@0.21.5)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.28)(uglify-js@3.19.3)))(postcss@8.5.28)(react@18.3.1)(rollup@3.30.0)(solid-js@1.9.15)(supports-color@8.1.1)(webpack-chain@6.5.1)(webpack-dev-server@4.15.2(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1)(webpack@5.91.0(@swc/core@1.3.96)(clean-css@5.3.3)(cssnano@6.1.2(postcss@8.5.28))(csso@5.0.5)(esbuild@0.21.5)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.28)(uglify-js@3.19.3)))(webpack@5.91.0(@swc/core@1.3.96)(clean-css@5.3.3)(cssnano@6.1.2(postcss@8.5.28))(csso@5.0.5)(esbuild@0.21.5)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.28)(uglify-js@3.19.3))
'@tarojs/plugin-platform-tt':
specifier: 4.0.9
version: 4.0.9(@tarojs/service@4.0.9(supports-color@8.1.1))(@tarojs/shared@4.0.9)
'@tarojs/plugin-platform-weapp':
specifier: 4.0.9
version: 4.0.9(@tarojs/service@4.0.9(supports-color@8.1.1))(@tarojs/shared@4.0.9)
@ -1899,13 +1896,6 @@ packages:
'@tarojs/plugin-platform-h5@4.2.1':
resolution: {integrity: sha512-dSq83kvWokaju7gfPyddQCzjCd9gi57T5YNQqXkfqLLEPHnR3xfZHN2qdO3Vf6Qjob3woms/hEwIi4HUFWOTgg==}
'@tarojs/plugin-platform-tt@4.0.9':
resolution: {integrity: sha512-bf0KdU+3V1Kk/0e+RhHxIbYVCxusAFU01dE1lnyKsSB28pdzsE8HN1VQsnJoL2dgU/KratHl7P2e38SjHBYcyw==}
engines: {node: '>= 18'}
peerDependencies:
'@tarojs/service': 4.0.9
'@tarojs/shared': 4.0.9
'@tarojs/plugin-platform-weapp@4.0.9':
resolution: {integrity: sha512-R0EwkAAA5A0eCVZ8ZylEnixOFdwiwEBONOsxMDfRv12tl5U89O52r0nsCC9FMwPBke6g8lqvTBvqaWozZ6MiRA==}
engines: {node: '>= 18'}
@ -7909,12 +7899,6 @@ snapshots:
- webpack-chain
- webpack-dev-server
'@tarojs/plugin-platform-tt@4.0.9(@tarojs/service@4.0.9(supports-color@8.1.1))(@tarojs/shared@4.0.9)':
dependencies:
'@tarojs/service': 4.0.9(supports-color@8.1.1)
'@tarojs/shared': 4.0.9
webpack-sources: 3.6.0
'@tarojs/plugin-platform-weapp@4.0.9(@tarojs/service@4.0.9(supports-color@8.1.1))(@tarojs/shared@4.0.9)':
dependencies:
'@tarojs/service': 4.0.9(supports-color@8.1.1)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,14 +1,14 @@
/**
* Taro copy.patterns 偶发不落盘;构建后强制把 icons / assets 拷进 dist。
* Taro copy.patterns 偶发不落盘;构建后强制把 icons / assets 拷进 dist/weapp。
* 分享开关由 markPageShare 挂到 Page 组件(勿写入 page.json,基础库会报「无效的 page.json」)。
* 仅微信;抖音见 tt/scripts/copy-static.mjs,小红书见 xhs/。
*/
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const target = process.env.TARO_APP_TARGET || 'weapp'
const out =
target === 'tt' ? 'dist/tt' : target === 'xhs' ? 'dist/xhs' : 'dist/weapp'
const out = 'dist/weapp'
function copyDir(from, to) {
if (!fs.existsSync(from)) {
@ -30,6 +30,28 @@ function copyDir(from, to) {
return n
}
/** 清掉历史误写入的 enableShare*,避免开发者工具刷黄字警告 */
function stripInvalidShareKeys(pagesRoot) {
if (!fs.existsSync(pagesRoot)) return 0
let n = 0
for (const name of fs.readdirSync(pagesRoot)) {
const jsonPath = path.join(pagesRoot, name, 'index.json')
if (!fs.existsSync(jsonPath)) continue
try {
const raw = fs.readFileSync(jsonPath, 'utf8').replace(/^\uFEFF/, '')
const j = JSON.parse(raw)
if (!('enableShareAppMessage' in j) && !('enableShareTimeline' in j)) continue
delete j.enableShareAppMessage
delete j.enableShareTimeline
fs.writeFileSync(jsonPath, JSON.stringify(j))
n += 1
} catch (e) {
console.warn(`[copy-weapp-static] strip share fail ${jsonPath}:`, e.message)
}
}
return n
}
const icons = copyDir(
path.join(root, 'src/public/icons'),
path.join(root, out, 'icons'),
@ -38,4 +60,5 @@ const assets = copyDir(
path.join(root, 'src/assets'),
path.join(root, out, 'assets'),
)
console.log(`[copy-weapp-static] ${out}: icons=${icons} assets=${assets}`)
const stripped = stripInvalidShareKeys(path.join(root, out, 'pages'))
console.log(`[copy-weapp-static] ${out}: icons=${icons} assets=${assets} strippedShareJson=${stripped}`)

View File

@ -64,7 +64,8 @@ function extractReturnPayload(src, fnName) {
else if (ch === '}') {
depth--
if (depth === 0) {
return JSON.parse(src.slice(brace, i + 1))
const lit = src.slice(brace, i + 1)
return new Function(`return (${lit})`)()
}
}
}
@ -74,14 +75,35 @@ function extractReturnPayload(src, fnName) {
const links = JSON.parse(
fs.readFileSync(path.join(mini, 'src', 'data', 'links.json'), 'utf8'),
)
const coverBook = extractJsObject(
fs.readFileSync(path.join(mini, 'src', 'data', 'coverBook.ts'), 'utf8'),
'COVER_BOOK',
)
const readPayload = extractReturnPayload(
fs.readFileSync(path.join(mini, 'src', 'data', 'nomadCodeBook.ts'), 'utf8'),
'nomadCodeReadPayload',
)
function readBookSources() {
const candidates = [
path.join(mini, 'tt', 'src', 'data'),
path.join(mini, 'src', 'data'),
]
for (const dir of candidates) {
const bookPath = path.join(dir, 'nomadCodeBook.ts')
const coverPath = path.join(dir, 'coverBook.ts')
if (!fs.existsSync(bookPath) || !fs.existsSync(coverPath)) continue
const payload = extractReturnPayload(fs.readFileSync(bookPath, 'utf8'), 'nomadCodeReadPayload')
const chapters = payload.chapters || []
if (chapters.length >= 10) {
return {
source: bookPath,
coverBook: extractJsObject(fs.readFileSync(coverPath, 'utf8'), 'COVER_BOOK'),
readPayload: payload,
}
}
}
const bookPath = path.join(mini, 'src', 'data', 'nomadCodeBook.ts')
const coverPath = path.join(mini, 'src', 'data', 'coverBook.ts')
return {
source: bookPath,
coverBook: extractJsObject(fs.readFileSync(coverPath, 'utf8'), 'COVER_BOOK'),
readPayload: extractReturnPayload(fs.readFileSync(bookPath, 'utf8'), 'nomadCodeReadPayload'),
}
}
const { source: bookSource, coverBook, readPayload } = readBookSources()
const meetups = extractJsObject(
fs.readFileSync(path.join(mini, 'src', 'data', 'localCatalog.ts'), 'utf8'),
'LOCAL_MEETUPS',
@ -97,7 +119,9 @@ for (const f of fs.readdirSync(iconsOut)) {
fs.unlinkSync(path.join(iconsOut, f))
}
const needed = new Set(['_brand', 'nomadro'])
for (const cat of links.categories || []) {
// 隐藏分类保留在 links.json,导出门户时不展示(hidden: true)
links.categories = (links.categories || []).filter((c) => !c.hidden)
for (const cat of links.categories) {
for (const g of cat.groups || []) {
for (const link of g.links || []) {
const lid = String(link.id || '').trim()
@ -159,14 +183,23 @@ const cfg = {
}
const bookMeta = readPayload.book || {}
const bookChapters = (readPayload.chapters || []).map((ch) => ({
id: ch.id,
title: ch.title,
order: ch.order,
emoji: ch.emoji || '',
body: ch.content || '',
content: ch.content || '',
}))
/** 微信/抖音分包图路径 → 小红书离线 ./images/ */
function xhsBookImagePath(body) {
return String(body || '')
.replace(/\/packageBook\/assets\/book-images\//g, './images/')
.replace(/\/assets\/book-images\//g, './images/')
}
const bookChapters = (readPayload.chapters || []).map((ch) => {
const body = xhsBookImagePath(ch.content || ch.body || '')
return {
id: ch.id,
title: ch.title,
order: ch.order,
emoji: ch.emoji || '',
body,
content: body,
}
})
const portalBook = {
title: coverBook.title || bookMeta.title || '数字游民',
@ -196,9 +229,11 @@ const community = {
oa: {
eyebrow: '保持连接',
title: '关注',
accent: '公众号',
lead: '获取出海导航、游民社群与会员更新,扫码即达。',
hint: '搜索公众号「nomadro」',
accent: '异度世界',
lead: '获取出海导航、游民社群与会员更新。',
hint: '搜索公众号「异度世界」',
keyword: '加群',
keywordHint: '关注后私信关键词「加群」',
qr: './icons/wechat-oa-qr.png',
},
meetups: (meetups || []).slice(0, 12).map((m) => ({
@ -333,7 +368,8 @@ for (const qr of qrCandidates) {
}
console.log(
`[export-xhs-offline] portal modules=${Object.keys(cfg.modules).join(',')} ` +
`[export-xhs-offline] book=${path.relative(mini, bookSource)} ` +
`portal modules=${Object.keys(cfg.modules).join(',')} ` +
`nav_cats=${(links.categories || []).length} book_ch=${bookChapters.length} ` +
`meetups=${community.meetups.length} vip_topics=${vip.topics.length} ` +
`icons=${fs.readdirSync(iconsOut).length}` +

View File

@ -0,0 +1,63 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'src', 'pages')
const files = {
'book/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '数字游民',
navigationStyle: 'custom',
})
`,
'community/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '旅居社群',
navigationStyle: 'custom',
})
`,
'destination/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '目的地详情',
})
`,
'destinations/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '目的地',
})
`,
'index/index.config.ts': `export default definePageConfig({
navigationBarTitleText: 'Nomadro',
// 对齐 H5:自定义顶栏,去掉原生导航栏占位
navigationStyle: 'custom',
})
`,
'meetups/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '聚会',
})
`,
'mine/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '我的',
})
`,
'nav/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '出海导航',
navigationStyle: 'custom',
})
`,
'reader/index.config.ts': `export default definePageConfig({
navigationBarTitleText: '阅读',
})
`,
'vip/index.config.ts': `export default definePageConfig({
navigationBarTitleText: 'VIP 会员',
navigationBarBackgroundColor: '#0c0c0f',
navigationBarTextStyle: 'white',
backgroundColor: '#0c0c0f',
navigationStyle: 'custom',
})
`,
}
for (const [rel, body] of Object.entries(files)) {
const fp = path.join(root, rel)
fs.writeFileSync(fp, body, 'utf8')
console.log('ok', rel, body.includes('数字') || body.includes('Nomadro') || body.includes('VIP'))
}

View File

@ -0,0 +1,515 @@
# -*- coding: utf-8 -*-
"""
Pack hackrobot info.md → 抖音(tt) + 小红书(xhs) 离线电子书。
体积约束(官方/仓内校验):
- 抖音:主包 ≤4MB,单分包 ≤2MB,总计 ≤16MB
https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/tutorial/basic-ability/subpackages/introduction
- 小红书小工具:资源须全进包、禁外链 CDN;仓内 validate ≤10MB
(能力清单:包内 jpg/png/webp;base64 可用但更大)
策略:强压 WebP/JPEG、硬预算截断超额图 → 文案占位;禁止整本 366 图无上限灌入。
"""
from __future__ import annotations
import hashlib
import json
import re
import shutil
import sys
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from io import BytesIO
from pathlib import Path
from urllib.parse import quote, unquote, urlparse
import requests
from PIL import Image
ROOT = Path(__file__).resolve().parents[1]
SRC_MD = Path(__file__).resolve().parent / "_hackrobot_book" / "info.md"
WORK = Path(__file__).resolve().parent / "_hackrobot_book"
IMG_WORK = WORK / "images_budget"
TT_IMG = ROOT / "tt" / "src" / "packageBook" / "assets" / "book-images"
XHS_IMG = ROOT / "xhs" / "tool" / "book" / "images"
TT_DATA = ROOT / "tt" / "src" / "data"
WEAPP_DATA = ROOT / "src" / "data"
XHS_BOOK_DATA = ROOT / "xhs" / "tool" / "book" / "book-data.js"
XHS_PORTAL = ROOT / "xhs" / "tool" / "portal-data.js"
# —— 硬预算(字节 / 文件数)——
# 抖音单分包 ≤2MB:书页+文案约占 0.9~1.0MB,配图预算压到 0.95MB
TT_IMG_BUDGET = int(0.95 * 1024 * 1024)
# 小红书包 ≤10MB,且创服平台硬限 zip 内 ≤200 个文件
# 预留:index/app/styles≈3 + icons≈65 → 配图上限约 120
XHS_IMG_BUDGET = int(2.8 * 1024 * 1024)
XHS_IMG_MAX_COUNT = 120
XHS_ZIP_FILE_LIMIT = 200
MAX_WIDTH = 480
JPEG_Q = 52
WEBP_Q = 48
WORKERS = 14
PLACEHOLDER = "> 🖼 (配图已省略 · 完整图见公众号「异度世界」)"
MD_IMG_RE = re.compile(r"!\[([^\]]*)\]\((https?://[^)\s]+)\)")
HTML_IMG_RE = re.compile(
r"""<img\b([^>]*?)src=["'](https?://[^"']+)["']([^>]*)>""", re.I | re.S
)
def log(msg: str) -> None:
sys.stdout.buffer.write((msg + "\n").encode("utf-8", errors="replace"))
sys.stdout.buffer.flush()
def safe_stem(url: str) -> str:
name = Path(unquote(urlparse(url).path)).name or "img"
name = name.replace("…", "").replace(" ", "_")
h = hashlib.md5(url.encode("utf-8")).hexdigest()[:8]
stem = re.sub(r"[^A-Za-z0-9._\u4e00-\u9fff-]+", "_", Path(name).stem[:32]) or "img"
return f"{stem}_{h}"
def extract_urls(text: str) -> list[str]:
urls: list[str] = []
seen = set()
# 保持文中出现顺序(优先保留靠前配图)
for m in re.finditer(
r"""(?:!\[[^\]]*\]\((https?://[^)\s]+)\)|<img[^>]+src=["'](https?://[^"']+)["'])""",
text,
re.I | re.S,
):
u = m.group(1) or m.group(2)
if u and u not in seen:
seen.add(u)
urls.append(u)
return urls
def http_get(url: str) -> bytes | None:
try:
r = requests.get(url, timeout=35, headers={"User-Agent": "nomadro-offline-pack/1.1"})
if r.status_code == 200 and r.content and len(r.content) > 80:
return r.content
except Exception:
pass
try:
p = urlparse(url)
alt = p._replace(path=quote(unquote(p.path))).geturl()
if alt != url:
r = requests.get(alt, timeout=35, headers={"User-Agent": "nomadro-offline-pack/1.1"})
if r.status_code == 200 and r.content and len(r.content) > 80:
return r.content
except Exception:
pass
return None
def encode_image(data: bytes) -> tuple[bytes, str] | None:
"""返回 (bytes, ext) 选 webp/jpeg 更小者。"""
try:
im = Image.open(BytesIO(data)).convert("RGB")
w, h = im.size
if w > MAX_WIDTH:
im = im.resize((MAX_WIDTH, int(h * MAX_WIDTH / w)), Image.Resampling.LANCZOS)
buf_j = BytesIO()
im.save(buf_j, format="JPEG", quality=JPEG_Q, optimize=True)
jpeg_b = buf_j.getvalue()
try:
buf_w = BytesIO()
im.save(buf_w, format="WEBP", quality=WEBP_Q, method=4)
webp_b = buf_w.getvalue()
if len(webp_b) + 32 < len(jpeg_b):
return webp_b, ".webp"
except Exception:
pass
return jpeg_b, ".jpg"
except Exception:
return None
def download_encode(urls: list[str]) -> dict[str, tuple[Path, int]]:
"""url -> (local_path, size). 全量压缩到 IMG_WORK,再按预算筛选。"""
IMG_WORK.mkdir(parents=True, exist_ok=True)
out: dict[str, tuple[Path, int]] = {}
def one(url: str) -> tuple[str, Path | None, int]:
stem = safe_stem(url)
# 已有缓存
for ext in (".webp", ".jpg"):
p = IMG_WORK / f"{stem}{ext}"
if p.exists() and p.stat().st_size > 80:
return url, p, p.stat().st_size
raw = http_get(url)
if not raw:
return url, None, 0
enc = encode_image(raw)
if not enc:
return url, None, 0
data, ext = enc
p = IMG_WORK / f"{stem}{ext}"
p.write_bytes(data)
return url, p, len(data)
with ThreadPoolExecutor(max_workers=WORKERS) as ex:
futs = [ex.submit(one, u) for u in urls]
for fut in as_completed(futs):
url, path, sz = fut.result()
if path is not None:
out[url] = (path, sz)
else:
log(f"MISS {url[:90]}")
log(f"encoded {len(out)}/{len(urls)}")
return out
def select_by_budget(
urls_ordered: list[str],
encoded: dict[str, tuple[Path, int]],
budget: int,
max_count: int | None = None,
) -> dict[str, str]:
"""按文中顺序纳入,直到字节预算或张数上限。返回 url -> filename。"""
mapping: dict[str, str] = {}
used = 0
for url in urls_ordered:
if max_count is not None and len(mapping) >= max_count:
break
item = encoded.get(url)
if not item:
continue
path, sz = item
if used + sz > budget:
continue
mapping[url] = path.name
used += sz
log(
f"budget={budget/1024:.0f}KB keep={len(mapping)} used={used/1024:.0f}KB"
+ (f" max_count={max_count}" if max_count else "")
)
return mapping
def rewrite_md(text: str, mapping: dict[str, str], prefix: str) -> str:
def md_sub(m: re.Match) -> str:
alt, url = m.group(1), m.group(2)
name = mapping.get(url)
if not name:
return PLACEHOLDER
return f"![{alt}]({prefix}/{name})"
def html_sub(m: re.Match) -> str:
_b, url, after = m.group(1), m.group(2), m.group(3)
name = mapping.get(url)
if not name:
return PLACEHOLDER
# 统一成 markdown 图语法,避免 raw <img> 被二次 escape
alt_m = re.search(r'alt=["\']([^"\']*)["\']', after or "", re.I)
alt = (alt_m.group(1) if alt_m else "")[:40]
return f"![{alt}]({prefix}/{name})"
text = MD_IMG_RE.sub(md_sub, text)
text = HTML_IMG_RE.sub(html_sub, text)
text = re.sub(r"!\[[^\]]*\]\(file:///[^)]+\)", "", text)
text = re.sub(r"""<img\b[^>]*src=["']file:///[^"']+["'][^>]*>""", "", text, flags=re.I)
return text
def split_chapters(md: str) -> list[dict]:
parts = re.split(r"(?m)^#\s+(.+)$", md)
chapters: list[dict] = []
if parts[0].strip():
chapters.append({"title": "导读", "body": parts[0].strip()})
for i in range(1, len(parts), 2):
title = parts[i].strip()
body = parts[i + 1].strip() if i + 1 < len(parts) else ""
chapters.append({"title": title, "body": f"# {title}\n\n{body}".strip()})
out = []
emojis = ["📖", "🚀", "📱", "🎬", "🛠", "🌐", "💡", "🔥", "📦", "🧭"]
for idx, ch in enumerate(chapters):
title = re.sub(r"[\U00010000-\U0010ffff]", "", ch["title"]).strip()[:40] or "未命名"
slug = re.sub(r"[^A-Za-z0-9\u4e00-\u9fff._-]+", "", title.replace(" ", "-"))[:24] or "ch"
out.append(
{
"id": f"{idx:02d}-{slug}",
"title": title,
"order": idx + 1,
"content": ch["body"],
"emoji": emojis[idx % len(emojis)],
}
)
return out
def copy_selected(mapping: dict[str, str], dest: Path) -> int:
if dest.exists():
shutil.rmtree(dest)
dest.mkdir(parents=True, exist_ok=True)
n = 0
for name in set(mapping.values()):
src = IMG_WORK / name
if src.exists():
shutil.copy2(src, dest / name)
n += 1
return n
def extract_js_object(src: str, var_name: str) -> dict | None:
m = re.search(rf"var\s+{re.escape(var_name)}\s*=\s*", src)
if not m:
return None
i = m.end()
while i < len(src) and src[i] in " \t\r\n":
i += 1
if i >= len(src) or src[i] != "{":
return None
depth = 0
in_str = False
esc = False
quote = ""
for j in range(i, len(src)):
ch = src[j]
if in_str:
if esc:
esc = False
elif ch == "\\":
esc = True
elif ch == quote:
in_str = False
continue
if ch in ('"', "'"):
in_str = True
quote = ch
continue
if ch == "{":
depth += 1
elif ch == "}":
depth -= 1
if depth == 0:
return json.loads(src[i : j + 1])
return None
def format_portal_data_js(portal: dict) -> str:
return (
"/* generated from weapp SoT — offline seed for xhs minitool */\n"
f"var PORTAL_DATA = {json.dumps(portal, ensure_ascii=False, indent=2)};\n"
"var NAV_DATA = PORTAL_DATA.nav;\n"
)
def write_tt(chapters: list[dict], n_img: int) -> None:
meta = {
"id": "default",
"title": "数字游民:地理套利与自动化杠杆",
"subtitle": "低成本工作室",
"author": "异度世界",
"cover_emoji": "🚀",
"description": "云手机集群 / TikTok 无人直播 / YouTube 自动化。配图按抖音分包 2MB 上限精选固化。",
"tags": ["数字游民", "云手机", "无人直播", "自动化"],
"price_fen": 0,
"product_id": "ebook_default",
"unlock_percent": 100,
"is_free": True,
"chapter_count": len(chapters),
"word_count": sum(len(c["content"]) for c in chapters),
"rating": 0,
"chapters": [{"id": c["id"], "title": c["title"], "order": c["order"]} for c in chapters],
}
read_chapters = [
{
"id": c["id"],
"title": c["title"],
"order": c["order"],
"emoji": c["emoji"],
"content": c["content"],
"unlocked": True,
}
for c in chapters
]
cover = {
"title": meta["title"],
"subtitle": meta["subtitle"],
"author": meta["author"],
"description": meta["description"],
"tagline": "关注公众号异度世界 · 私信加群",
"viralTags": meta["tags"],
"readingMinutes": max(30, meta["word_count"] // 400),
"coverGradient": "from-slate-950 via-cyan-950 to-amber-900",
"stats": [
{"emoji": "📚", "value": str(len(chapters)), "label": "章节"},
{"emoji": "🖼", "value": str(n_img), "label": "精选图"},
{"emoji": "⏱", "value": str(max(30, meta["word_count"] // 400)), "label": "分钟"},
{"emoji": "📦", "value": "分包", "label": "离线"},
],
"hooks": [
{"emoji": "🚀", "text": "低成本工作室:云手机 × 自动化杠杆"},
{"emoji": "📱", "text": "TikTok / YouTube 实操,配图按体积精选"},
{"emoji": "📣", "text": "完整大图见公众号「异度世界」"},
],
"chapters": [
{
"slug": c["id"],
"title": c["title"],
"emoji": c["emoji"],
"hook": c["title"][:28],
"shareQuote": c["title"][:40],
}
for c in chapters
],
}
nomad_ts = (
"/** hackrobot offline · size-capped book-images in packageBook */\n"
"import type { BookDetail, ReadPayload } from '../services/ebookApi'\n\n"
f"export const NOMAD_CODE_BOOK: BookDetail = {json.dumps(meta, ensure_ascii=False, indent=2)}\n\n"
"export function nomadCodeReadPayload(): ReadPayload {\n"
" return {\n"
f" book: {json.dumps(meta, ensure_ascii=False, indent=2)},\n"
f" chapters: {json.dumps(read_chapters, ensure_ascii=False, indent=2)},\n"
f" progress: {{ chapter_id: {json.dumps(chapters[0]['id'], ensure_ascii=False)}, percent: 0 }},\n"
" access: { unlocked: true, is_free: true },\n"
" } as ReadPayload\n"
"}\n"
)
cover_ts = (
"/** hackrobot cover · size-capped */\n"
"export type CoverStat = { emoji: string; value: string; label: string }\n"
"export type CoverHook = { emoji: string; text: string }\n"
"export type CoverChapter = { slug: string; title: string; emoji: string; hook?: string; shareQuote?: string }\n\n"
f"export const COVER_BOOK = {json.dumps(cover, ensure_ascii=False, indent=2)}\n"
)
for data_dir in (TT_DATA, WEAPP_DATA):
data_dir.mkdir(parents=True, exist_ok=True)
(data_dir / "nomadCodeBook.ts").write_text(nomad_ts, encoding="utf-8")
(data_dir / "coverBook.ts").write_text(cover_ts, encoding="utf-8")
log(f"tt+weapp data chapters={len(chapters)}")
def write_xhs(chapters: list[dict], title: str) -> None:
book = {
"id": "default",
"title": title,
"subtitle": "低成本工作室",
"author": "异度世界",
"coverEmoji": "🚀",
"description": "配图按小红书小工具包体积上限精选固化(禁 CDN)。",
"tags": ["数字游民", "云手机", "无人直播", "自动化"],
"chapters": [
{
"id": c["id"],
"title": c["title"],
"order": c["order"],
"emoji": c["emoji"],
"content": c["content"],
}
for c in chapters
],
}
XHS_BOOK_DATA.parent.mkdir(parents=True, exist_ok=True)
XHS_BOOK_DATA.write_text(
"/* hackrobot offline book · size-capped images */\nvar BOOK_DATA = "
+ json.dumps(book, ensure_ascii=False, indent=2)
+ ";\n",
encoding="utf-8",
)
if not XHS_PORTAL.exists():
return
portal_src = XHS_PORTAL.read_text(encoding="utf-8")
portal = extract_js_object(portal_src, "PORTAL_DATA")
if not portal:
log("WARN cannot parse PORTAL_DATA")
return
# app.js 读 portal.book(顶层),不是 config.modules.book
portal["book"] = {
"title": book["title"],
"subtitle": book["subtitle"],
"author": book["author"],
"description": book["description"],
"tagline": "关注公众号异度世界 · 私信加群",
"tags": book["tags"],
"chapters": [
{
"id": c["id"],
"title": c["title"],
"body": c["content"],
}
for c in chapters
],
}
portal["cover"] = {
"title": book["title"],
"subtitle": book["subtitle"],
"author": book["author"],
"description": book["description"],
"tagline": "关注公众号异度世界 · 私信加群",
"viralTags": book["tags"],
"hooks": [
"🚀 低成本工作室:云手机 × 自动化杠杆",
"📱 TikTok / YouTube 实操,配图按体积精选",
"📣 完整大图见公众号「异度世界」",
],
}
modules = (portal.get("config") or {}).get("modules") or {}
book_mod = modules.get("book") or {}
if "chapters" in book_mod or "body" in str(book_mod):
modules["book"] = {
"enabled": book_mod.get("enabled", True),
"title": book_mod.get("title") or "数字游民小册",
"emoji": book_mod.get("emoji") or "📖",
"desc": book_mod.get("desc") or "离线阅读",
}
if portal.get("config"):
portal["config"]["modules"] = modules
XHS_PORTAL.write_text(format_portal_data_js(portal), encoding="utf-8")
log(f"xhs portal.book patched chapters={len(chapters)}")
def main() -> None:
t0 = time.time()
if not SRC_MD.exists():
raise SystemExit(f"missing {SRC_MD} — fetch from server first")
text = SRC_MD.read_text(encoding="utf-8")
urls = extract_urls(text)
log(f"urls_ordered={len(urls)}")
log(f"budgets TT_img={TT_IMG_BUDGET/1024:.0f}KB XHS_img={XHS_IMG_BUDGET/1024:.0f}KB")
encoded = download_encode(urls)
map_tt = select_by_budget(urls, encoded, TT_IMG_BUDGET)
map_xhs = select_by_budget(urls, encoded, XHS_IMG_BUDGET, max_count=XHS_IMG_MAX_COUNT)
# 抖音:分包内路径 /packageBook/assets/book-images/xxx
md_tt = rewrite_md(text, map_tt, "/packageBook/assets/book-images")
md_xhs = rewrite_md(text, map_xhs, "./images")
ch_tt = split_chapters(md_tt)
ch_xhs = split_chapters(md_xhs)
n_tt = copy_selected(map_tt, TT_IMG)
n_xhs = copy_selected(map_xhs, XHS_IMG)
write_tt(ch_tt, n_tt)
write_xhs(ch_xhs, "数字游民:地理套利与自动化杠杆")
report = {
"urls": len(urls),
"encoded": len(encoded),
"tt_imgs": n_tt,
"tt_budget_kb": TT_IMG_BUDGET // 1024,
"tt_used_kb": sum((IMG_WORK / n).stat().st_size for n in set(map_tt.values()) if (IMG_WORK / n).exists()) // 1024,
"xhs_imgs": n_xhs,
"xhs_budget_kb": XHS_IMG_BUDGET // 1024,
"xhs_used_kb": sum((IMG_WORK / n).stat().st_size for n in set(map_xhs.values()) if (IMG_WORK / n).exists()) // 1024,
"seconds": round(time.time() - t0, 1),
"limits": {
"douyin": "main≤4MB sub≤2MB total≤16MB",
"xhs": "offline pack ≤10MB & ≤200 files; no CDN",
},
}
(WORK / "pack-report.json").write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")
log(json.dumps(report, ensure_ascii=False))
log(f"done {time.time()-t0:.1f}s")
if __name__ == "__main__":
main()

View File

@ -38,10 +38,12 @@ const tabBar = {
}
/**
* 对齐 H5:默认无 tabBar(门户是自由跳转,不是五 Tab App)
* 若以后要开 Tab,设 TARO_APP_TABBAR=1
* H5 / 微信:默认无原生 tabBar(首页入口卡片跳转)。
* 仅当显式 TARO_APP_TABBAR=1 时才挂五 Tab。
*/
const wantTabBar = process.env.TARO_APP_TABBAR === '1'
const isH5 =
process.env.TARO_ENV === 'h5' || process.env.TARO_APP_TARGET === 'h5'
const wantTabBar = !isH5 && process.env.TARO_APP_TABBAR === '1'
export default defineAppConfig({
pages: [
@ -58,10 +60,10 @@ export default defineAppConfig({
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#0a0e17',
navigationBarTitleText: 'Nomadro',
navigationBarBackgroundColor: '#0c0c0f',
navigationBarTitleText: 'nomadro',
navigationBarTextStyle: 'white',
backgroundColor: '#0a0e17',
backgroundColor: '#0c0c0f',
},
...(wantTabBar ? { tabBar } : {}),
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,38 +1,23 @@
import { useEffect, useMemo, useState } from 'react'
import Taro, { usePageScroll } from '@tarojs/taro'
import { Image } from '@tarojs/components'
import { usePageScroll } from '@tarojs/taro'
import { H5Box, H5Txt } from './H5Box'
import {
applyH5Theme,
getStoredH5Theme,
type H5Theme,
} from '../utils/h5Theme'
import { goPage } from '../utils/nav'
import { getSafeAreaMetrics } from '../utils/safeArea'
const LOGO_SVG = `<svg class="logo-icon" viewBox="0 0 40 40" fill="none" aria-hidden="true">
<circle cx="20" cy="20" r="18" stroke="url(#logoGrad)" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="url(#logoGrad)" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="url(#logoGrad)"/>
<defs>
<linearGradient id="logoGrad" x1="0" y1="0" x2="40" y2="40">
<stop offset="0%" stop-color="#FF6B6B"/>
<stop offset="50%" stop-color="#FFE66D"/>
<stop offset="100%" stop-color="#4ECDC4"/>
</linearGradient>
</defs>
<circle cx="20" cy="20" r="18" stroke="#f06664" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="#f06664" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="#f06664"/>
</svg>`
const isH5 = process.env.TARO_ENV === 'h5'
function go(url: string) {
if (isH5 && url.includes('/pages/index')) {
Taro.redirectTo({ url }).catch(() => Taro.navigateTo({ url }))
return
}
Taro.navigateTo({ url }).catch(() =>
Taro.redirectTo({ url }).catch(() => Taro.reLaunch({ url })),
)
}
/**
* 社区/小册顶栏:logo + 主题切换(H5 / 微信 / 抖音同一套视觉)
* 小程序端 logo 用 CSS 圆标(View innerHTML SVG 不渲染)
@ -88,14 +73,11 @@ export function CommunityNavbar() {
: undefined
}
>
<H5Box className="logo" onClick={() => go('/pages/index/index')} aria-label="返回首页">
<H5Box className="logo" onClick={() => goPage('/pages/index/index')} aria-label="返回首页">
{isH5 ? (
<H5Box html={LOGO_SVG} />
) : (
<H5Box className="hub-logo-mark" aria-hidden>
<H5Box className="hub-logo-mark-ring" />
<H5Box className="hub-logo-mark-dot" />
</H5Box>
<Image className="hub-logo-img" src="/icons/nomadro.webp" mode="aspectFit" />
)}
<H5Txt>nomadro</H5Txt>
</H5Box>
@ -116,11 +98,15 @@ export function BrandNav({
const label = section || chip || '社群'
return (
<H5Box className="portal-topbar">
<H5Box className="portal-logo" onClick={() => go('/pages/index/index')}>
<H5Box
className="portal-logo-svg"
html={LOGO_SVG.replace('logo-icon', 'portal-mark').replace(/logoGrad/g, 'portalGrad')}
/>
<H5Box className="portal-logo" onClick={() => goPage('/pages/index/index')}>
{isH5 ? (
<H5Box
className="portal-logo-svg"
html={LOGO_SVG.replace('logo-icon', 'portal-mark')}
/>
) : (
<Image className="hub-logo-img" src="/icons/nomadro.webp" mode="aspectFit" />
)}
<H5Txt className="portal-brand">nomadro</H5Txt>
<H5Txt className="portal-sep">/</H5Txt>
<H5Txt className="portal-section">{label}</H5Txt>

View File

@ -2,22 +2,11 @@ import { H5Box, H5Txt } from './H5Box'
import './NomadroLoader.scss'
const LOGO_SVG = `<svg class="nd-loader-mark" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<defs>
<linearGradient id="ndLoaderGrad" x1="0" y1="0" x2="80" y2="80">
<stop offset="0%" stop-color="#FF6B6B"/>
<stop offset="50%" stop-color="#FFE66D"/>
<stop offset="100%" stop-color="#4ECDC4"/>
</linearGradient>
<radialGradient id="ndLoaderGlow" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#4ECDC4" stop-opacity="0.35"/>
<stop offset="100%" stop-color="#4ECDC4" stop-opacity="0"/>
</radialGradient>
</defs>
<circle cx="40" cy="40" r="36" fill="url(#ndLoaderGlow)"/>
<circle class="nd-loader-ring" cx="40" cy="40" r="34" stroke="url(#ndLoaderGrad)" stroke-width="3" stroke-dasharray="54 160" stroke-linecap="round"/>
<circle cx="40" cy="40" r="22" stroke="url(#ndLoaderGrad)" stroke-width="2" stroke-opacity="0.35"/>
<path d="M24 44c8-16 24-16 32 0" stroke="url(#ndLoaderGrad)" stroke-width="2.8" stroke-linecap="round" fill="none"/>
<circle cx="56" cy="28" r="4.5" fill="url(#ndLoaderGrad)"/>
<circle cx="40" cy="40" r="36" fill="rgba(240,102,100,0.12)"/>
<circle class="nd-loader-ring" cx="40" cy="40" r="34" stroke="#f06664" stroke-width="3" stroke-dasharray="54 160" stroke-linecap="round"/>
<circle cx="40" cy="40" r="22" stroke="#f06664" stroke-width="2" stroke-opacity="0.35"/>
<path d="M24 44c8-16 24-16 32 0" stroke="#f06664" stroke-width="2.8" stroke-linecap="round" fill="none"/>
<circle cx="56" cy="28" r="4.5" fill="#f06664"/>
</svg>`
type Props = {
@ -27,7 +16,7 @@ type Props = {
hidden?: boolean
}
/** 全站加载:珊瑚→金→青绿,H5 / 微信 / 抖音同一套 SVG */
/** 全站加载:小红书同源红标,H5 / 微信 / 抖音同一套 SVG */
export function NomadroLoader({
brand = 'nomadro',
tip = '随处工作 · 自由生活',

View File

@ -1,70 +1,75 @@
/* 微信:已加入 pxExclude,禁止 px→rpx 半宽塌缩;H5 同步用真实 px */
.woa-root {
position: fixed;
inset: 0;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1200;
display: flex;
align-items: flex-end;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 1rem;
padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
padding: 16px 12px;
padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
box-sizing: border-box;
}
@media (min-width: 640px) {
.woa-root {
align-items: center;
}
}
.woa-backdrop {
position: absolute;
inset: 0;
background: rgba(10, 14, 23, 0.62);
backdrop-filter: blur(6px);
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(10, 14, 23, 0.72);
}
.woa-card {
position: relative;
z-index: 1;
width: min(100%, 380px);
padding: 1.5rem 1.35rem 1.25rem;
border-radius: 18px;
width: 94%;
max-width: 440px;
margin: 0 auto;
padding: 32px 24px 20px;
border-radius: 20px;
border: 1px solid rgba(255, 255, 255, 0.1);
background:
radial-gradient(90% 70% at 50% -20%, rgba(78, 205, 196, 0.16), transparent 55%),
radial-gradient(70% 50% at 100% 0%, rgba(255, 107, 107, 0.12), transparent 50%),
rgba(17, 24, 39, 0.94);
rgba(17, 24, 39, 0.96);
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
box-sizing: border-box;
text-align: center;
}
.woa-close {
position: absolute;
top: 10px;
right: 10px;
width: 36px;
height: 36px;
border-radius: 10px;
top: 12px;
right: 12px;
width: 40px;
height: 40px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.06);
display: flex;
align-items: center;
justify-content: center;
color: #94a3b8;
font-size: 14px;
font-size: 16px;
}
.woa-eyebrow {
display: block;
font-size: 0.75rem;
font-size: 13px;
letter-spacing: 0.12em;
color: #94a3b8;
margin-bottom: 0.35rem;
margin-bottom: 8px;
padding-right: 32px;
}
.woa-title {
display: block;
font-size: 1.35rem;
font-size: 26px;
font-weight: 700;
color: #f1f5f9;
line-height: 1.35;
@ -77,35 +82,61 @@
.woa-lead {
display: block;
margin-top: 0.5rem;
font-size: 0.9rem;
margin-top: 10px;
font-size: 15px;
color: #94a3b8;
line-height: 1.5;
line-height: 1.55;
padding: 0 6px;
}
/* official-account 最小宽 300px、高 84px */
.woa-official {
margin: 16px auto 0;
width: 100%;
min-width: 300px;
max-width: 100%;
overflow: hidden;
border-radius: 10px;
}
.woa-qr-wrap {
margin: 1.1rem auto 0.85rem;
margin: 20px auto 14px;
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
justify-content: center;
gap: 12px;
width: 100%;
}
.woa-qr {
width: 180px;
height: 180px;
border-radius: 12px;
width: 280px;
height: 280px;
border-radius: 14px;
background: #fff;
}
.woa-qr-hint {
font-size: 0.78rem;
font-size: 14px;
color: #94a3b8;
text-align: center;
line-height: 1.4;
}
.woa-qr-kw {
font-size: 16px;
font-weight: 700;
color: #4ecdc4;
text-align: center;
line-height: 1.4;
}
.woa-later {
text-align: center;
padding: 0.65rem;
font-size: 0.85rem;
padding: 14px 16px;
margin-top: 4px;
font-size: 15px;
color: #94a3b8;
border-radius: 12px;
background: rgba(255, 255, 255, 0.04);
}

View File

@ -1,8 +1,17 @@
import { View, Text, Image } from '@tarojs/components'
import { useState } from 'react'
import Taro from '@tarojs/taro'
import { View, Text, Image, OfficialAccount } from '@tarojs/components'
import qrImg from '../assets/wechat-oa-qr.png'
import './WechatOaModal.scss'
/** 对齐门户 WechatOaModal:关注公众号二维码 */
/** 公众号:异度世界(二维码固化于 assets/wechat-oa-qr.png) */
export const WECHAT_OA_NAME = '异度世界'
export const WECHAT_OA_KEYWORD = '加群'
const QR_SRC = qrImg as string
const isWeapp = process.env.TARO_ENV === 'weapp'
/** 对齐门户:关注公众号二维码 → 私信加群 */
export function WechatOaModal({
open,
onClose,
@ -10,8 +19,17 @@ export function WechatOaModal({
open: boolean
onClose: () => void
}) {
const [oaOk, setOaOk] = useState(true)
if (!open) return null
const previewQr = () => {
if (!isWeapp) return
// image 内嵌二维码不能长按识别;previewImage 支持长按识别公众号
// https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewImage.html
void Taro.previewImage({ urls: [QR_SRC], current: QR_SRC })
}
return (
<View className='woa-root' catchMove>
<View className='woa-backdrop' onClick={onClose} />
@ -21,12 +39,38 @@ export function WechatOaModal({
</View>
<Text className='woa-eyebrow'>保持连接</Text>
<Text className='woa-title'>
关注 <Text className='woa-accent'>公众号</Text>
关注 <Text className='woa-accent'>{WECHAT_OA_NAME}</Text>
</Text>
<Text className='woa-lead'>获取出海导航、游民社群与会员更新,扫码即达。</Text>
<Text className='woa-lead'>
获取出海导航、游民社群与会员更新。
</Text>
{/* 需小程序后台「设置 → 关注公众号」关联同主体公众号;仅特定场景展示 */}
{isWeapp && oaOk ? (
<View className='woa-official'>
<OfficialAccount
onLoad={() => setOaOk(true)}
onError={() => setOaOk(false)}
/>
</View>
) : null}
<View className='woa-qr-wrap'>
<Image className='woa-qr' src={qrImg as string} mode='aspectFit' />
<Text className='woa-qr-hint'>搜索公众号「nomadro」</Text>
<Image
className='woa-qr'
src={QR_SRC}
mode='aspectFit'
showMenuByLongpress
onClick={previewQr}
/>
<Text className='woa-qr-hint'>
{isWeapp
? '点按二维码预览,长按识别关注'
: `搜索公众号「${WECHAT_OA_NAME}」`}
</Text>
<Text className='woa-qr-kw'>
关注后私信关键词「{WECHAT_OA_KEYWORD}」
</Text>
</View>
<View className='woa-later' onClick={onClose}>
<Text>稍后再说</Text>

View File

@ -1,121 +1,345 @@
/**
* Auto-packed from apps/ebook/content/book.json — keep in sync with Next /book.
* Run: pnpm pack:nomad-code
*/
/** hackrobot cover · size-capped */
export type CoverStat = { emoji: string; value: string; label: string }
export type CoverHook = { emoji: string; text: string }
export type CoverChapter = {
slug: string
title: string
emoji: string
hook?: string
shareQuote?: string
}
export type CoverChapter = { slug: string; title: string; emoji: string; hook?: string; shareQuote?: string }
export const COVER_BOOK = {
"title": "数字游民",
"subtitle": "远程生活 · 自由工作入门",
"author": "林远",
"description": "离开工位、带着电脑去看世界——一边工作,一边把日子过成自己想要的样子。",
"tagline": "在任意城市,过你想要的生活。",
"title": "数字游民:地理套利与自动化杠杆",
"subtitle": "低成本工作室",
"author": "异度世界",
"description": "云手机集群 / TikTok 无人直播 / YouTube 自动化。配图按抖音分包 2MB 上限精选固化。",
"tagline": "关注公众号异度世界 · 私信加群",
"viralTags": [
"数字游民",
"远程办公",
"旅居生活",
"自由职业",
"边走边工作"
"云手机",
"无人直播",
"自动化"
],
"readingMinutes": 45,
"coverGradient": "from-violet-950 via-fuchsia-900 to-orange-900",
"readingMinutes": 249,
"coverGradient": "from-slate-950 via-cyan-950 to-amber-900",
"stats": [
{
"emoji": "🌍",
"value": "7",
"label": "章精华"
"emoji": "📚",
"value": "41",
"label": "章节"
},
{
"emoji": "⏱️",
"value": "45",
"label": "分钟读完"
"emoji": "🖼",
"value": "114",
"label": "精选图"
},
{
"emoji": "📍",
"value": "3+",
"label": "城市灵感"
"emoji": "⏱",
"value": "249",
"label": "分钟"
},
{
"emoji": "🔥",
"value": "12",
"label": "书摘片段"
"emoji": "📦",
"value": "分包",
"label": "离线"
}
],
"hooks": [
{
"emoji": "☀️",
"text": "远程办公的第一周,效率奇高。第二周,你开始分不清「工作结束」和「生活开始」。"
"emoji": "🚀",
"text": "低成本工作室:云手机 × 自动化杠杆"
},
{
"emoji": "🌴",
"text": "清迈的周二早晨:一杯咖啡、一台电脑,旁边有人在写旅行笔记。"
"emoji": "📱",
"text": "TikTok / YouTube 实操,配图按体积精选"
},
{
"emoji": "🏡",
"text": "真正的安全感,是无论走到哪里,熟悉的文件与习惯都还在。"
},
{
"emoji": "🌏",
"text": "城市可以换,节奏可以自己定——这才是边走边工作的味道。"
"emoji": "📣",
"text": "完整大图见公众号「异度世界」"
}
],
"chapters": [
{
"slug": "00-preface",
"title": "序:我想换一种活法",
"emoji": "✈️",
"hook": "我想要的不是更好的工位,而是可以选择坐在哪里。",
"shareQuote": "数字游民是一种工作方式:产出不绑定在某个地理坐标上。"
"slug": "00-前言",
"title": "前言",
"emoji": "📖",
"hook": "前言",
"shareQuote": "前言"
},
{
"slug": "01-first-remote",
"title": "第一次远程办公的那个周五",
"emoji": "🏠",
"hook": "穿着睡衣开视频会,可能是当代最魔幻的上班方式。",
"shareQuote": "异步沟通:不是「随时在线」,而是「明确预期」。"
"slug": "01-数字游民自动化杠杆副业",
"title": "数字游民:自动化杠杆副业",
"emoji": "🚀",
"hook": "数字游民:自动化杠杆副业",
"shareQuote": "数字游民:自动化杠杆副业"
},
{
"slug": "02-chiangmai",
"title": "清迈的周二早晨",
"emoji": "☕",
"hook": "旅居不是一个人流浪,是在流动中找到同类。",
"shareQuote": "在这里,旅游和工作本来就不矛盾。"
"slug": "02-低成本工作室",
"title": "低成本工作室",
"emoji": "📱",
"hook": "低成本工作室",
"shareQuote": "低成本工作室"
},
{
"slug": "03-gear",
"title": "行囊里真正重要的东西",
"emoji": "🎒",
"hook": "带多了是负担,带少了会后悔——这是旅居者的永恒命题。",
"shareQuote": "网络,比护照更重要。"
"slug": "03-只谈赚钱不讲技术",
"title": "只谈赚钱,不讲技术",
"emoji": "🎬",
"hook": "只谈赚钱,不讲技术",
"shareQuote": "只谈赚钱,不讲技术"
},
{
"slug": "04-homelab",
"title": "把熟悉的数字生活带在身边",
"emoji": "🗂️",
"hook": "一张旧电脑、一套自己的空间,也能成为随时回去的「数字家」。",
"shareQuote": "完美是优秀的敌人。先跑起来,再迭代。"
"slug": "04-Youtube才是普通人出海的最佳选择",
"title": "Youtube才是普通人出海的最佳选择",
"emoji": "🛠",
"hook": "Youtube才是普通人出海的最佳选择",
"shareQuote": "Youtube才是普通人出海的最佳选择"
},
{
"slug": "05-network",
"title": "无论在哪,都能连回家",
"emoji": "🔗",
"hook": "人在巴厘岛,重要的东西仍在熟悉的地方。",
"shareQuote": "安全访问,是远程生活的底气。"
"slug": "05-Tiktok无人直播",
"title": "Tiktok无人直播",
"emoji": "🌐",
"hook": "Tiktok无人直播",
"shareQuote": "Tiktok无人直播"
},
{
"slug": "06-epilogue",
"title": "终章:自由是一种日常",
"emoji": "🌅",
"hook": "自由不是不用工作,而是可以选择在哪里、以什么节奏工作。",
"shareQuote": "小步验证,比宏大计划更可靠。"
"slug": "06-独立开发者",
"title": "独立开发者",
"emoji": "💡",
"hook": "独立开发者",
"shareQuote": "独立开发者"
},
{
"slug": "07-云手机搭建",
"title": "云手机搭建",
"emoji": "🔥",
"hook": "云手机搭建",
"shareQuote": "云手机搭建"
},
{
"slug": "08-vps云服务器",
"title": "vps云服务器",
"emoji": "📦",
"hook": "vps云服务器",
"shareQuote": "vps云服务器"
},
{
"slug": "09-RPA自动化",
"title": "RPA自动化",
"emoji": "🧭",
"hook": "RPA自动化",
"shareQuote": "RPA自动化"
},
{
"slug": "10-赚美金-收款与提现",
"title": "赚美金: 收款与提现",
"emoji": "📖",
"hook": "赚美金: 收款与提现",
"shareQuote": "赚美金: 收款与提现"
},
{
"slug": "11-远程办公-随时随地",
"title": "远程办公: 随时随地",
"emoji": "🚀",
"hook": "远程办公: 随时随地",
"shareQuote": "远程办公: 随时随地"
},
{
"slug": "12-地理套利",
"title": "地理套利",
"emoji": "📱",
"hook": "地理套利",
"shareQuote": "地理套利"
},
{
"slug": "13-分布式团队",
"title": "分布式团队",
"emoji": "🎬",
"hook": "分布式团队",
"shareQuote": "分布式团队"
},
{
"slug": "14-数字游民的一天",
"title": "数字游民的一天",
"emoji": "🛠",
"hook": "数字游民的一天",
"shareQuote": "数字游民的一天"
},
{
"slug": "15-产品化",
"title": "产品化",
"emoji": "🌐",
"hook": "产品化",
"shareQuote": "产品化"
},
{
"slug": "16-一部手机走天下",
"title": "一部手机走天下",
"emoji": "💡",
"hook": "一部手机走天下",
"shareQuote": "一部手机走天下"
},
{
"slug": "17-电商独立站",
"title": "电商独立站",
"emoji": "🔥",
"hook": "电商独立站",
"shareQuote": "电商独立站"
},
{
"slug": "18-Youtube无人直播2",
"title": "Youtube无人直播2",
"emoji": "📦",
"hook": "Youtube无人直播2",
"shareQuote": "Youtube无人直播2"
},
{
"slug": "19-Tiktok无人直播2",
"title": "Tiktok无人直播2",
"emoji": "🧭",
"hook": "Tiktok无人直播2",
"shareQuote": "Tiktok无人直播2"
},
{
"slug": "20-如何成为一个数字游民",
"title": "如何成为一个数字游民?",
"emoji": "📖",
"hook": "如何成为一个数字游民?",
"shareQuote": "如何成为一个数字游民?"
},
{
"slug": "21-数字游民社群",
"title": "数字游民社群",
"emoji": "🚀",
"hook": "数字游民社群",
"shareQuote": "数字游民社群"
},
{
"slug": "22-边缘计算",
"title": "边缘计算",
"emoji": "📱",
"hook": "边缘计算",
"shareQuote": "边缘计算"
},
{
"slug": "23-金字塔模型",
"title": "金字塔模型",
"emoji": "🎬",
"hook": "金字塔模型",
"shareQuote": "金字塔模型"
},
{
"slug": "24-副产品",
"title": "副产品",
"emoji": "🛠",
"hook": "副产品",
"shareQuote": "副产品"
},
{
"slug": "25-买号刷量设备",
"title": "买号/刷量/设备",
"emoji": "🌐",
"hook": "买号/刷量/设备",
"shareQuote": "买号/刷量/设备"
},
{
"slug": "26-独立开发者-saas",
"title": "独立开发者: saas",
"emoji": "💡",
"hook": "独立开发者: saas",
"shareQuote": "独立开发者: saas"
},
{
"slug": "27-AI",
"title": "AI",
"emoji": "🔥",
"hook": "AI",
"shareQuote": "AI"
},
{
"slug": "28-数字员工",
"title": "数字员工",
"emoji": "📦",
"hook": "数字员工",
"shareQuote": "数字员工"
},
{
"slug": "29-AI算力工作室",
"title": "AI算力工作室",
"emoji": "🧭",
"hook": "AI算力工作室",
"shareQuote": "AI算力工作室"
},
{
"slug": "30-一键懒人包",
"title": "一键懒人包",
"emoji": "📖",
"hook": "一键懒人包",
"shareQuote": "一键懒人包"
},
{
"slug": "31-web-pannel",
"title": "web pannel",
"emoji": "🚀",
"hook": "web pannel",
"shareQuote": "web pannel"
},
{
"slug": "32-增长黑客",
"title": "增长黑客",
"emoji": "📱",
"hook": "增长黑客",
"shareQuote": "增长黑客"
},
{
"slug": "33-定制安卓系统",
"title": "定制安卓/系统",
"emoji": "🎬",
"hook": "定制安卓/系统",
"shareQuote": "定制安卓/系统"
},
{
"slug": "34-赚美金的底层逻辑",
"title": "赚美金的底层逻辑",
"emoji": "🛠",
"hook": "赚美金的底层逻辑",
"shareQuote": "赚美金的底层逻辑"
},
{
"slug": "35-旅居",
"title": "旅居",
"emoji": "🌐",
"hook": "旅居",
"shareQuote": "旅居"
},
{
"slug": "36-数字游民的一天2",
"title": "数字游民的一天(2)",
"emoji": "💡",
"hook": "数字游民的一天(2)",
"shareQuote": "数字游民的一天(2)"
},
{
"slug": "37-低成本工作室2",
"title": "低成本工作室(2)",
"emoji": "🔥",
"hook": "低成本工作室(2)",
"shareQuote": "低成本工作室(2)"
},
{
"slug": "38-Youtube无人直播收益",
"title": "Youtube无人直播收益",
"emoji": "📦",
"hook": "Youtube无人直播收益",
"shareQuote": "Youtube无人直播收益"
},
{
"slug": "39-产品3件套",
"title": "产品3件套",
"emoji": "🧭",
"hook": "产品3件套",
"shareQuote": "产品3件套"
},
{
"slug": "40-懒人包2",
"title": "懒人包2",
"emoji": "📖",
"hook": "懒人包2",
"shareQuote": "懒人包2"
}
]
} as const
}

View File

@ -537,6 +537,7 @@
"id": "books",
"title": "书籍",
"emoji": "◈",
"hidden": true,
"groups": [
{
"id": "handbook",

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,6 @@
.book-hero-title {
margin-bottom: 0 !important;
text-align: center;
animation: bookFadeUp 0.65s ease 0.06s both;
}
.book-title-brand {
@ -83,7 +82,6 @@
line-height: 1;
letter-spacing: 0.08em;
text-align: center;
animation: bookFadeUp 0.55s ease 0.12s both;
}
.book-typewriter {
@ -99,7 +97,6 @@
overflow: hidden;
text-align: center !important;
color: var(--text-secondary);
animation: bookFadeUp 0.55s ease 0.18s both;
}
.typewriter-cursor {
@ -117,7 +114,6 @@
margin: 4px auto 0;
overflow: visible;
cursor: pointer;
animation: bookFadeUp 0.7s ease 0.2s both;
}
.book-visual-host {

View File

@ -18,6 +18,7 @@ import { MiniModuleGate } from '@/components/MiniModuleGate'
import { CommunityNavbar } from '../../components/Chrome'
import { H5Box, H5Txt } from '../../components/H5Box'
import { applyH5Theme, useNomadroTheme } from '../../utils/h5Theme'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import { getSafeAreaMetrics } from '../../utils/safeArea'
import './index.scss'
@ -122,6 +123,7 @@ function BookPageInner() {
applyH5Theme(theme)
}, [theme])
// 对齐小红书 startTypewriter:hooks 轮播打字机
useEffect(() => {
if (loading) return
const phrases = HOOK_LINES.length ? HOOK_LINES : [COVER_BOOK.subtitle]
@ -246,10 +248,8 @@ function BookPageInner() {
? '点一下,直接进入正文'
: '先翻开前面的章节'
const tagline = COVER_BOOK.tagline.replace(/。$/, '')
const tagParts = tagline.includes(',')
? tagline.split(',')
: [book.subtitle || '数字游民', tagline]
/** 封面副标题只保留「低成本工作室」,不拼公众号引导(与弹窗重复) */
const tagParts = [book.subtitle || COVER_BOOK.subtitle || '低成本工作室']
const safe = useMemo(() => getSafeAreaMetrics(), [])
const safeStyle = useMemo(
() => ({
@ -283,12 +283,6 @@ function BookPageInner() {
<H5Txt className="hero-title-line book-title-brand">{COVER_BOOK.title}</H5Txt>
<H5Box className="hero-title-line book-tagline">
<H5Txt>{tagParts[0]}</H5Txt>
{tagParts[1] ? (
<>
<H5Txt>,</H5Txt>
<H5Txt className="gradient-text">{tagParts[1]}</H5Txt>
</>
) : null}
</H5Box>
</H5Box>
@ -343,10 +337,14 @@ function BookPageInner() {
)
}
export default function BookPage() {
function BookPage() {
usePageShare({ title: 'nomadro · 数字游民小册', path: '/pages/book/index' })
return (
<MiniModuleGate moduleKey="book">
<BookPageInner />
</MiniModuleGate>
)
}
export default markPageShare(BookPage)

View File

@ -11,6 +11,7 @@ import { WechatOaModal } from '../../components/WechatOaModal'
import { TYPEWRITER_LINES, TYPEWRITER_LINES_EN } from '../../data/homeStatic'
import { MiniModuleGate } from '@/components/MiniModuleGate'
import { useNomadroTheme } from '@/utils/h5Theme'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import { getSafeAreaMetrics } from '@/utils/safeArea'
import './index.scss'
@ -221,10 +222,14 @@ function HomePageInner() {
)
}
export default function HomePage() {
function HomePage() {
usePageShare({ title: 'nomadro · 旅居社群', path: '/pages/community/index' })
return (
<MiniModuleGate moduleKey="community">
<HomePageInner />
</MiniModuleGate>
)
}
export default markPageShare(HomePage)

View File

@ -1 +1,3 @@
export default definePageConfig({ navigationBarTitleText: '城市详情' })
export default definePageConfig({
navigationBarTitleText: '目的地详情',
})

View File

@ -3,13 +3,15 @@ import Taro, { useLoad, useRouter } from '@tarojs/taro'
import { useState } from 'react'
import { BrandNav, SiteFooter } from '../../components/Chrome'
import { fetchDestination, type Destination } from '../../services/api'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import './index.scss'
function hueBg(hue = 170) {
return `linear-gradient(160deg, hsl(${hue}, 42%, 24%), hsl(${hue}, 30%, 10%))`
}
export default function DestinationPage() {
function DestinationPage() {
usePageShare({ title: 'nomadro · 城市详情', path: '/pages/destination/index' })
const router = useRouter()
const [d, setD] = useState<Destination | null>(null)
const [err, setErr] = useState('')
@ -73,3 +75,5 @@ export default function DestinationPage() {
</ScrollView>
)
}
export default markPageShare(DestinationPage)

View File

@ -1 +1,3 @@
export default definePageConfig({ navigationBarTitleText: '目的地' })
export default definePageConfig({
navigationBarTitleText: '目的地',
})

View File

@ -4,9 +4,11 @@ import { useState } from 'react'
import { BrandNav, SiteFooter } from '../../components/Chrome'
import { DestinationsSection } from '../../components/DestinationsSection'
import { fetchDestinations, type Destination } from '../../services/api'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import './index.scss'
export default function DestinationsPage() {
function DestinationsPage() {
usePageShare({ title: 'nomadro · 目的地', path: '/pages/destinations/index' })
const [list, setList] = useState<Destination[]>([])
const [err, setErr] = useState('')
const [loading, setLoading] = useState(true)
@ -32,3 +34,5 @@ export default function DestinationsPage() {
</ScrollView>
)
}
export default markPageShare(DestinationsPage)

View File

@ -3,7 +3,7 @@
* H5 关键布局用原生 div(Taro View 自定义元素会弄塌 grid/绝对定位)。
*/
import { useEffect, useMemo, useState, type CSSProperties, type ReactNode } from 'react'
import { View, Text } from '@tarojs/components'
import { View, Text, Image } from '@tarojs/components'
import Taro, { usePageScroll } from '@tarojs/taro'
import {
isModuleEnabled,
@ -11,6 +11,8 @@ import {
} from '@/services/remoteConfig'
import type { NomadroRemoteConfig } from '@/data/remoteConfig.defaults'
import { applyH5Theme, useNomadroTheme } from '@/utils/h5Theme'
import { goPage } from '@/utils/nav'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import { getSafeAreaMetrics } from '@/utils/safeArea'
import './index.scss'
@ -43,16 +45,9 @@ const showQuickNav = false
const isDev = process.env.NODE_ENV === 'development'
const LOGO_SVG = `<svg class="hub-logo-icon" viewBox="0 0 40 40" fill="none" aria-hidden="true">
<circle cx="20" cy="20" r="18" stroke="url(#hubLogoGrad)" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="url(#hubLogoGrad)" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="url(#hubLogoGrad)"/>
<defs>
<linearGradient id="hubLogoGrad" x1="0" y1="0" x2="40" y2="40">
<stop offset="0%" stop-color="#FF6B6B"/>
<stop offset="50%" stop-color="#FFE66D"/>
<stop offset="100%" stop-color="#4ECDC4"/>
</linearGradient>
</defs>
<circle cx="20" cy="20" r="18" stroke="#f06664" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="#f06664" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="#f06664"/>
</svg>`
const GLOBE_SVG = `<svg class="hub-globe-svg" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
@ -81,12 +76,7 @@ const GLOBE_SVG = `<svg class="hub-globe-svg" viewBox="0 0 400 400" xmlns="http:
</svg>`
function goPath(path: string) {
// 对齐 H5:无原生 tabBar
Taro.navigateTo({ url: path }).catch(() => {
Taro.redirectTo({ url: path }).catch(() => {
Taro.reLaunch({ url: path })
})
})
goPage(path)
}
function openDevLink(kind: 'vip' | 'admin' | 'config') {
@ -165,7 +155,9 @@ function Txt({ className, children }: { className?: string; children?: ReactNode
return <Text className={className}>{children}</Text>
}
export default function IndexPage() {
function IndexPage() {
usePageShare({ title: 'nomadro · 随处工作,自由生活', path: '/pages/index/index' })
const [config, setConfig] = useState<NomadroRemoteConfig | null>(null)
const theme = useNomadroTheme()
const [navScrolled, setNavScrolled] = useState(false)
@ -329,10 +321,12 @@ export default function IndexPage() {
{isH5 ? (
<Box className="hub-logo-svg" html={LOGO_SVG} />
) : (
<Box className="hub-logo-mark" aria-hidden>
<Box className="hub-logo-mark-ring" />
<Box className="hub-logo-mark-dot" />
</Box>
<Image
className="hub-logo-img"
src="/icons/nomadro.webp"
mode="aspectFit"
aria-hidden
/>
)}
<Txt className="hub-logo-text">{brand}</Txt>
</Box>
@ -385,9 +379,15 @@ export default function IndexPage() {
</Box>
)}
<Box className="hub-floating-cards" aria-hidden>
<Box className="hub-float-card hub-fc-1">🏝️ 巴厘岛</Box>
<Box className="hub-float-card hub-fc-2">☕ 里斯本</Box>
<Box className="hub-float-card hub-fc-3">🏔️ 清迈</Box>
<Box className="hub-float-card hub-fc-1">
<Txt>🏝️ 巴厘岛</Txt>
</Box>
<Box className="hub-float-card hub-fc-2">
<Txt>☕ 里斯本</Txt>
</Box>
<Box className="hub-float-card hub-fc-3">
<Txt>🏔️ 清迈</Txt>
</Box>
</Box>
</Box>
</Box>
@ -405,7 +405,7 @@ export default function IndexPage() {
onClick={() => goPath(INTERNAL_PORTALS[portal.id])}
>
<Box className="hub-portal-ico" aria-hidden>
{portal.emoji}
<Txt>{portal.emoji}</Txt>
</Box>
<Txt className="hub-portal-name">
{cfg?.modules[portal.moduleKey]?.title || portal.name}
@ -418,3 +418,5 @@ export default function IndexPage() {
</Box>
)
}
export default markPageShare(IndexPage)

View File

@ -1 +1,3 @@
export default definePageConfig({ navigationBarTitleText: '活动' })
export default definePageConfig({
navigationBarTitleText: '聚会',
})

View File

@ -3,9 +3,11 @@ import Taro, { useLoad } from '@tarojs/taro'
import { useMemo, useState } from 'react'
import { BrandNav, SiteFooter } from '../../components/Chrome'
import { fetchMeetups, type Meetup } from '../../services/api'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import './index.scss'
export default function MeetupsPage() {
function MeetupsPage() {
usePageShare({ title: 'nomadro · 活动', path: '/pages/meetups/index' })
const [list, setList] = useState<Meetup[]>([])
const [mode, setMode] = useState<'all' | 'online' | 'offline' | 'hybrid'>('all')
const [fromLocal, setFromLocal] = useState(false)
@ -117,3 +119,5 @@ export default function MeetupsPage() {
</ScrollView>
)
}
export default markPageShare(MeetupsPage)

View File

@ -1 +1,3 @@
export default definePageConfig({ navigationBarTitleText: '我的' })
export default definePageConfig({
navigationBarTitleText: '我的',
})

View File

@ -13,9 +13,11 @@ import {
type Destination,
type ProfileStats,
} from '../../services/api'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import './index.scss'
export default function MinePage() {
function MinePage() {
usePageShare({ title: 'nomadro · 我的', path: '/pages/mine/index' })
const [user, setUser] = useState<AuthUser | null>(null)
const [stats, setStats] = useState<ProfileStats | null>(null)
const [favs, setFavs] = useState<Destination[]>([])
@ -157,3 +159,5 @@ export default function MinePage() {
</ScrollView>
)
}
export default markPageShare(MinePage)

View File

@ -9,6 +9,8 @@ import { MiniModuleGate } from '@/components/MiniModuleGate'
import { H5Box, H5Txt } from '@/components/H5Box'
import config from '@/data/links.json'
import { applyH5Theme, useNomadroTheme } from '@/utils/h5Theme'
import { goHome } from '@/utils/nav'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import { getSafeAreaMetrics } from '@/utils/safeArea'
import './index.scss'
@ -22,7 +24,7 @@ type NavLink = {
action?: LinkAction
}
type NavGroup = { id: string; title: string; links: NavLink[] }
type NavCategory = { id: string; title: string; emoji: string; groups: NavGroup[] }
type NavCategory = { id: string; title: string; emoji: string; groups: NavGroup[]; hidden?: boolean }
type NavConfig = {
brand: string
tagline: string
@ -31,6 +33,8 @@ type NavConfig = {
}
const nav = config as NavConfig
/** 隐藏分类仍保留在 links.json,仅不展示(如 books) */
const visibleCategories = nav.categories.filter((c) => !c.hidden)
const isH5 = process.env.TARO_ENV === 'h5'
function countLinks(cat: NavCategory) {
@ -52,16 +56,9 @@ const MENU_SVG = (open: boolean) =>
</svg>`
const LOGO_SVG = `<svg class="nav-portal-mark" viewBox="0 0 40 40" fill="none" aria-hidden="true">
<circle cx="20" cy="20" r="18" stroke="url(#navPortalGrad)" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="url(#navPortalGrad)" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="url(#navPortalGrad)"/>
<defs>
<linearGradient id="navPortalGrad" x1="0" y1="0" x2="40" y2="40">
<stop offset="0%" stop-color="#FF6B6B"/>
<stop offset="50%" stop-color="#FFE66D"/>
<stop offset="100%" stop-color="#4ECDC4"/>
</linearGradient>
</defs>
<circle cx="20" cy="20" r="18" stroke="#f06664" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="#f06664" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="#f06664"/>
</svg>`
const UP_SVG = `<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
@ -74,11 +71,12 @@ const CLOSE_SVG = `<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
function NavPageInner() {
const theme = useNomadroTheme()
const [activeId, setActiveId] = useState(nav.categories[0]?.id ?? '')
const [activeId, setActiveId] = useState(visibleCategories[0]?.id ?? '')
const [drawerOpen, setDrawerOpen] = useState(false)
const [toast, setToast] = useState('')
const [showTop, setShowTop] = useState(false)
const [pillKey, setPillKey] = useState(0)
const [scrollInto, setScrollInto] = useState('')
const jumpingRef = useRef(false)
const safe = useMemo(() => getSafeAreaMetrics(), [])
const safeStyle = useMemo(
@ -117,7 +115,7 @@ function NavPageInner() {
useEffect(() => {
if (!isH5) return
const sections = nav.categories
const sections = visibleCategories
.map((c) => document.getElementById(`cat-${c.id}`))
.filter((el): el is HTMLElement => !!el)
@ -142,25 +140,32 @@ function NavPageInner() {
}, [])
const activeCategory = useMemo(
() => nav.categories.find((c) => c.id === activeId) ?? nav.categories[0],
() => visibleCategories.find((c) => c.id === activeId) ?? visibleCategories[0],
[activeId],
)
const onOpen = useCallback((link: NavLink) => {
const action = link.action ?? 'open'
if (action === 'copy') {
Taro.setClipboardData({ data: link.href })
.then(() => setToast('已复制'))
.catch(() => setToast('复制失败'))
const href = String(link.href || '').trim()
if (!href) {
void Taro.showToast({ title: '暂无链接', icon: 'none' })
return
}
if (isH5 && typeof window !== 'undefined') {
window.open(link.href, '_blank', 'noopener,noreferrer')
} else {
Taro.setClipboardData({ data: link.href }).then(() => {
Taro.showToast({ title: '链接已复制', icon: 'none' })
})
if (isH5 && typeof window !== 'undefined' && (link.action ?? 'open') === 'open') {
window.open(href, '_blank', 'noopener,noreferrer')
return
}
// 微信 / 抖音:统一复制(抖音官方支持 tt.setClipboardData)
void Taro.setClipboardData({
data: href,
success: () => {
setToast('已复制')
void Taro.showToast({ title: '链接已复制', icon: 'none' })
},
fail: () => {
setToast('复制失败')
void Taro.showToast({ title: '复制失败,请检查隐私授权', icon: 'none' })
},
})
}, [])
const onSelectCategory = useCallback((id: string) => {
@ -175,22 +180,14 @@ function NavPageInner() {
jumpingRef.current = false
}, 700)
} else {
jumpingRef.current = false
setScrollInto(`cat-${id}`)
setTimeout(() => {
setScrollInto('')
jumpingRef.current = false
}, 500)
}
}, [])
function goHome() {
if (isH5) {
Taro.redirectTo({ url: '/pages/index/index' }).catch(() => {
Taro.navigateTo({ url: '/pages/index/index' })
})
} else {
Taro.reLaunch({ url: '/pages/index/index' }).catch(() => {
Taro.redirectTo({ url: '/pages/index/index' })
})
}
}
const body = (
<H5Box className={`app-shell${drawerOpen ? ' drawer-open' : ''}`}>
<H5Box className="bg-glow" aria-hidden>
@ -201,14 +198,14 @@ function NavPageInner() {
<H5Box className="desktop-rail">
<H5Box className="desktop-rail-brand">
<Image src="/icons/_brand.webp" className="desktop-rail-brand-img" mode="aspectFit" />
<Image src="/icons/nomadro.webp" className="desktop-rail-brand-img" mode="aspectFit" />
<H5Box>
<H5Txt className="desktop-rail-title">{nav.brand}</H5Txt>
<H5Txt className="desktop-rail-sub">{nav.tagline}</H5Txt>
</H5Box>
</H5Box>
<H5Box className="desktop-rail-nav">
{nav.categories.map((cat) => {
{visibleCategories.map((cat) => {
const count = countLinks(cat)
const active = cat.id === activeCategory.id
return (
@ -256,10 +253,7 @@ function NavPageInner() {
{isH5 ? (
<H5Box html={LOGO_SVG} />
) : (
<H5Box className="hub-logo-mark" aria-hidden>
<H5Box className="hub-logo-mark-ring" />
<H5Box className="hub-logo-mark-dot" />
</H5Box>
<Image className="hub-logo-img" src="/icons/nomadro.webp" mode="aspectFit" />
)}
<H5Txt className="nav-portal-brand">nomadro</H5Txt>
<H5Txt className="nav-portal-sep">·</H5Txt>
@ -273,7 +267,7 @@ function NavPageInner() {
</H5Box>
<H5Box className="page">
{nav.categories.map((cat) => {
{visibleCategories.map((cat) => {
const count = countLinks(cat)
let flatIndex = 0
return (
@ -329,7 +323,7 @@ function NavPageInner() {
<H5Box className="drawer-head">
<H5Box className="drawer-brand-wrap">
<Image
src={iconSrc('/icons/_brand.webp')}
src={iconSrc('/icons/nomadro.webp')}
style={{ width: 28, height: 28 }}
mode="aspectFit"
/>
@ -343,7 +337,7 @@ function NavPageInner() {
</H5Box>
</H5Box>
<H5Box className="drawer-nav">
{nav.categories.map((cat) => {
{visibleCategories.map((cat) => {
const count = countLinks(cat)
const active = cat.id === activeId
return (
@ -386,6 +380,9 @@ function NavPageInner() {
className="navmini-root"
style={{ height: '100vh', ...safeStyle }}
data-theme={theme}
scrollIntoView={scrollInto}
scrollWithAnimation
enableFlex
>
{body}
</ScrollView>
@ -398,10 +395,14 @@ function NavPageInner() {
)
}
export default function NavPage() {
function NavPage() {
usePageShare({ title: 'nomadro · 出海导航', path: '/pages/nav/index' })
return (
<MiniModuleGate moduleKey="nav">
<NavPageInner />
</MiniModuleGate>
)
}
export default markPageShare(NavPage)

View File

@ -16,6 +16,7 @@ import { MarkdownView } from '../../components/MarkdownView'
import { PayResultSheet } from '../../components/PayResultSheet'
import { ReaderSettings } from '../../components/ReaderSettings'
import { runUnlockPayment } from '../../utils/payFlow'
import { goPage } from '../../utils/nav'
import { mapPayError, successFeedback, type PayFeedback } from '../../utils/payFeedback'
import { track, trackPage, trackPay } from '../../utils/track'
import {
@ -29,6 +30,7 @@ import {
saveReadingProgress,
} from '../../utils/readingProgress'
import { applyH5Theme, getStoredH5Theme } from '../../utils/h5Theme'
import { usePageShare, markPageShare } from '../../utils/pageShare'
import { getSafeAreaMetrics } from '../../utils/safeArea'
import {
CHAPTER_EMOJIS,
@ -43,7 +45,8 @@ import './index.scss'
const TOPBAR_OFFSET = 72
const isH5 = process.env.TARO_ENV === 'h5'
export default function ReaderPage() {
function ReaderPage() {
usePageShare({ title: 'nomadro · 数字游民', path: '/pages/reader/index' })
const router = useRouter()
const bookId = router.params.id || 'default'
const chapterParam = router.params.chapter || ''
@ -776,11 +779,7 @@ export default function ReaderPage() {
</View>
<View
className="fin-btn ghost"
onClick={() =>
Taro.navigateTo({ url: '/pages/book/index' }).catch(() =>
Taro.redirectTo({ url: '/pages/book/index' })
)
}
onClick={() => goPage('/pages/book/index')}
>
<Text>返回封面</Text>
</View>
@ -894,3 +893,5 @@ export default function ReaderPage() {
</View>
)
}
export default markPageShare(ReaderPage)

View File

@ -10,6 +10,8 @@ import { payVirtualProduct } from '@/utils/virtualPay'
import { getCachedRemoteConfig, loadRemoteConfig } from '@/services/remoteConfig'
import type { NomadroRemoteConfig } from '@/data/remoteConfig.defaults'
import { useNomadroTheme } from '@/utils/h5Theme'
import { goHome } from '@/utils/nav'
import { usePageShare, markPageShare } from '@/utils/pageShare'
import { getSafeAreaMetrics } from '@/utils/safeArea'
import './index.scss'
@ -126,16 +128,9 @@ const FAQ_ITEMS = [
const CTA_CHIPS = ['阶梯定价', '数字交付', '持续更新', '不支持退款'] as const
const LOGO_SVG = `<svg class="vip-logoMark" viewBox="0 0 40 40" fill="none" aria-hidden="true">
<circle cx="20" cy="20" r="18" stroke="url(#vipLogoGrad)" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="url(#vipLogoGrad)" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="url(#vipLogoGrad)"/>
<defs>
<linearGradient id="vipLogoGrad" x1="0" y1="0" x2="40" y2="40">
<stop offset="0%" stop-color="#FF6B6B"/>
<stop offset="50%" stop-color="#FFE66D"/>
<stop offset="100%" stop-color="#4ECDC4"/>
</linearGradient>
</defs>
<circle cx="20" cy="20" r="18" stroke="#f06664" stroke-width="2.5"/>
<path d="M12 22c4-8 12-8 16 0" stroke="#f06664" stroke-width="2" stroke-linecap="round"/>
<circle cx="28" cy="14" r="3" fill="#f06664"/>
</svg>`
function formatRestoreDateShort(): string {
@ -144,7 +139,8 @@ function formatRestoreDateShort(): string {
return `${d.getMonth() + 1}月${d.getDate()}日`
}
export default function VipPage() {
function VipPage() {
usePageShare({ title: 'nomadro · VIP 会员', path: '/pages/vip/index' })
return (
<MiniModuleGate moduleKey="vip">
<VipLanding />
@ -152,6 +148,9 @@ export default function VipPage() {
)
}
export default markPageShare(VipPage)
function VipLanding() {
const theme = useNomadroTheme()
const [busy, setBusy] = useState(false)
@ -261,18 +260,6 @@ function VipLanding() {
}
}
function goHome() {
if (isH5) {
Taro.redirectTo({ url: '/pages/index/index' }).catch(() =>
Taro.navigateTo({ url: '/pages/index/index' })
)
return
}
Taro.reLaunch({ url: '/pages/index/index' }).catch(() =>
Taro.redirectTo({ url: '/pages/index/index' })
)
}
return (
<H5Box className="vip-root" data-theme={theme} style={safeStyle}>
<H5Box className="vip-header">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -19,7 +19,7 @@
--hub-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
min-height: 100dvh;
min-height: 100vh;
font-family: var(--hub-font-body);
background: var(--hub-bg);
color: var(--hub-text);
@ -161,6 +161,13 @@ html.light .hub-navbar.scrolled,
animation: hub-spin 20s linear infinite;
}
.hub-logo-img {
width: 28px;
height: 28px;
flex-shrink: 0;
display: block;
}
/* Local-dev only shortcuts */
.hub-dev-nav {
display: flex;
@ -208,7 +215,7 @@ html.light .hub-navbar.scrolled,
position: relative;
z-index: 1;
width: 100%;
min-height: 100svh;
min-height: 100vh;
overflow: hidden;
}
@ -271,7 +278,7 @@ html.light .hub-navbar.scrolled,
z-index: 1;
width: min(1200px, calc(100% - clamp(2rem, 6vw, 5rem)));
margin: 0 auto;
min-height: 100svh;
min-height: 100vh;
display: grid;
grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
grid-template-areas:
@ -559,7 +566,7 @@ html.light .hub-navbar.scrolled,
"portals";
align-content: start;
justify-items: stretch;
min-height: 100svh;
min-height: 100vh;
gap: 0.85rem;
padding-top: calc(var(--hub-nav-height) + 0.85rem);
padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
@ -607,7 +614,7 @@ html.light .hub-navbar.scrolled,
@media (max-width: 640px) {
.hub-hero-inner {
min-height: 100svh;
min-height: 100vh;
gap: 0.65rem;
padding-top: calc(var(--hub-nav-height) + 0.65rem);
}
@ -811,6 +818,12 @@ html.light .nd-theme-toggle,
box-sizing: border-box !important;
}
/* 小程序勿依赖 reveal 动画:部分基础库对复合类/transition 表现异常 → 整页像黑屏 */
.hub-root--mini .hub-reveal {
opacity: 1 !important;
transform: none !important;
}
.hub-root--mini .hub-navbar {
height: auto;
min-height: 0;
@ -950,7 +963,7 @@ html.light .nd-theme-toggle,
width: 28px;
height: 28px;
border-radius: 50%;
border: 2px solid #4ecdc4;
border: 2px solid #f06664;
box-sizing: border-box;
}
@ -961,7 +974,7 @@ html.light .nd-theme-toggle,
width: 6px;
height: 6px;
border-radius: 50%;
background: #ff6b6b;
background: #f06664;
}
.hub-root--mini .hub-hero-visual {
@ -1065,7 +1078,9 @@ html.light .nd-theme-toggle,
width: 100% !important;
max-width: 100% !important;
gap: 8px !important;
margin: 8px 0 0 !important;
/* 三入口整体下移,视觉更松 */
margin: 28px 0 0 !important;
padding-top: 8px !important;
box-sizing: border-box;
}

View File

@ -423,10 +423,12 @@ html {
position: fixed;
inset: 0;
z-index: 60;
pointer-events: none;
/* 抖音等端常忽略 pointer-events,关闭时必须 display:none,否则盖住整页点不到 */
display: none;
}
.drawer-root.open {
display: block;
pointer-events: auto;
}

View File

@ -226,9 +226,12 @@ button.btn-primary::after,
}
.navbar .logo-icon,
.navbar .logo > view:first-child {
.navbar .logo > view:first-child,
.hub-logo-img {
width: 28px !important;
height: 28px !important;
flex-shrink: 0;
display: block !important;
}
/* CSS logo mark(与 hub 一致,供 Chrome / 社群顶栏) */
@ -246,9 +249,9 @@ button.btn-primary::after,
bottom: 0;
left: 0;
border-radius: 50%;
border: 2.5px solid #4ecdc4;
border: 2.5px solid #f06664;
box-sizing: border-box;
background: rgba(10, 14, 23, 0.9);
background: rgba(12, 12, 15, 0.95);
}
.hub-logo-mark-dot {
@ -258,7 +261,7 @@ button.btn-primary::after,
border-radius: 50%;
right: 3px;
top: 4px;
background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
background: #f06664;
}
/* 小册 / 社群 CSS 视觉(替代 View innerHTML SVG) */
@ -407,3 +410,113 @@ button.btn-primary::after,
.book-title-brand {
color: #f1f5f9 !important;
}
/* 小册封面:对齐小红书(标题→副标题→插画→CTA),勿把 visual 提到最前 */
.book-flow .hero-top {
display: flex !important;
flex-direction: column !important;
align-items: center !important;
text-align: center !important;
gap: 10px !important;
}
.book-flow .hero-content {
order: 0 !important;
width: 100% !important;
}
.book-flow .hero-visual {
order: 1 !important;
width: 100% !important;
margin-top: 4px !important;
}
.book-flow .hero-title.book-hero-title {
font-size: 32px !important;
line-height: 1.2 !important;
letter-spacing: -0.02em !important;
margin: 0 0 6px !important;
font-weight: 800 !important;
}
.book-flow .book-title-brand {
display: block !important;
font-size: 32px !important;
line-height: 1.2 !important;
font-weight: 800 !important;
}
.book-flow .book-tagline {
display: block !important;
font-size: 17px !important;
font-weight: 700 !important;
line-height: 1.35 !important;
margin-top: 4px !important;
}
.book-flow .hero-title-spark {
margin: 2px 0 0 !important;
font-size: 18px !important;
}
/* 对齐小红书 xhs-typewriter:标题下打字机,不是隐藏 */
.book-flow .book-typewriter {
display: block !important;
min-height: 2.6em !important;
max-width: 24em !important;
width: 100% !important;
margin: 0 auto !important;
padding: 0 12px !important;
font-size: 14px !important;
color: #94a3b8 !important;
line-height: 1.55 !important;
text-align: center !important;
box-sizing: border-box !important;
}
.book-flow .book-typewriter .typewriter-cursor {
color: #4ecdc4 !important;
}
/* 微信:去掉 bookFadeUp both 后仍兜底,防止封面卡在透明 */
.book-flow .book-hero-title,
.book-flow .hero-title.book-hero-title,
.book-flow .hero-title-spark,
.book-flow .book-typewriter,
.book-flow .book-visual,
.book-flow .book-float-chips .social-chip,
.book-flow .book-cta,
.book-flow .book-cta-hint,
.book-flow .book-title-brand,
.book-flow .book-tagline {
opacity: 1 !important;
transform: none !important;
animation: none !important;
}
/* 自定义顶栏:小程序 Text 不能靠 background-clip 渐变字,给实色 */
.navbar .logo text,
.navbar .logo .taro-text,
.page-shell .logo text {
color: #f1f5f9 !important;
background: none !important;
-webkit-text-fill-color: #f1f5f9 !important;
}
.hub-logo-img {
width: 28px !important;
height: 28px !important;
display: block !important;
flex-shrink: 0 !important;
}
.book-flow .book-visual,
.book-flow .book-visual-css {
width: 200px !important;
max-width: 62vw !important;
margin: 0 auto !important;
}
.book-flow .hero-bottom {
margin-top: 16px !important;
}

View File

@ -0,0 +1,34 @@
import Taro from '@tarojs/taro'
const isH5 = process.env.TARO_ENV === 'h5'
function normalizePath(url: string): string {
const raw = (url || '').split('?')[0]
if (!raw) return ''
return raw.startsWith('/') ? raw : `/${raw}`
}
/**
* 微信默认无 tabBar:一律 navigate / redirect / reLaunch。
* (勿在此读 process.env.TARO_APP_* —— 未注入 Define 时小程序会 ReferenceError: process is not defined)
*/
export function goPage(url: string): void {
const path = normalizePath(url)
const qs = url.includes('?') ? url.slice(url.indexOf('?')) : ''
const full = `${path}${qs}`
if (isH5 && path.includes('/pages/index')) {
Taro.redirectTo({ url: full }).catch(() => Taro.navigateTo({ url: full }))
return
}
Taro.navigateTo({ url: full }).catch(() =>
Taro.redirectTo({ url: full }).catch(() => Taro.reLaunch({ url: full })),
)
}
export function goHome(): void {
goPage('/pages/index/index')
}
export function isTabPath(_url: string): boolean {
return false
}

View File

@ -0,0 +1,54 @@
import Taro, { useDidShow, useShareAppMessage, useShareTimeline } from '@tarojs/taro'
const DEFAULT_TITLE = 'nomadro · 随处工作,自由生活'
export type PageShareOptions = {
title?: string
path?: string
query?: string
}
/**
* 挂到页面默认导出上:Taro 靠 Component.enableShare* 才会注册 onShare*。
* (page.config 里的开关常被编译丢掉)
*/
export function markPageShare<T extends object>(Page: T): T {
Object.assign(Page as object, {
enableShareAppMessage: true,
enableShareTimeline: true,
})
return Page
}
/**
* 打开微信右上角「发送给朋友 / 分享到朋友圈」。
* 页面须:markPageShare(export) + 本 hook。
*/
export function usePageShare(opts: PageShareOptions = {}) {
const title = opts.title || DEFAULT_TITLE
const path = opts.path || '/pages/index/index'
const query = opts.query || ''
useDidShow(() => {
if (process.env.TARO_ENV !== 'weapp') return
const opt = {
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
}
void Promise.resolve(Taro.showShareMenu(opt as Parameters<typeof Taro.showShareMenu>[0])).catch(
() => {
void Taro.showShareMenu({ withShareTicket: true })
},
)
})
useShareAppMessage(() => ({
title,
path: query ? `${path}?${query}` : path,
}))
useShareTimeline(() => ({
title,
query,
}))
}

5
apps/miniprogram/tt/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules/
dist/
.swc/
*.log
.DS_Store

View File

@ -0,0 +1,88 @@
# Nomadro 抖音小程序(独立目录)
与微信(`../src/`)、小红书(`../xhs/`)**分目录开发,互不影响**。
| 项 | 值 |
|---|---|
| AppID | `tt995defe007255b2701` |
| 源码 | `src/` |
| 产物 | `dist/`(gitignore;本地 `pnpm build` 生成) |
| 工程配置 | `project.tt.json`(`miniprogramRoot: ./dist/`) |
| TabBar | **无** |
| 首页 | 三入口;自定义顶栏红标 `nomadro.webp`(与微信同源) |
| 支付 | 默认关闭 / 离线免费(无微信虚拟支付) |
| 隐私 | `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 章卡死);目录切章;仅末章显示「全书读完」 |
| 滚动 | 禁止用唯一 chapter-block 回写 `activeChapter`(否则会弹回第 1 章) |
## 包体积(官方)
| 项 | 上限 |
|---|---|
| 主包 | ≤ 4MB |
| 单个分包(`packageBook`) | ≤ 2MB |
| 全部合计 | ≤ 16MB |
构建结束自动 `copy-static` + `validate:size`。
## 验收
1. [ ] 导入 `tt/`,AppID 正确;`pnpm build` 后预览 `dist/`
2. [ ] 首页三入口;红标 logo;顶栏避开状态栏
3. [ ] 导航点链接 → 系统 Modal「复制/关闭」→ 复制成功(后台已声明剪切板)
4. [ ] 小册阅读:首章可滑,**不会**一滑就回前言并出「全书读完」
5. [ ] 目录可立刻点;章末「上一章/下一章」
6. [ ] 断网仍可打开小册;`validate:size` 通过
## 禁止
- 勿改上级 `src/` / `xhs/` 来编抖音
- 勿把 `tt/node_modules`、`tt/dist` 提交进 Git

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

View File

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Some files were not shown because too many files have changed in this diff Show More