diff --git a/src/components/UploadCover/upload-from-wx.tsx b/src/components/UploadCover/upload-from-wx.tsx index 841c27b..33e23fe 100644 --- a/src/components/UploadCover/upload-from-wx.tsx +++ b/src/components/UploadCover/upload-from-wx.tsx @@ -27,8 +27,8 @@ export default function UploadFromWx(props: UploadFromWxProps) { let count = 0 const files = res.tempFiles.map(item => ({ filePath: item.path, - description: 'test', - tags: 'test', + description: '封面图', + tags: 'cover', is_public: 1 as unknown as 0 | 1, id: (Date.now() + count++).toString(), })) diff --git a/src/components/UploadCover/upload-source-popup.tsx b/src/components/UploadCover/upload-source-popup.tsx index dc72e44..7ceff4b 100644 --- a/src/components/UploadCover/upload-source-popup.tsx +++ b/src/components/UploadCover/upload-source-popup.tsx @@ -57,27 +57,18 @@ export default forwardRef(function UploadImage(props: UploadImageProps, ref) { setVisible(true) setSourceType(sourceType) setMaxCount(maxCount) - fetchImages() + fetchImages(sourceType) } })) - function fetchImages() { - publishService.getPictures({ - pageOption: { - page: 1, - pageSize: 100, - }, - seachOption: { - tag: '', - resource_type: 'image', - dateRange: [], - }, - }).then(res => { - if (res.success) { + function fetchImages(st: SourceType) { + publishService.getPictures({ type: st }).then(res => { + console.log(res, 1122) + if (res.code === 0) { let start = 0 - setImages(res.data.data.rows.map(item => ({ + setImages(res.data.rows.map(item => ({ id: (Date.now() + start++).toString(), - url: item.thumbnail_url, + url: item.file_url, }))) } else { // TODO: 显示错误信息 diff --git a/src/services/httpService.ts b/src/services/httpService.ts index fcee8f3..4c356fa 100644 --- a/src/services/httpService.ts +++ b/src/services/httpService.ts @@ -58,7 +58,7 @@ class HttpService { // 构建完整URL private buildUrl(url: string, params?: Record): string { - const fullUrl = url.startsWith('http') ? url : `${this.baseURL}${url}` + const fullUrl = url.startsWith('http') ? url : `${this.baseURL}${url.startsWith('/') ? url.slice(1) : url}` if (params) { const searchParams = new URLSearchParams() diff --git a/src/services/publishService.ts b/src/services/publishService.ts index 24d55d9..8d88261 100644 --- a/src/services/publishService.ts +++ b/src/services/publishService.ts @@ -129,12 +129,48 @@ class PublishService { loadingText: '发布中...' }) } - async getPictures(req: getPicturesReq): Promise> { + async getHistoryImageList(req: getPicturesReq): Promise { + return httpService.post('/gallery/list', req, { + showLoading: false, + showToast: false, + }) + } + async getPresetImageList(req: getPicturesReq): Promise { return httpService.post('/gallery/sys_img_list', req, { showLoading: false, showToast: false, }) } + async getPictures(req) { + const { type, otherReq = {} } = req + if (type === 'history') { + return this.getHistoryImageList({ + pageOption: { + page: 1, + pageSize: 100, + }, + seachOption: { + tag: 'cover', + resource_type: 'image', + dateRange: [], + }, + ...otherReq, + }) + } else { + return this.getPresetImageList({ + pageOption: { + page: 1, + pageSize: 100, + }, + seachOption: { + tag: '', + resource_type: 'image', + dateRange: [], + }, + ...otherReq, + }) + } + } } // 导出认证服务实例