refactor: ♻️ 完善 typescript 类型,重构代码
Former-commit-id: 5ac4e273aaab2b068e28da5146f516da80a8852b
This commit is contained in:
@@ -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 },
|
||||
});
|
||||
}
|
||||
@@ -12,8 +12,8 @@ export function loginApi(data: LoginData): AxiosPromise<LoginResult> {
|
||||
const formData = new FormData();
|
||||
formData.append("username", data.username);
|
||||
formData.append("password", data.password);
|
||||
formData.append("verifyCodeKey", data.verifyCodeKey || "");
|
||||
formData.append("verifyCode", data.verifyCode || "");
|
||||
formData.append("captchaKey", data.captchaKey || "");
|
||||
formData.append("captchaCode", data.captchaCode || "");
|
||||
return request({
|
||||
url: "/api/v1/auth/login",
|
||||
method: "post",
|
||||
|
||||
@@ -14,12 +14,12 @@ export interface LoginData {
|
||||
/**
|
||||
* 验证码缓存key
|
||||
*/
|
||||
verifyCodeKey?: string;
|
||||
captchaKey?: string;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
verifyCode?: string;
|
||||
captchaCode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,9 +51,9 @@ export interface CaptchaResult {
|
||||
/**
|
||||
* 验证码缓存key
|
||||
*/
|
||||
verifyCodeKey: string;
|
||||
captchaKey: string;
|
||||
/**
|
||||
* 验证码图片Base64字符串
|
||||
*/
|
||||
captchaImgBase64: string;
|
||||
captchaBase64: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user