refactor: ♻️ 完善 typescript 类型,重构代码

Former-commit-id: 5ac4e273aaab2b068e28da5146f516da80a8852b
This commit is contained in:
hxr
2023-11-18 22:48:44 +08:00
parent 12c78f96d7
commit ae4d2067b7
15 changed files with 69 additions and 146 deletions

View File

@@ -1,88 +0,0 @@
import request from "@/utils/request";
export interface ArticleQuery {
page?: number;
limit?: number;
sort?: string;
title?: string;
type?: string;
importance?: number;
}
export interface ArticleDetail {
id: number;
timestamp: number;
title: string;
type: string;
status: string;
importance: number;
content?: string;
remark?: string;
}
export interface ArticleCreate {
type: string;
timestamp: Date;
title: string;
status?: string;
importance?: number;
remark?: string;
}
export interface ArticleUpdate {
id: number;
type?: string;
timestamp?: Date;
title?: string;
status?: string;
importance?: number;
remark?: string;
}
export function fetchList(query: ArticleQuery) {
return request({
url: "/api/v1/article/list",
method: "get",
params: query,
});
}
export function fetchArticle(id: number) {
return request({
url: "/api/v1/article/detail",
method: "get",
params: { id },
});
}
export function fetchPv(id: number) {
return request({
url: "/api/v1/article/pv",
method: "get",
params: { id },
});
}
export function createArticle(data: ArticleCreate) {
return request({
url: "/api/v1/article/create",
method: "post",
data,
});
}
export function updateArticle(data: ArticleUpdate) {
return request({
url: "/api/v1/article/update",
method: "post",
data,
});
}
export function deleteArticle(id: number) {
return request({
url: "/api/v1/article/delete",
method: "post",
data: { id },
});
}