Merge pull request #9 from CrazyStudent13/wxadapter

fix(upload): 修正环境变量baseUrl配置以区分小程序端环境
This commit is contained in:
菲鸽 2024-09-11 20:39:59 +08:00 committed by GitHub
commit 3c0b24ff62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 4 deletions

View File

@ -1,5 +1,7 @@
// TODO: 别忘加更改环境变量的 VITE_UPLOAD_BASEURL 地址。
const VITE_UPLOAD_BASEURL = import.meta.env.VITE_UPLOAD_BASEURL
import { getEvnBaseUploadUrl } from '@/utils'
const VITE_UPLOAD_BASEURL = `${getEvnBaseUploadUrl()}`
/**
* useUpload

View File

@ -134,16 +134,45 @@ export const getEvnBaseUrl = () => {
switch (envVersion) {
case 'develop':
baseUrl = 'https://dev.test.net'
baseUrl = 'https://ukw0y1.laf.run'
break
case 'trial':
baseUrl = 'https://trial.test.net'
baseUrl = 'https://ukw0y1.laf.run'
break
case 'release':
baseUrl = 'https://prod.test.net'
baseUrl = 'https://ukw0y1.laf.run'
break
}
}
return baseUrl
}
/**
* UPLOAD_BASEURL
*/
export const getEvnBaseUploadUrl = () => {
// 请求基准地址
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
// 小程序端环境区分
if (isMp) {
const {
miniProgram: { envVersion },
} = uni.getAccountInfoSync()
switch (envVersion) {
case 'develop':
baseUploadUrl = 'https://ukw0y1.laf.run/upload'
break
case 'trial':
baseUploadUrl = 'https://ukw0y1.laf.run/upload'
break
case 'release':
baseUploadUrl = 'https://ukw0y1.laf.run/upload'
break
}
}
return baseUploadUrl
}