still bugs

This commit is contained in:
felinae98
2021-09-26 16:22:49 +08:00
parent dce58580f2
commit 5e153b0d2f
11 changed files with 308 additions and 36 deletions
+11 -1
View File
@@ -1,5 +1,5 @@
import axios from "axios";
import { GlobalConf, TokenResp } from "../utils/type";
import { GlobalConf, TokenResp, SubscribeResp, TargetNameResp } from "../utils/type";
import { baseUrl } from './utils';
export async function getGlobalConf(): Promise<GlobalConf> {
@@ -11,3 +11,13 @@ export async function auth(token: string): Promise<TokenResp> {
const res = await axios.get<TokenResp>(`${baseUrl}auth`, {params: {token}});
return res.data;
}
export async function getSubscribe(): Promise<SubscribeResp> {
const res = await axios.get(`${baseUrl}subs`);
return res.data;
}
export async function getTargetName(platformName: string, target: string): Promise<TargetNameResp> {
const res = await axios.get(`${baseUrl}target_name`, {params: {platformName, target}});
return res.data;
}
+20 -1
View File
@@ -18,4 +18,23 @@ axios.interceptors.request.use(function (config) {
return config;
}, function (error) {
return Promise.reject(error);
})
});
axios.interceptors.response.use(function (response) {
// const data = response.data;
// const parseToMap = (item: any): any => {
// if (item instanceof Array) {
// return item.map(parseToMap);
// } else if (item instanceof Object) {
// let res = new Map();
// for (const key of Object.keys(item)) {
// res.set(key, parseToMap(item[key]));
// }
// return res;
// } else {
// return item;
// }
// }
// response.data = parseToMap(data);
return response;
});