|
@@ -8,7 +8,7 @@ import { useAppStore } from '~src/store'
|
|
|
const store = useAppStore(pinia)
|
|
|
|
|
|
//封装的请求
|
|
|
-export const HcApi = async (obj, msg = true) => {
|
|
|
+export const HcApi = async (obj, msg) => {
|
|
|
return new Promise((resolve) => {
|
|
|
//处理统一的请求头
|
|
|
obj.headers = obj.headers ?? {}
|
|
@@ -20,19 +20,19 @@ export const HcApi = async (obj, msg = true) => {
|
|
|
//console.log(response)
|
|
|
resolve(response)
|
|
|
}).catch((response) => {
|
|
|
- getResData(response, msg)
|
|
|
+ getResData(response)
|
|
|
resolve(response)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//处理数据
|
|
|
-const getResData = ({ code, msg }, isMsg = false) => {
|
|
|
+const getResData = async ({ code }) => {
|
|
|
if (code === 401) {
|
|
|
window.$message?.error('身份失效,请重新登录!')
|
|
|
router.push({ path: '/login' }).then()
|
|
|
} else if (code !== 404 && code !== 500 && code !== 504) {
|
|
|
- HcWarMsg({
|
|
|
+ await HcWarMsg({
|
|
|
type: 'warning',
|
|
|
title: '服务器异常,请稍后重试',
|
|
|
text: '服务器异常了,如有需要,请联系管理员!',
|