Merge branch 'base'

This commit is contained in:
菲鸽
2024-05-18 17:25:05 +08:00
5 changed files with 34 additions and 8 deletions

2
src/env.d.ts vendored
View File

@@ -15,6 +15,8 @@ interface ImportMetaEnv {
readonly VITE_SERVER_PORT: string
/** 后台接口地址 */
readonly VITE_SERVER_BASEURL: string
/** H5是否需要代理 */
readonly VITE_APP_PROXY: boolean
/** 上传图片地址 */
readonly VITE_UPLOAD_BASEURL: string
/** 是否清除console */

View File

@@ -27,7 +27,18 @@ const httpInterceptor = {
}
// 非 http 开头需拼接地址
if (!options.url.startsWith('http')) {
// #ifdef H5
console.log(__VITE_APP_PROXY__)
if (JSON.parse(__VITE_APP_PROXY__)) {
// 啥都不需要做
} else {
options.url = baseUrl + options.url
}
// #endif
// 非H5正常拼接
// #ifndef H5
options.url = baseUrl + options.url
// #endif
// TIPS: 如果需要对接多个后端服务,也可以在这里处理,拼接成所需要的地址
}
// 1. 请求超时

View File

@@ -12,3 +12,5 @@ declare const __UNI_PLATFORM__:
| 'quickapp-webview'
| 'quickapp-webview-huawei'
| 'quickapp-webview-union'
declare const __VITE_APP_PROXY__: 'true' | 'false'