update
This commit is contained in:
+19
-3
@@ -1,9 +1,23 @@
|
||||
import {Setting, TemplateBizType} from "../types";
|
||||
import {CaptchaResult, Setting, TemplateBizType} from "../types";
|
||||
import {axios} from "./BaseAPI";
|
||||
|
||||
const getCaptchaAPI = () => axios.defaults.baseURL + "/captcha";
|
||||
function getBaseURI(): string {
|
||||
const baseURL = axios.defaults.baseURL;
|
||||
if (!baseURL || baseURL === "undefined") {
|
||||
return "";
|
||||
}
|
||||
return baseURL.replace(/\/$/, "");
|
||||
}
|
||||
|
||||
const getAttachmentReadAPI = (mongoId: string) => `${axios.defaults.baseURL}/attachment/read/${mongoId}`;
|
||||
const getCaptchaAPI = () => `${getBaseURI()}/captcha`;
|
||||
|
||||
async function captcha(width: number, height: number): Promise<CaptchaResult> {
|
||||
return await axios.get(`/captcha?width=${width}&height=${height}`);
|
||||
}
|
||||
|
||||
const getAttachmentReadAPI = (id: string) => `${getBaseURI()}/attach/read/${id}`;
|
||||
|
||||
const getAttachmentTempReadAPI = (id: string) => `${getBaseURI()}/attach/temp/read?id=${id}`;
|
||||
|
||||
async function getTemplate(bizType: TemplateBizType, code: string): Promise<string> {
|
||||
return axios.get(`/template?bizType=${bizType}&bizCode=${code}`);
|
||||
@@ -30,7 +44,9 @@ async function settingMap(map: Record<string, string[]>): Promise<Map<string, Ma
|
||||
|
||||
export default {
|
||||
getCaptchaAPI,
|
||||
captcha,
|
||||
getAttachmentReadAPI,
|
||||
getAttachmentTempReadAPI,
|
||||
getTemplate,
|
||||
settingMap
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user