|
|
@@ -21,7 +21,7 @@ import teamApi from "@/api/modules/team.ts";
|
|
|
import advertisementApi from "@/api/modules/advertisement.ts"
|
|
|
import representativeApi from "@/api/modules/representative.ts";
|
|
|
import contentApi from "@/api/modules/content.ts";
|
|
|
-import agreementApi from "@/api/modules/agreement";
|
|
|
+import agreementApi from "@/api/modules/agreement";
|
|
|
import companySortApi from "@/api/modules/companySort.ts"
|
|
|
import homeApi from "@/api/modules/home.ts";
|
|
|
|
|
|
@@ -45,7 +45,7 @@ import saleApi from '@/api/modules/sale.ts'
|
|
|
import dispatchApi from '@/api/modules/dispatch.ts'
|
|
|
|
|
|
|
|
|
-const axiosInstance:ApiInstance = axios.create({
|
|
|
+const axiosInstance: ApiInstance = axios.create({
|
|
|
baseURL: (import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true') ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
|
|
|
timeout: 1000 * 120,
|
|
|
responseType: 'json',
|
|
|
@@ -99,7 +99,7 @@ axiosInstance.interceptors.response.use(
|
|
|
duration: 2000,
|
|
|
})
|
|
|
useUserStore().logout()
|
|
|
- } else if(response.data.code === 400 && !skipGlobalError) {
|
|
|
+ } else if (response.data.code === 400 && !skipGlobalError) {
|
|
|
ElMessage({
|
|
|
message: `${response.data.msg}!!!`,
|
|
|
type: 'error',
|
|
|
@@ -110,7 +110,12 @@ axiosInstance.interceptors.response.use(
|
|
|
},
|
|
|
(error) => {
|
|
|
let message = error.message
|
|
|
- if (message === 'Network Error') {
|
|
|
+ // 按 HTTP 状态码分类提示
|
|
|
+ if (error.response && error.response.status === 404) {
|
|
|
+
|
|
|
+ message = '请求的接口不存在'
|
|
|
+ }
|
|
|
+ else if (message === 'Network Error') {
|
|
|
message = '后端网络故障'
|
|
|
}
|
|
|
else if (message.includes('timeout')) {
|
|
|
@@ -119,29 +124,31 @@ axiosInstance.interceptors.response.use(
|
|
|
else if (message.includes('Request failed with status code')) {
|
|
|
message = `接口${message.substr(message.length - 3)}异常`
|
|
|
}
|
|
|
- Message.error(message, {
|
|
|
- zIndex: 2000,
|
|
|
+ ElMessage({
|
|
|
+ message: message,
|
|
|
+ type: 'error',
|
|
|
+ plain: true,
|
|
|
})
|
|
|
return Promise.reject(error)
|
|
|
},
|
|
|
)
|
|
|
- // API 模块
|
|
|
+// API 模块
|
|
|
const api = {
|
|
|
appApi: appApi(axiosInstance),
|
|
|
userApi: userApi(axiosInstance),
|
|
|
roleApi: roleApi(axiosInstance),
|
|
|
- institutionApi:institutionApi(axiosInstance),
|
|
|
- partnerApi:partnerApi(axiosInstance),
|
|
|
- areaApi:areaApi(axiosInstance),
|
|
|
+ institutionApi: institutionApi(axiosInstance),
|
|
|
+ partnerApi: partnerApi(axiosInstance),
|
|
|
+ areaApi: areaApi(axiosInstance),
|
|
|
operationApi: operationApi(axiosInstance),
|
|
|
- menuApi:menuApi(axiosInstance),
|
|
|
+ menuApi: menuApi(axiosInstance),
|
|
|
commonApi: commonApi(axiosInstance),
|
|
|
teamApi: teamApi(axiosInstance),
|
|
|
representativeApi: representativeApi(axiosInstance),
|
|
|
lotteryApi: lotteryApi(axiosInstance),
|
|
|
- contentApi:contentApi(axiosInstance),
|
|
|
- advertisementApi:advertisementApi(axiosInstance),
|
|
|
- agreementApi:agreementApi(axiosInstance),
|
|
|
+ contentApi: contentApi(axiosInstance),
|
|
|
+ advertisementApi: advertisementApi(axiosInstance),
|
|
|
+ agreementApi: agreementApi(axiosInstance),
|
|
|
insuranceApi: insuranceApi(axiosInstance),
|
|
|
projectApi: projectApi(axiosInstance),
|
|
|
additionalApi: additionalApi(axiosInstance),
|
|
|
@@ -151,11 +158,11 @@ const api = {
|
|
|
financeApi: financeApi(axiosInstance),
|
|
|
invoiceRecordApi: invoiceRecordApi(axiosInstance),
|
|
|
settlementApi: settlementApi(axiosInstance),
|
|
|
- wechatApi:wechatApi(axiosInstance),
|
|
|
+ wechatApi: wechatApi(axiosInstance),
|
|
|
saleApi: saleApi(axiosInstance),
|
|
|
dispatchApi: dispatchApi(axiosInstance),
|
|
|
companySortApi: companySortApi(axiosInstance),
|
|
|
dictApi: dictApi(axiosInstance),
|
|
|
homeApi: homeApi(axiosInstance)
|
|
|
}
|
|
|
-export default api
|
|
|
+export default api
|