diff --git a/examples/Root.vue b/examples/Root.vue
index 9239e41..397e655 100644
--- a/examples/Root.vue
+++ b/examples/Root.vue
@@ -1,5 +1,10 @@
@@ -7,17 +12,9 @@
diff --git a/src/api/ArticleAPI.ts b/src/api/ArticleAPI.ts
index 3f32b68..7f2e973 100644
--- a/src/api/ArticleAPI.ts
+++ b/src/api/ArticleAPI.ts
@@ -1,27 +1,25 @@
import type { Article } from "../types";
import { axios } from "./BaseAPI";
-/**
- * 获取文章
- *
- * @param id 文章 ID
- * @returns 文章数据
- */
-async function view(id: string): Promise {
- return axios.get(`/article/${id}`);
-}
-
-/**
- * 喜欢文章,后端有限调用,1240ms 一次
- *
- * @param id 文章 ID
- * @returns 最新喜欢数量
- */
-async function like(id: string): Promise {
- return axios.get(`/article/like/${id}`);
-}
-
-export default {
- view,
- like
+export const ArticleAPI = {
+ /**
+ * 获取文章
+ *
+ * @param id 文章 ID
+ * @returns 文章数据
+ */
+ async view(id: string): Promise {
+ return axios.get(`/article/${id}`);
+ },
+ /**
+ * 喜欢文章,后端有限调用,1240ms 一次
+ *
+ * @param id 文章 ID
+ * @returns 最新喜欢数量
+ */
+ async like(id: string): Promise {
+ return axios.get(`/article/like/${id}`);
+ }
};
+
+export default ArticleAPI;
diff --git a/src/api/AttachmentAPI.ts b/src/api/AttachmentAPI.ts
index 9de182a..4508b9b 100644
--- a/src/api/AttachmentAPI.ts
+++ b/src/api/AttachmentAPI.ts
@@ -4,55 +4,57 @@ import CommonAPI from "./CommonAPI";
const BASE_URI = "/attach";
-/**
- * 上传临时附件
- *
- * @param file 文件或文件列表
- * @param ttl 有效期
- * @returns 临时附件列表
- */
-async function upload(file: File | File[], ttl?: string): Promise {
- const formData = new FormData();
- const fileList = Array.isArray(file) ? file : [file];
- for (const item of fileList) {
- formData.append("file", item);
- }
- if (ttl) {
- formData.append("ttl", ttl);
- }
- return await axios.post(`${BASE_URI}/temp/upload`, formData);
-}
-
-/**
- * 按业务差分更新附件
- *
- * @param req 更新请求
- */
-async function updateByBizId(req: BizIdUpdate): Promise {
- return await axios.post(`${BASE_URI}/update/biz/id`, req);
-}
-
-/**
- * 按业务查询附件列表
- *
- * @param bizType 业务类型
- * @param bizId 业务 ID
- * @param attachTypeList 附件类型列表
- */
-async function listByBizId(bizType: string, bizId: string, attachTypeList?: string[]): Promise {
- return await axios.get(`${BASE_URI}/list/biz/id`, {
- params: {
- bizType,
- bizId,
- attachTypeList
+export const AttachmentAPI = {
+ /**
+ * 上传临时附件
+ *
+ * @param file 文件或文件列表
+ * @param ttl 有效期
+ * @returns 临时附件列表
+ */
+ async upload(file: File | File[], ttl?: string): Promise {
+ const formData = new FormData();
+ const fileList = Array.isArray(file) ? file : [file];
+ for (const item of fileList) {
+ formData.append("file", item);
}
- });
-}
+ if (ttl) {
+ formData.append("ttl", ttl);
+ }
+ return await axios.post(`${BASE_URI}/temp/upload`, formData);
+ },
+ /**
+ * 按业务差分更新附件
+ *
+ * @param req 更新请求
+ */
+ async updateByBizId(req: BizIdUpdate): Promise {
+ return await axios.post(`${BASE_URI}/update/biz/id`, req);
+ },
+ /**
+ * 按业务查询附件列表
+ *
+ * @param bizType 业务类型
+ * @param bizId 业务 ID
+ * @param attachTypeList 附件类型列表
+ */
+ async listByBizId(bizType: string, bizId: string, attachTypeList?: string[]): Promise {
+ return await axios.get(`${BASE_URI}/list/biz/id`, {
+ params: {
+ bizType,
+ bizId,
+ attachTypeList
+ }
+ });
+ },
-export default {
- upload,
- updateByBizId,
- listByBizId,
- getReadURL: CommonAPI.getAttachmentReadAPI,
- getTempReadURL: CommonAPI.getAttachmentTempReadAPI
+ getReadURL(id: string): string {
+ return CommonAPI.getAttachmentReadAPI(id);
+ },
+
+ getTempReadURL(id: string): string {
+ return CommonAPI.getAttachmentTempReadAPI(id);
+ }
};
+
+export default AttachmentAPI;
diff --git a/src/api/CommentAPI.ts b/src/api/CommentAPI.ts
index 14ae41f..bb8ad03 100644
--- a/src/api/CommentAPI.ts
+++ b/src/api/CommentAPI.ts
@@ -3,15 +3,13 @@ import { axios } from "./BaseAPI";
const BASE_URI = "/comment";
-async function page(page: Page): Promise> {
- return axios.post(`${BASE_URI}/list`, page);
-}
-
-async function create(captchaData: CaptchaData): Promise {
- return axios.post(`${BASE_URI}/create`, captchaData);
-}
-
-export default {
- page,
- create,
+export const CommentAPI = {
+ async page(page: Page): Promise> {
+ return axios.post(`${BASE_URI}/list`, page);
+ },
+ async create(captchaData: CaptchaData): Promise {
+ return axios.post(`${BASE_URI}/create`, captchaData);
+ }
};
+
+export default CommentAPI;
diff --git a/src/api/CommonAPI.ts b/src/api/CommonAPI.ts
index 259b99e..5dcd25e 100644
--- a/src/api/CommonAPI.ts
+++ b/src/api/CommonAPI.ts
@@ -9,39 +9,37 @@ function getBaseURI(): string {
return baseURL.replace(/\/$/, "");
}
-const getCaptchaAPI = () => `${getBaseURI()}/captcha`;
-
-async function captcha(width: number, height: number): Promise {
- 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 settingMap(map: Record): Promise