Files
medical-mall/config/consumer/README.md

152 lines
3.5 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.
# 消费者端专用配置说明
## 一、配置文件结构
```
mall/
├── pages.json # 公共配置(保持不变)
├── manifest.json # 公共配置(保持不变)
├── config/
│ └── consumer/ # 消费者端专用配置
│ ├── pages.json # 消费者端页面配置
│ ├── manifest.json # 消费者端应用配置
│ └── README.md # 本文档
└── scripts/ # 构建脚本
├── build-consumer.bat # 应用消费者端配置
└── restore-config.bat # 恢复公共配置
```
---
## 二、快速使用
### 方式一:一键切换(推荐)
在 HBuilderX 中打开项目,使用 **外部命令** 功能:
1. 菜单:**工具 → 外部命令 → 自定义外部命令**
2. 添加以下命令:
```
名称: 切换到消费者端配置
命令: scripts\build-consumer.bat
工作目录: ${projectPath}
名称: 恢复公共配置
命令: scripts\restore-config.bat
工作目录: ${projectPath}
```
3. 以后通过菜单 **工具 → 外部命令** 一键切换
### 方式二:手动运行脚本
在项目目录下双击运行:
- `scripts\build-consumer.bat` - 切换到消费者端配置
- `scripts\restore-config.bat` - 恢复公共配置
---
## 三、开发流程
### 3.1 开发消费者端小程序
```
1. 运行 build-consumer.bat切换配置
2. HBuilderX 编译微信小程序
3. 开发调试
4. 运行 restore-config.bat恢复配置
5. 提交代码
```
### 3.2 开发消费者端 App
直接在 HBuilderX 中编译 Android App无需切换配置。
---
## 四、配置文件说明
### 4.1 pages.json
消费者端专用页面配置:
**主包页面(核心页面)**
- 登录注册login, register, forgot-password
- 主要功能index, category, cart, profile
**分包页面(次级页面)**
- 商品product-detail, shop-detail, search
- 订单checkout, payment, orders, order-detail
- 用户settings, wallet, favorites, address-list
- 会员member/index, points/*, coupons
### 4.2 manifest.json
消费者端专用应用配置:
- 应用名称:商城消费者端
- 小程序 AppID需填写
- 分包优化配置
---
## 五、添加新页面
### 5.1 添加消费者端页面
1. 创建页面文件:`pages/mall/consumer/new-page.uvue`
2. 编辑 `config/consumer/pages.json`
```json
{
"path": "new-page",
"style": {
"navigationBarTitleText": "新页面"
}
}
```
### 5.2 添加公共页面
同时更新:
- `config/consumer/pages.json`
- 根目录 `pages.json`
---
## 六、Git 提交规范
```bash
# 只提交消费者端配置
git add config/consumer/
git commit -m "feat(consumer): 添加新页面配置"
# 只提交消费者端代码
git add pages/mall/consumer/
git commit -m "feat(consumer): 添加会员功能"
```
---
## 七、常见问题
### Q1: 编译时提示找不到页面?
检查 `config/consumer/pages.json` 中的页面路径。
### Q2: 忘记恢复配置怎么办?
直接运行 `restore-config.bat` 即可。
### Q3: 如何查看当前使用的是哪个配置?
查看根目录 `pages.json` 的内容,或检查是否存在 `.bak` 备份文件。
---
## 八、注意事项
- ✅ 只修改 `config/consumer/` 目录下的文件
- ❌ 不要修改根目录的 `pages.json``manifest.json`
- ✅ 编译小程序前运行 `build-consumer.bat`
- ✅ 编译完成后运行 `restore-config.bat`