fix: 支持小程序本地API地址切换
This commit is contained in:
1 parent
1a9dc426f6
commit
17af0f6883
2 files changed
+22
-1
No files matched your search
+6
-1
@@ -1,6 +1,11 @@
|
|||||||
|
const DEFAULT_API_BASE_URL = "http://172.16.6.123:3001";
|
||||||
|
|
||||||
App({
|
App({
|
||||||
onLaunch() {
|
onLaunch() {
|
||||||
this.globalData = { apiBaseUrl: "http://192.168.88.29:3001", brand: {} };
|
this.globalData = {
|
||||||
|
apiBaseUrl: wx.getStorageSync("apiBaseUrl") || DEFAULT_API_BASE_URL,
|
||||||
|
brand: {},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
globalData: {},
|
globalData: {},
|
||||||
});
|
});
|
||||||
@@ -15,3 +15,19 @@
|
|||||||
- 页面和行业模板:只消费统一字段与状态,不出现 `templateKey === "food"` 一类分支。
|
- 页面和行业模板:只消费统一字段与状态,不出现 `templateKey === "food"` 一类分支。
|
||||||
|
|
||||||
品牌颜色、圆角和间距统一维护在 `apps/miniapp/styles/tokens.wxss`。
|
品牌颜色、圆角和间距统一维护在 `apps/miniapp/styles/tokens.wxss`。
|
||||||
|
|
||||||
|
## 本地 API 地址
|
||||||
|
|
||||||
|
开发环境 API 地址默认配置在 `apps/miniapp/app.js`。换网络后可以直接在开发者工具 Console 执行:
|
||||||
|
|
||||||
|
```js
|
||||||
|
wx.setStorageSync("apiBaseUrl", "http://新的局域网IP:3001");
|
||||||
|
```
|
||||||
|
|
||||||
|
然后重新编译小程序。恢复默认地址可执行:
|
||||||
|
|
||||||
|
```js
|
||||||
|
wx.removeStorageSync("apiBaseUrl");
|
||||||
|
```
|
||||||
|
|
||||||
|
真机调试时,手机和电脑必须处于同一局域网,API 进程需监听可被局域网访问的地址,且防火墙允许 `3001` 端口。
|
||||||
Reference in new issue
Block a user