feat: 上传封面图
This commit is contained in:
@@ -27,8 +27,8 @@ export default function UploadFromWx(props: UploadFromWxProps) {
|
|||||||
let count = 0
|
let count = 0
|
||||||
const files = res.tempFiles.map(item => ({
|
const files = res.tempFiles.map(item => ({
|
||||||
filePath: item.path,
|
filePath: item.path,
|
||||||
description: 'test',
|
description: '封面图',
|
||||||
tags: 'test',
|
tags: 'cover',
|
||||||
is_public: 1 as unknown as 0 | 1,
|
is_public: 1 as unknown as 0 | 1,
|
||||||
id: (Date.now() + count++).toString(),
|
id: (Date.now() + count++).toString(),
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -57,27 +57,18 @@ export default forwardRef(function UploadImage(props: UploadImageProps, ref) {
|
|||||||
setVisible(true)
|
setVisible(true)
|
||||||
setSourceType(sourceType)
|
setSourceType(sourceType)
|
||||||
setMaxCount(maxCount)
|
setMaxCount(maxCount)
|
||||||
fetchImages()
|
fetchImages(sourceType)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function fetchImages() {
|
function fetchImages(st: SourceType) {
|
||||||
publishService.getPictures({
|
publishService.getPictures({ type: st }).then(res => {
|
||||||
pageOption: {
|
console.log(res, 1122)
|
||||||
page: 1,
|
if (res.code === 0) {
|
||||||
pageSize: 100,
|
|
||||||
},
|
|
||||||
seachOption: {
|
|
||||||
tag: '',
|
|
||||||
resource_type: 'image',
|
|
||||||
dateRange: [],
|
|
||||||
},
|
|
||||||
}).then(res => {
|
|
||||||
if (res.success) {
|
|
||||||
let start = 0
|
let start = 0
|
||||||
setImages(res.data.data.rows.map(item => ({
|
setImages(res.data.rows.map(item => ({
|
||||||
id: (Date.now() + start++).toString(),
|
id: (Date.now() + start++).toString(),
|
||||||
url: item.thumbnail_url,
|
url: item.file_url,
|
||||||
})))
|
})))
|
||||||
} else {
|
} else {
|
||||||
// TODO: 显示错误信息
|
// TODO: 显示错误信息
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class HttpService {
|
|||||||
|
|
||||||
// 构建完整URL
|
// 构建完整URL
|
||||||
private buildUrl(url: string, params?: Record<string, any>): string {
|
private buildUrl(url: string, params?: Record<string, any>): 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) {
|
if (params) {
|
||||||
const searchParams = new URLSearchParams()
|
const searchParams = new URLSearchParams()
|
||||||
|
|||||||
@@ -129,12 +129,48 @@ class PublishService {
|
|||||||
loadingText: '发布中...'
|
loadingText: '发布中...'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async getPictures(req: getPicturesReq): Promise<ApiResponse<getPicturesRes>> {
|
async getHistoryImageList(req: getPicturesReq): Promise<getPicturesRes> {
|
||||||
|
return httpService.post('/gallery/list', req, {
|
||||||
|
showLoading: false,
|
||||||
|
showToast: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async getPresetImageList(req: getPicturesReq): Promise<getPicturesRes> {
|
||||||
return httpService.post('/gallery/sys_img_list', req, {
|
return httpService.post('/gallery/sys_img_list', req, {
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
showToast: 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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出认证服务实例
|
// 导出认证服务实例
|
||||||
|
|||||||
Reference in New Issue
Block a user