diff --git a/apps/web-antdv-next/src/api/blog/asset.ts b/apps/web-antdv-next/src/api/blog/asset.ts new file mode 100644 index 0000000..5cc5788 --- /dev/null +++ b/apps/web-antdv-next/src/api/blog/asset.ts @@ -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('/minio/check', { + params: { bucketName }, + }); +} + +export function createAssetBucket(bucketName?: string) { + return requestClient.post('/minio/bucket', undefined, { + params: { bucketName }, + }); +} + +export function uploadBlogAsset( + file: Blob | File, + options: BlogAssetApi.UploadOptions = {}, +) { + return requestClient.upload('/minio/upload', { + ...options, + file, + }); +} + +export function getAssetList(params: BlogAssetApi.ListQuery = {}) { + return requestClient.get('/minio/list', { + params, + }); +} + +export function getAssetPresignedUrl(params: BlogAssetApi.PresignedUrlQuery) { + return requestClient.get('/minio/url', { params }); +} + +export function removeBlogAsset(params: BlogAssetApi.ObjectQuery) { + return requestClient.delete('/minio/remove', { params }); +} diff --git a/apps/web-antdv-next/src/api/blog/index.ts b/apps/web-antdv-next/src/api/blog/index.ts index 4e07ed1..cafd8b7 100644 --- a/apps/web-antdv-next/src/api/blog/index.ts +++ b/apps/web-antdv-next/src/api/blog/index.ts @@ -1 +1,2 @@ +export * from './asset'; export * from './wordpress'; diff --git a/apps/web-antdv-next/src/api/blog/wordpress.ts b/apps/web-antdv-next/src/api/blog/wordpress.ts index e0b1465..1c4ce23 100644 --- a/apps/web-antdv-next/src/api/blog/wordpress.ts +++ b/apps/web-antdv-next/src/api/blog/wordpress.ts @@ -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('/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( `/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( `/blog/category/remove?id=${id}&force=${force}`, ); @@ -255,7 +255,7 @@ export function updateTag(data: WordpressBlogApi.TermBody) { return requestClient.post('/blog/tag/update', data); } -export function deleteTag(id: number | string, force = true) { +export function deleteTag(id: string, force = true) { return requestClient.post( `/blog/tag/remove?id=${id}&force=${force}`, ); diff --git a/apps/web-antdv-next/src/views/blog/modules/term-management.tsx b/apps/web-antdv-next/src/views/blog/modules/term-management.tsx index 3bf3ada..9faea2c 100644 --- a/apps/web-antdv-next/src/views/blog/modules/term-management.tsx +++ b/apps/web-antdv-next/src/views/blog/modules/term-management.tsx @@ -54,7 +54,7 @@ export default defineComponent({ const route = useRoute(); const router = useRouter(); - const editingId = ref(); + const editingId = ref(); const tableRows = ref([]); const parentOptions = computed(() => tableRows.value diff --git a/apps/web-antdv-next/src/views/blog/modules/use-article-filters.ts b/apps/web-antdv-next/src/views/blog/modules/use-article-filters.ts index e0025f8..3bc6d64 100644 --- a/apps/web-antdv-next/src/views/blog/modules/use-article-filters.ts +++ b/apps/web-antdv-next/src/views/blog/modules/use-article-filters.ts @@ -1,6 +1,6 @@ export interface BlogArticleFilters { - categories?: Array; - tags?: Array; + categories?: string[]; + tags?: string[]; } let pendingFilters: BlogArticleFilters | null = null;