Ship Taro H5 Vite build and Next-parity hub/nav/book/vip pages.

Switch miniprogram H5 to Vite for fast local compile; align portal pages and static icons for cross-machine continue.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-09-29 04:36:12 -05:00
parent c90670a1f7
commit 69b0bd8224
349 changed files with 29541 additions and 3299 deletions

46
.env.vip.example Normal file
View File

@ -0,0 +1,46 @@
# ========== 与 payjsapi/digital/cnomadcna 同源 ==========
# 复制为 .env.local,PB/Memos 与 payjsapi 保持一致
#
# 本地无 PocketBase:next dev 下可用 POCKETBASE_INTERNAL_URL 指远程 PB。
# next start 生产同机部署:服务端只用 POCKETBASE_URL(默认 http://127.0.0.1:8090),不会读取 POCKETBASE_INTERNAL_URL,避免误配公网域名拖慢 API。
# payjsapi 生产请配本机 PB(如 PB_INTERNAL_URL=http://127.0.0.1:8090),勿让 payjs 再绕公网打 pocketbase 域名。
# ========== PocketBase ==========
NEXT_PUBLIC_POCKETBASE_URL=https://pocketbase.hackrobot.cn
# 仅 next dev 服务端生效:远程 PB
POCKETBASE_INTERNAL_URL=https://pocketbase.hackrobot.cn
# 仅 next start 生产服务端生效(同机示例)
# POCKETBASE_URL=http://127.0.0.1:8090
POCKETBASE_EMAIL=xiaoshuang.eric@gmail.com
POCKETBASE_PASSWORD=Xiao4669805@
# ========== 支付(payjsapi)==========
PAYMENT_API_URL=http://127.0.0.1:8007
NEXT_PUBLIC_API_URL=http://127.0.0.1:8007
PAYMENT_API_INTERNAL_URL=http://127.0.0.1:8007
# 内网/慢网络可适当提高超时(毫秒):check_vip 默认 15s,payh5/redirect 默认 60s
# PAYJSAPI_CHECK_TIMEOUT=15000
# PAYJSAPI_CHECK_BY_EMAIL_TIMEOUT=20000
# PAYJSAPI_CHECK_BY_EMAIL_RETRIES=1
# PAYJSAPI_PAYH5_TIMEOUT=60000
# PAYJSAPI_REDIRECT_TIMEOUT=60000
PAYMENT_PROVIDER=zpay
PAYMENT_DEFAULT_AMOUNT=100
NEXT_PUBLIC_SITE_ID=vip
ZPAY_SUBMIT_URL=https://zpayz.cn/submit.php
# ========== Memos(pay/confirm 创建账号,与 payjsapi MEMOS_TOKEN 同值)==========
MEMOS_API_URL=https://qun.hackrobot.cn
MEMOS_ACCESS_TOKEN=eyJhbGciOiJIUzI1NiIsImtpZCI6InYxIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiaGFja3JvYm90IiwiaXNzIjoibWVtb3MiLCJzdWIiOiIxIiwiYXVkIjpbInVzZXIuYWNjZXNzLXRva2VuIl0sImlhdCI6MTc1NzQwNTE0OX0.Idn7kBlxE-CoSOXwWuZ1tHGIRKHAIeDyXSafGS5OHsg
# ========== MinIO ==========
MINIO_ENDPOINT=minioweb.hackrobot.cn
MINIO_PORT=9035
MINIO_USE_SSL=false
MINIO_BUCKET=hackrobot
MINIO_PUBLIC_URL=https://minioweb.hackrobot.cn/hackrobot
# 如需上传需配置(服务端)
# MINIO_ACCESS_KEY=
# MINIO_SECRET_KEY=
# MINIO_REGION=china

View File

@ -11,6 +11,21 @@
| 抖音 | `ebook/dymini` AppID / Taro tt | `pnpm build:tt` |
| 小红书 | `navmini/xhs` + `ebook/redmini` | `xhs/`(导航 ZIP + book 资源) |
## 目标(全端)
用 **一套 Taro 源码** 覆盖 Next 已整合的四垂直能力,产出:
| 端 | 命令 | 对齐 |
|---|---|---|
| **Taro H5 / PC**(先验) | `pnpm dev:h5` → `:10086` | 视觉与路由对齐门户 Next(`/` `/nav` `/book` `/community` `/vip`) |
| 微信小程序 | `pnpm dev:weapp` | 同套页面 + TabBar + 虚拟支付 |
| 抖音小程序 | `pnpm dev:tt` | 同套页面 |
| 小红书小工具 | `pnpm build:xhs` / `build:xhs-book` | 离线 ZIP(无 Taro 运行时) |
**验收顺序**:Taro H5 → 微信 → 抖音 → 小红书。H5 过了再编三端。
首页源码对照:`components/sections/hero.tsx` + `app/hub.css` → `src/pages/index` + `src/styles/hub.scss`。H5 **无 TabBar**(与 Next 一致);微信/抖音保留五 Tab。
## 文档
- 微信 https://developers.weixin.qq.com/miniprogram/dev/framework/
@ -57,12 +72,26 @@ WX_PAY_ENV=1
cd apps/miniprogram
pnpm install
# ① 先验 Taro H5(Vite,浏览器,同套源码)
pnpm dev:h5 # → http://localhost:10086/ (compiler: vite,远快于 webpack)
# H5 同源代理(config/index.ts)避免浏览器 CORS:
# /api → https://nomadro.cn (远程配置)
# /ebook-api → https://api.nomadro.cn (电子书)
# /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/release 导航包;book 资源在 xhs/tool/book*
pnpm build:xhs # → xhs/dist/youmin-nav-xhs-tool.zip(离线纯前端包)
pnpm build:xhs-book # → xhs/dist/yidu-xingqiu-xhs-tool.zip(电子书独立包)
# 勿把 book/ 嵌进导航 zip:子目录 index.html 会被小红书当成入口报错
```
TabBar:首页 / 导航 / **小册** / 社群 / 我的。
**验收顺序**:Taro H5 → 微信 → 抖音 → 小红书(小红书无 Taro 运行时,用离线 zip)。
H5 首页视觉对齐门户 `app/hub.css`(`src/styles/hub.scss`);Tab:首页 / 导航 / **小册** / 社群 / 我的。
建议:根仓 `pnpm dev` 先起门户,再开小程序,便于拉 `http://localhost:3000/api/config`(拉不到则用包内默认,小红书尤其依赖离线包)。

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: 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

Binary file not shown.

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: 3.3 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

View File

@ -2,14 +2,52 @@ import path from 'path'
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 === 'tt' ? 'dist/tt' : target === 'xhs' ? 'dist/xhs' : 'dist/weapp'
target === 'h5'
? 'dist/h5'
: target === 'tt'
? 'dist/tt'
: target === 'xhs'
? 'dist/xhs'
: 'dist/weapp'
const defaultApi =
target === 'tt'
? 'https://dyapi.nomadro.cn'
: 'https://api.nomadro.cn'
const iconsDir = path.resolve(__dirname, '..', 'src', 'assets', 'icons')
/** Vite H5 代理(比 webpack 快一个数量级) */
const h5ViteProxy = {
'/ebook-api': {
target: process.env.TARO_H5_EBOOK_PROXY || 'https://api.nomadro.cn',
changeOrigin: true,
secure: false,
rewrite: (p: string) => p.replace(/^\/ebook-api/, ''),
},
'/community-api': {
target: process.env.TARO_H5_COMMUNITY_PROXY || 'https://nomadweb.nomadro.com',
changeOrigin: true,
secure: false,
rewrite: (p: string) => p.replace(/^\/community-api/, '/api/v1'),
},
'/api': {
target: process.env.TARO_H5_PROXY || 'https://nomadro.cn',
changeOrigin: true,
secure: false,
},
}
const pxExclude = (file: string) =>
/[\\/]styles[\\/]hub\.scss/.test(file) ||
/[\\/]styles[\\/]navmini\.scss/.test(file) ||
/[\\/]styles[\\/]ebook-cover\.scss/.test(file) ||
/[\\/]pages[\\/]index[\\/]index\.scss/.test(file) ||
/[\\/]pages[\\/]nav[\\/]index\.scss/.test(file) ||
/[\\/]pages[\\/]book[\\/]index\.scss/.test(file)
export default defineConfig(async (merge) => {
const baseConfig: UserConfigExport = {
projectName: 'nomadro-miniprogram',
@ -35,18 +73,47 @@ export default defineConfig(async (merge) => {
TARO_APP_TARGET: JSON.stringify(target),
},
copy: {
patterns: [{ from: 'src/assets/', to: 'assets/' }],
patterns: [
{ from: 'src/assets/', to: 'assets/' },
{ from: 'src/public/icons/', to: 'icons/' },
],
options: {},
},
framework: 'react',
compiler: {
type: 'webpack5',
prebundle: { enable: false },
},
cache: { enable: false },
// H5 → Vite(快);微信/抖音 → webpack5
compiler: isH5
? {
type: 'vite',
vitePlugins: [
{
name: 'nomadro-spa-fallback',
configureServer(server: {
middlewares: { use: (fn: (req: { url?: string }, res: unknown, next: () => void) => void) => void }
}) {
server.middlewares.use((req, _res, next) => {
if (req.url === '/' || req.url === '') {
req.url = '/index.html'
}
next()
})
},
},
],
}
: {
type: 'webpack5',
prebundle: { enable: false },
},
cache: { enable: !isH5 },
alias: {
'@': path.resolve(__dirname, '..', 'src'),
},
// Vite root=src,publicDir 默认 src/public → /icons/*
modifyViteConfig(viteConfig: { publicDir?: string; appType?: string }) {
if (!isH5) return
viteConfig.publicDir = path.resolve(__dirname, '..', 'src', 'public')
viteConfig.appType = 'spa'
},
mini: {
postcss: {
pxtransform: { enable: true, config: {} },
@ -56,9 +123,24 @@ export default defineConfig(async (merge) => {
h5: {
publicPath: '/',
staticDirectory: 'static',
router: {
mode: 'hash',
},
devServer: {
host: '0.0.0.0',
port: 10086,
open: false,
proxy: h5ViteProxy,
},
postcss: {
autoprefixer: { enable: true },
cssModules: { enable: false },
pxtransform: {
enable: true,
config: {
exclude: pxExclude,
},
},
},
},
}

19799
apps/miniprogram/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,26 +4,38 @@
"private": true,
"description": "Nomadro 统一小程序 — 微信 / 抖音 / 小红书(Taro 4 + React,能力对齐 apps 垂直仓)",
"scripts": {
"build:weapp": "taro build --type weapp",
"dev:weapp": "npm run build:weapp -- --watch",
"build:tt": "cross-env TARO_APP_TARGET=tt taro build --type tt",
"dev:tt": "npm run build:tt -- --watch",
"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": "node ./node_modules/@tarojs/cli/bin/taro build --type weapp",
"dev:weapp": "node ./node_modules/@tarojs/cli/bin/taro build --type weapp --watch",
"build:tt": "cross-env TARO_APP_TARGET=tt node ./node_modules/@tarojs/cli/bin/taro build --type tt",
"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",
"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",
"build:xhs": "npm run xhs:assemble && npm run xhs:pack",
"build:xhs-book": "npm run xhs:assemble-book && npm run xhs:pack-book",
"build:xhs-all": "npm run build:xhs && npm run build:xhs-book",
"dev:all": "echo use: pnpm dev:weapp | pnpm dev:tt | pnpm build:xhs"
},
"browserslist": ["last 3 versions", "Android >= 4.1", "ios >= 8"],
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
],
"dependencies": {
"@babel/runtime": "^7.26.0",
"@tarojs/components": "4.0.9",
"@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",
"@tarojs/runtime": "4.0.9",
"@tarojs/shared": "4.0.9",
"@tarojs/taro": "4.0.9",
@ -32,14 +44,22 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-transform-runtime": "^7.29.7",
"@babel/preset-react": "^7.26.3",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.17",
"@tarojs/cli": "4.0.9",
"@tarojs/vite-runner": "^4.0.9",
"@tarojs/webpack5-runner": "4.0.9",
"@types/react": "^18.3.12",
"@vitejs/plugin-react": "^4.7.0",
"babel-preset-taro": "4.0.9",
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",
"sass": "^1.81.0",
"typescript": "^5.6.3",
"vite": "^4.5.14",
"webpack": "5.91.0"
}
}

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: 2.8 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

Binary file not shown.

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: 3.3 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

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