swagger文档展示开发

This commit is contained in:
暮光:城中城
2021-10-20 22:32:25 +08:00
parent 9267aed477
commit 5cb267fba6
16 changed files with 146 additions and 65 deletions

View File

@@ -0,0 +1,6 @@
import apiClient from './request/custom.js'
export const customApi = {
post: (url, data) => apiClient({url: url, method: 'post', data: data}),
};

View File

@@ -1,3 +1,4 @@
export { zyplayerApi } from './zyplayer.js';
export { customApi } from './custom.js';

View File

@@ -0,0 +1,14 @@
import Axios from 'axios'
import interceptors from './interceptors'
import {getCustomApiBaseUrl} from "./utils";
const apiClient = Axios.create({
baseURL: getCustomApiBaseUrl(),
timeout: 20000,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
withCredentials: true
});
interceptors(apiClient);
export default apiClient;

View File

@@ -4,7 +4,7 @@ import {getZyplayerApiBaseUrl} from "./utils";
// 增加不需要验证结果的标记
const noValidate = {
"/zyplayer-doc-db/executor/execute": true,
"./swagger-resources": true,
"/zyplayer-doc-db/datasource/test": true,
};
@@ -38,7 +38,7 @@ export default function (axios) {
response => {
if (!!response.message) {
vue.$message.error('请求错误:' + response.message);
}else {
} else {
if (!response.config.needValidateResult || response.data.errCode === 200) {
return response.data;
} else if (response.data.errCode === 400) {

View File

@@ -11,3 +11,15 @@ export function getZyplayerApiBaseUrl() {
return baseUrl;
}
/**
* 获取custom后端域名
*/
export function getCustomApiBaseUrl() {
let env = import.meta.env.VITE_APP_ENV;
let baseUrl = import.meta.env.VITE_APP_CUSTOM_URL_ONLINE;
if ("dev" === env) {
baseUrl = import.meta.env.VITE_APP_CUSTOM_URL_DEV;
}
return baseUrl;
}