请求器优化
This commit is contained in:
parent
316bfbbee6
commit
79b03cfba2
|
|
@ -2,7 +2,7 @@
|
|||
"name" : "OfficeSystem",
|
||||
"appid" : "__UNI__53A0BE0",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.4",
|
||||
"versionName" : "1.0.5",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ export const Request = () => {
|
|||
// 初始化请求配置
|
||||
uni.$uv.http.setConfig((config) => {
|
||||
/* config 为默认全局配置*/
|
||||
config.baseURL = 'http://192.168.1.4:4001'; /* 根域名 */
|
||||
config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */
|
||||
config.baseURL = 'http://192.168.1.2:4001'; /* 根域名 */
|
||||
// config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */
|
||||
return config
|
||||
})
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ export const Request = () => {
|
|||
const custom = response.config?.custom
|
||||
|
||||
// 处理 token 过期等情况(根据实际业务调整)
|
||||
if (data.code === 401 || data.code === 403) {
|
||||
if (data.code === 401) {
|
||||
// token 过期或无效,清除登录状态
|
||||
const userStore = useUserStore()
|
||||
userStore.logout()
|
||||
|
|
@ -89,6 +89,15 @@ export const Request = () => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (data.code === 403) {
|
||||
uni.$uv.toast('无权限')
|
||||
// setTimeout(() => {
|
||||
// uni.reLaunch({ url: '/pages/login/index' })
|
||||
// isRedirectingToLogin = false
|
||||
// }, 200)
|
||||
}
|
||||
|
||||
if (data.code !== 200) {
|
||||
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
|
||||
if (custom?.toast !== false) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user