This commit is contained in:
Timi
2026-07-30 18:28:25 +08:00
parent 8b24804b22
commit f0d1090932
21 changed files with 915 additions and 268 deletions
+19 -3
View File
@@ -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
};