1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-09-12 16:40:40 +08:00

refactor: 架构升级

This commit is contained in:
小莫唐尼
2026-08-31 07:58:23 +08:00
commit ba5b77568b
693 changed files with 118430 additions and 0 deletions
@@ -0,0 +1,97 @@
# Multi-Platform Deployment
## 多平台部署
UniApp + uView 项目支持多平台部署的策略和注意事项。
### 平台差异处理
使用条件编译处理平台差异:
```vue
<template>
<view>
<!-- #ifdef H5 -->
<view>H5 平台内容</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view>微信小程序内容</view>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view>App 平台内容</view>
<!-- #endif -->
</view>
</template>
<script>
export default {
methods: {
handlePlatform() {
// #ifdef H5
// H5 平台代码
// #endif
// #ifdef MP-WEIXIN
// 微信小程序代码
// #endif
// #ifdef APP-PLUS
// App 平台代码
// #endif
}
}
}
</script>
```
### 统一 API 封装
封装统一的 API 调用:
```javascript
// utils/api.js
export function request(url, options = {}) {
return new Promise((resolve, reject) => {
uni.request({
url,
...options,
success: (res) => {
resolve(res.data)
},
fail: (err) => {
reject(err)
}
})
})
}
```
### 平台特定配置
在 manifest.json 中配置各平台:
```json
{
"h5": {
"router": {
"mode": "hash"
}
},
"mp-weixin": {
"appid": "your-appid"
},
"app-plus": {
"usingComponents": true
}
}
```
### 注意事项
1. **条件编译**:使用条件编译处理平台差异
2. **API 统一**:封装统一的 API 调用
3. **配置管理**:正确配置各平台参数
4. **测试验证**:在各平台测试功能
5. **文档记录**:记录平台差异和注意事项