refactor: 同步博客与资产管理契约
This commit is contained in:
parent
68e593237e
commit
5f270cff5c
80
apps/web-antdv-next/src/api/blog/asset.ts
Normal file
80
apps/web-antdv-next/src/api/blog/asset.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace BlogAssetApi {
|
||||
export interface BucketStatus {
|
||||
bucketName: string;
|
||||
exists: boolean;
|
||||
}
|
||||
|
||||
export interface ListQuery {
|
||||
bucketName?: string;
|
||||
prefix?: string;
|
||||
recursive?: boolean;
|
||||
}
|
||||
|
||||
export interface ObjectItem {
|
||||
etag: string;
|
||||
lastModified?: string;
|
||||
name: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface ObjectQuery {
|
||||
bucketName?: string;
|
||||
objectName: string;
|
||||
}
|
||||
|
||||
export interface PresignedUrlQuery extends ObjectQuery {
|
||||
expiry?: number;
|
||||
}
|
||||
|
||||
export interface UploadOptions {
|
||||
bucketName?: string;
|
||||
objectName?: string;
|
||||
}
|
||||
|
||||
export interface UploadResult {
|
||||
bucketName: string;
|
||||
etag: string;
|
||||
mimeType: string;
|
||||
objectName: string;
|
||||
size: number;
|
||||
url: string;
|
||||
}
|
||||
}
|
||||
|
||||
export function checkAssetBucket(bucketName?: string) {
|
||||
return requestClient.get<BlogAssetApi.BucketStatus>('/minio/check', {
|
||||
params: { bucketName },
|
||||
});
|
||||
}
|
||||
|
||||
export function createAssetBucket(bucketName?: string) {
|
||||
return requestClient.post<string>('/minio/bucket', undefined, {
|
||||
params: { bucketName },
|
||||
});
|
||||
}
|
||||
|
||||
export function uploadBlogAsset(
|
||||
file: Blob | File,
|
||||
options: BlogAssetApi.UploadOptions = {},
|
||||
) {
|
||||
return requestClient.upload<BlogAssetApi.UploadResult>('/minio/upload', {
|
||||
...options,
|
||||
file,
|
||||
});
|
||||
}
|
||||
|
||||
export function getAssetList(params: BlogAssetApi.ListQuery = {}) {
|
||||
return requestClient.get<BlogAssetApi.ObjectItem[]>('/minio/list', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function getAssetPresignedUrl(params: BlogAssetApi.PresignedUrlQuery) {
|
||||
return requestClient.get<string>('/minio/url', { params });
|
||||
}
|
||||
|
||||
export function removeBlogAsset(params: BlogAssetApi.ObjectQuery) {
|
||||
return requestClient.delete<boolean>('/minio/remove', { params });
|
||||
}
|
||||
@ -1 +1,2 @@
|
||||
export * from './asset';
|
||||
export * from './wordpress';
|
||||
|
||||
@ -21,7 +21,7 @@ export namespace WordpressBlogApi {
|
||||
contentMarkdown?: string;
|
||||
date?: string;
|
||||
excerpt?: RenderedField | string;
|
||||
id: number | string;
|
||||
id: string;
|
||||
link?: string;
|
||||
modified?: string;
|
||||
slug?: string;
|
||||
@ -39,7 +39,7 @@ export namespace WordpressBlogApi {
|
||||
contentFormat?: 'html' | 'markdown';
|
||||
cover?: string;
|
||||
excerpt?: string;
|
||||
id?: number | string;
|
||||
id?: string;
|
||||
slug?: string;
|
||||
status?: string;
|
||||
sticky?: boolean;
|
||||
@ -119,17 +119,17 @@ export namespace WordpressBlogApi {
|
||||
export interface Term {
|
||||
count?: number;
|
||||
description?: string;
|
||||
id: number | string;
|
||||
id: string;
|
||||
name: string;
|
||||
parent?: number | string;
|
||||
parent?: string;
|
||||
slug?: string;
|
||||
}
|
||||
|
||||
export interface TermBody {
|
||||
description?: string;
|
||||
id?: number | string;
|
||||
id?: string;
|
||||
name: string;
|
||||
parent?: number | string;
|
||||
parent?: string;
|
||||
slug?: string;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ export namespace WordpressBlogApi {
|
||||
hide_empty?: boolean;
|
||||
pageNo?: number;
|
||||
pageSize?: number;
|
||||
parent?: number | string;
|
||||
parent?: string;
|
||||
search?: string;
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ export function getArticleList(params: WordpressBlogApi.ArticleQuery) {
|
||||
>('/blog/article/list', { params });
|
||||
}
|
||||
|
||||
export function getArticleDetail(id: number | string) {
|
||||
export function getArticleDetail(id: string) {
|
||||
return requestClient.get<WordpressBlogApi.Article>('/blog/article/detail', {
|
||||
params: { id },
|
||||
});
|
||||
@ -168,7 +168,7 @@ export function updateArticle(data: WordpressBlogApi.ArticleBody) {
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteArticle(id: number | string) {
|
||||
export function deleteArticle(id: string) {
|
||||
return requestClient.post<WordpressBlogApi.Article>(
|
||||
`/blog/article/remove?id=${id}`,
|
||||
);
|
||||
@ -234,7 +234,7 @@ export function updateCategory(data: WordpressBlogApi.TermBody) {
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteCategory(id: number | string, force = true) {
|
||||
export function deleteCategory(id: string, force = true) {
|
||||
return requestClient.post<WordpressBlogApi.Term>(
|
||||
`/blog/category/remove?id=${id}&force=${force}`,
|
||||
);
|
||||
@ -255,7 +255,7 @@ export function updateTag(data: WordpressBlogApi.TermBody) {
|
||||
return requestClient.post<WordpressBlogApi.Term>('/blog/tag/update', data);
|
||||
}
|
||||
|
||||
export function deleteTag(id: number | string, force = true) {
|
||||
export function deleteTag(id: string, force = true) {
|
||||
return requestClient.post<WordpressBlogApi.Term>(
|
||||
`/blog/tag/remove?id=${id}&force=${force}`,
|
||||
);
|
||||
|
||||
@ -54,7 +54,7 @@ export default defineComponent({
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const editingId = ref<number | string>();
|
||||
const editingId = ref<string>();
|
||||
const tableRows = ref<WordpressBlogApi.Term[]>([]);
|
||||
const parentOptions = computed(() =>
|
||||
tableRows.value
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export interface BlogArticleFilters {
|
||||
categories?: Array<number | string>;
|
||||
tags?: Array<number | string>;
|
||||
categories?: string[];
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
let pendingFilters: BlogArticleFilters | null = null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user