Files
digital-psychology/docs/LOCAL-DEV-MINI-PROGRAM-H5.md
T
jackyu66gitandCursor 580ba85b61 fix(h5): 小程序 nh=1 原生顶栏模式与 sbh 顶距(配 202608278)
H5 在 nh=1 时隐藏 AppHeader,支持 sbh 控制内容顶距,首屏 inline 预应用。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 03:24:42 +08:00

72 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 愈心魔方 H5 · 本地联调(免每次改服务器)
## 模式 A:本地小程序 → 远程 H5(默认)
只改小程序、不动 H5 时用这个。`util/yxgConfig.local.js` 保持:
```js
export const USE_LOCAL_H5 = false
```
微信开发者工具 **编译运行** → 愈心魔方 Tab 加载 `https://h5.yuxingu.com.cn/psy/?mp=1&nh=1&v=…`
**不必**开 `npm run dev:mp`;业务域名 / request 域名按线上一致(可不勾「不校验合法域名」)。
## 模式 B:本地小程序 → 本机 Vite
改 H5 时要热更新:
```bash
cd digital-psychology && npm run dev:mp
```
`util/yxgConfig.local.js`
```js
export const USE_LOCAL_H5 = true
export const LOCAL_H5_HOST = '192.168.x.x:5173' // 与 dev:mp 打印一致
```
微信开发者工具:勾选「不校验合法域名、web-view…」。
## 日常流程(模式 B
```bash
# 终端 1:H5(会打印局域网 IP)
cd digital-psychology
npm run dev:mp
# 终端 2(需要登录/接口时)
npm run dev:api
# 或仅数据库: npm run deps:up && npm run dev:api
```
```text
微信开发者工具
├── 打开 yuxingu-Miniprogram-dev
├── 详情 → 本地设置 → 勾选「不校验合法域名、web-view…」
├── 编译运行(开发模式,非发行)
└── 打开 Tab「愈心魔方」
## 浏览器自测 embed
```text
http://localhost:5173/psy/?mp=1&sbh=88
```
## 确认要上线时(一条命令)
```bash
cp deploy.env.example deploy.env # 首次填写服务器
chmod +x scripts/deploy-h5.sh
./scripts/deploy-h5.sh
```
## 局限
| 项 | 说明 |
|----|------|
| 真机预览 | 手机与电脑同一 WiFi;开发者工具可勾选「真机调试」 |
| 业务域名 | 本地为 `http`,仅开发模式 + 关闭域名校验时可用 |
| 与线上一致 | 发行前仍建议在体验版走 HTTPS 域名验收一次 |