Merge remote-tracking branch 'github/base' into base
This commit is contained in:
commit
fe46d10b94
@ -2,6 +2,7 @@
|
||||
import qs from 'qs'
|
||||
import { useUserStore } from '@/store'
|
||||
import { platform } from '@/utils/platform'
|
||||
import { getEvnBaseUrl } from '@/utils'
|
||||
|
||||
export type CustomRequestOptions = UniApp.RequestOptions & {
|
||||
query?: Record<string, any>
|
||||
@ -10,7 +11,7 @@ export type CustomRequestOptions = UniApp.RequestOptions & {
|
||||
} & IUniUploadFileOptions // 添加uni.uploadFile参数类型
|
||||
|
||||
// 请求基准地址
|
||||
const baseUrl = import.meta.env.VITE_SERVER_BASEURL
|
||||
const baseUrl = getEvnBaseUrl()
|
||||
|
||||
// 拦截器配置
|
||||
const httpInterceptor = {
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { pages, subPackages, tabBar } from '@/pages.json'
|
||||
import { isMp } from './platform'
|
||||
|
||||
const getLastPage = () => {
|
||||
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
||||
// const lastPage = getCurrentPages().at(-1)
|
||||
@ -116,3 +118,32 @@ export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map((p
|
||||
* 只得到 path 数组
|
||||
*/
|
||||
export const needLoginPages: string[] = getAllPages('needLogin').map((page) => page.path)
|
||||
|
||||
/**
|
||||
* 根据微信小程序当前环境,判断应该获取的BaseUrl
|
||||
*/
|
||||
export const getEvnBaseUrl = () => {
|
||||
// 请求基准地址
|
||||
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
|
||||
|
||||
// 小程序端环境区分
|
||||
if (isMp) {
|
||||
const {
|
||||
miniProgram: { envVersion },
|
||||
} = uni.getAccountInfoSync()
|
||||
|
||||
switch (envVersion) {
|
||||
case 'develop':
|
||||
baseUrl = 'https://dev.test.net'
|
||||
break
|
||||
case 'trial':
|
||||
baseUrl = 'https://trial.test.net'
|
||||
break
|
||||
case 'release':
|
||||
baseUrl = 'https://prod.test.net'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return baseUrl
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user