swagger文档树展示开发
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import apiClient from './request/custom.js'
|
||||
|
||||
export const customApi = {
|
||||
get: (url, data) => apiClient({url: url, method: 'get', data: data}),
|
||||
post: (url, data) => apiClient({url: url, method: 'post', data: data}),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Axios from 'axios'
|
||||
import interceptors from './interceptors'
|
||||
import interceptors from './interceptorsCustom'
|
||||
import {getCustomApiBaseUrl} from "./utils";
|
||||
|
||||
const apiClient = Axios.create({
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getZyplayerApiBaseUrl} from "./utils";
|
||||
// 增加不需要验证结果的标记
|
||||
const noValidate = {
|
||||
"./swagger-resources": true,
|
||||
"/zyplayer-doc-db/datasource/test": true,
|
||||
"/v2/api-docs": true,
|
||||
};
|
||||
|
||||
export default function (axios) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import qs from 'qs'
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
export default function (axios) {
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
if (config.method === 'get') {
|
||||
config.params = config.params || {};
|
||||
config.params = {...config.params, _: (new Date()).getTime()}
|
||||
} else if (config.method === 'post') {
|
||||
config.data = config.data || {};
|
||||
if (config.data instanceof FormData) {
|
||||
// 表单,无需特殊处理
|
||||
} else if (config.data instanceof Object) {
|
||||
config.data = qs.stringify(config.data);
|
||||
}
|
||||
}
|
||||
return config;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
axios.interceptors.response.use(
|
||||
response => {
|
||||
if (!!response.message) {
|
||||
vue.$message.error('请求错误:' + response.message);
|
||||
} else {
|
||||
return response.data;
|
||||
}
|
||||
return Promise.reject('请求错误');
|
||||
},
|
||||
error => {
|
||||
console.log('err' + error);
|
||||
message.error('请求错误:' + error.message);
|
||||
return Promise.reject(error)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user