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';
|
export * from './wordpress';
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export namespace WordpressBlogApi {
|
|||||||
contentMarkdown?: string;
|
contentMarkdown?: string;
|
||||||
date?: string;
|
date?: string;
|
||||||
excerpt?: RenderedField | string;
|
excerpt?: RenderedField | string;
|
||||||
id: number | string;
|
id: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
modified?: string;
|
modified?: string;
|
||||||
slug?: string;
|
slug?: string;
|
||||||
@ -39,7 +39,7 @@ export namespace WordpressBlogApi {
|
|||||||
contentFormat?: 'html' | 'markdown';
|
contentFormat?: 'html' | 'markdown';
|
||||||
cover?: string;
|
cover?: string;
|
||||||
excerpt?: string;
|
excerpt?: string;
|
||||||
id?: number | string;
|
id?: string;
|
||||||
slug?: string;
|
slug?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
sticky?: boolean;
|
sticky?: boolean;
|
||||||
@ -119,17 +119,17 @@ export namespace WordpressBlogApi {
|
|||||||
export interface Term {
|
export interface Term {
|
||||||
count?: number;
|
count?: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
id: number | string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
parent?: number | string;
|
parent?: string;
|
||||||
slug?: string;
|
slug?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TermBody {
|
export interface TermBody {
|
||||||
description?: string;
|
description?: string;
|
||||||
id?: number | string;
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
parent?: number | string;
|
parent?: string;
|
||||||
slug?: string;
|
slug?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ export namespace WordpressBlogApi {
|
|||||||
hide_empty?: boolean;
|
hide_empty?: boolean;
|
||||||
pageNo?: number;
|
pageNo?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
parent?: number | string;
|
parent?: string;
|
||||||
search?: string;
|
search?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ export function getArticleList(params: WordpressBlogApi.ArticleQuery) {
|
|||||||
>('/blog/article/list', { params });
|
>('/blog/article/list', { params });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getArticleDetail(id: number | string) {
|
export function getArticleDetail(id: string) {
|
||||||
return requestClient.get<WordpressBlogApi.Article>('/blog/article/detail', {
|
return requestClient.get<WordpressBlogApi.Article>('/blog/article/detail', {
|
||||||
params: { id },
|
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>(
|
return requestClient.post<WordpressBlogApi.Article>(
|
||||||
`/blog/article/remove?id=${id}`,
|
`/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>(
|
return requestClient.post<WordpressBlogApi.Term>(
|
||||||
`/blog/category/remove?id=${id}&force=${force}`,
|
`/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);
|
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>(
|
return requestClient.post<WordpressBlogApi.Term>(
|
||||||
`/blog/tag/remove?id=${id}&force=${force}`,
|
`/blog/tag/remove?id=${id}&force=${force}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -54,7 +54,7 @@ export default defineComponent({
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const editingId = ref<number | string>();
|
const editingId = ref<string>();
|
||||||
const tableRows = ref<WordpressBlogApi.Term[]>([]);
|
const tableRows = ref<WordpressBlogApi.Term[]>([]);
|
||||||
const parentOptions = computed(() =>
|
const parentOptions = computed(() =>
|
||||||
tableRows.value
|
tableRows.value
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export interface BlogArticleFilters {
|
export interface BlogArticleFilters {
|
||||||
categories?: Array<number | string>;
|
categories?: string[];
|
||||||
tags?: Array<number | string>;
|
tags?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
let pendingFilters: BlogArticleFilters | null = null;
|
let pendingFilters: BlogArticleFilters | null = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user