chore:提取公共常量
This commit is contained in:
1 parent
97eb387436
commit
88e5660b29
8 files changed
+41
-19
No files matched your search
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* ZZD:浙政钉 | SH:诗画
|
||||
*/
|
||||
export default {
|
||||
ZZD: "zzd",
|
||||
SH: "sh",
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
export { default as serviceEnum } from "./service-enum"
|
||||
|
||||
export { default as storageConstant } from "./storage-constant"
|
||||
|
||||
export { default as APPENV } from "./app-env"
|
||||
@@ -1,4 +1,7 @@
|
||||
// app运行环境
|
||||
|
||||
import { APPENV } from "../constant"
|
||||
|
||||
// export default () => import.meta.env.VITE_DEV_ENV === "dev"
|
||||
export const isDevEnv = (): boolean => process.env.NODE_ENV === "development"
|
||||
|
||||
@@ -14,11 +17,11 @@ export const getAppInfo = async (): Promise<string> => {
|
||||
// 浙政钉环境
|
||||
if (res.code === 0) {
|
||||
console.log("环境:浙政钉-zzd")
|
||||
return "zzd"
|
||||
return APPENV.ZZD
|
||||
} else {
|
||||
// 诗画环境
|
||||
console.log("环境:诗画浦江-sh")
|
||||
return "sh"
|
||||
return APPENV.SH
|
||||
}
|
||||
} catch (error) {
|
||||
return "unknown"
|
||||
|
||||
@@ -4,6 +4,7 @@ import { isEmpty } from "radash"
|
||||
import { getAppInfo, isDevEnv } from "@@/utils/app"
|
||||
import { userApi } from "../api"
|
||||
import showVerifyDeviceImpModel from "../components/verifyDeviceImpModel/verifyDeviceImpModel"
|
||||
import { APPENV } from "../constant"
|
||||
|
||||
const TOKEN_KEY = constant.storageConstant.TOKEN
|
||||
const USER_INFO_KEY = constant.storageConstant.USERINFO
|
||||
@@ -210,9 +211,9 @@ async function refreshToken(): Promise<any> {
|
||||
const autoLogin = async (): Promise<boolean> => {
|
||||
const appInfo = await getAppInfo()
|
||||
// 浙政钉环境
|
||||
if (appInfo == "zzd") return await loginByZzd()
|
||||
if (appInfo == APPENV.ZZD) return await loginByZzd()
|
||||
// 诗画环境
|
||||
if (appInfo == "sh") return await loginBySh()
|
||||
if (appInfo == APPENV.SH) return await loginBySh()
|
||||
|
||||
uni.showToast({ title: "app环境错误", icon: "none" })
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user