fix: 新增mock数据请求功能

This commit is contained in:
mtruning
2022-03-21 23:03:10 +08:00
parent d9ee41c892
commit bf020e3d3e
7 changed files with 48 additions and 32 deletions
+2 -1
View File
@@ -26,11 +26,12 @@ axiosInstance.interceptors.response.use(
if (code === ResultEnum.DATA_SUCCESS) return Promise.resolve(res.data)
// 重定向
if (ErrorPageNameMap.get(code)) redirectErrorPage(code)
return Promise.reject(res.data)
return Promise.resolve(res.data)
},
(err: AxiosResponse) => {
const { code } = err.data as { code: number }
if (ErrorPageNameMap.get(code)) redirectErrorPage(code)
window['$message'].error('接口异常,请检查!')
Promise.reject(err)
}
)
+1 -2
View File
@@ -1,11 +1,10 @@
import axiosInstance from './axios'
import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum'
export const get = (url: string, params: object) => {
export const get = (url: string) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.GET,
params
})
}
+13 -13
View File
@@ -4,37 +4,37 @@ export default {
status: 200,
msg: "请求成功",
data: {
dimensions: ["product", "data1", "data2"],
dimensions: ["product", "dataOne", "dataTwo"],
source: [
{
'product': '@name',
'data1|100-900': 3,
'data2|100-900': 3,
'dataOne|100-900': 3,
'dataTwo|100-900': 3,
},
{
'product': '@name',
'data1|100-900': 3,
'data2|100-900': 3,
'dataOne|100-900': 3,
'dataTwo|100-900': 3,
},
{
'product': '@name',
'data1|100-900': 3,
'data2|100-900': 3,
'dataOne1|100-900': 3,
'dataTwo|100-900': 3,
},
{
'product': '@name',
'data1|100-900': 3,
'data2|100-900': 3,
'dataOne|100-900': 3,
'dataTwo|100-900': 3,
},
{
'product': '@name',
'data1|100-900': 3,
'data2|100-900': 3,
'dataOne|100-900': 3,
'dataTwo|100-900': 3,
},
{
'product': '@name',
'data1|100-900': 3,
'data2|100-900': 3,
'dataOne|100-900': 3,
'dataTwo|100-900': 3,
},
]
}