Merge branch 'master-fetch-dev' into master-fetch

This commit is contained in:
奔跑的面条 2023-05-08 20:36:15 +08:00
commit 8809022e8c
4 changed files with 31 additions and 43 deletions

View File

@ -89,7 +89,8 @@ export const uploadFile = async (data: object) => {
/** /**
* *
*/ */
fileName: string fileName: string,
fileurl: string,
}>(`${ModuleTypeEnum.PROJECT}/upload`, data, ContentTypeEnum.FORM_DATA) }>(`${ModuleTypeEnum.PROJECT}/upload`, data, ContentTypeEnum.FORM_DATA)
return res return res
} catch { } catch {

View File

@ -139,7 +139,7 @@ import { loadAsyncComponent, fetchRouteParamsLocation } from '@/utils'
import { PreviewScaleEnum } from '@/enums/styleEnum' import { PreviewScaleEnum } from '@/enums/styleEnum'
import { ResultEnum } from '@/enums/httpEnum' import { ResultEnum } from '@/enums/httpEnum'
import { icon } from '@/plugins' import { icon } from '@/plugins'
import { uploadFile} from '@/api/path' import { uploadFile } from '@/api/path'
const { ColorPaletteIcon } = icon.ionicons5 const { ColorPaletteIcon } = icon.ionicons5
const { ScaleIcon, FitToScreenIcon, FitToHeightIcon, FitToWidthIcon } = icon.carbon const { ScaleIcon, FitToScreenIcon, FitToHeightIcon, FitToWidthIcon } = icon.carbon
@ -273,24 +273,26 @@ const customRequest = (options: UploadCustomRequestOptions) => {
nextTick(async () => { nextTick(async () => {
if (file.file) { if (file.file) {
// //
const newNameFile = new File( const newNameFile = new File([file.file], `${fetchRouteParamsLocation()}_index_background.png`, {
[file.file], type: file.file.type
`${fetchRouteParamsLocation()}_index_background.png`, })
{ type: file.file.type }
)
let uploadParams = new FormData() let uploadParams = new FormData()
uploadParams.append('object', newNameFile) uploadParams.append('object', newNameFile)
const uploadRes = await uploadFile(uploadParams) const uploadRes = await uploadFile(uploadParams)
if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) { if (uploadRes && uploadRes.code === ResultEnum.SUCCESS) {
chartEditStore.setEditCanvasConfig( if (uploadRes.data.fileurl) {
EditCanvasConfigEnum.BACKGROUND_IMAGE, chartEditStore.setEditCanvasConfig(
`${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}?time=${new Date().getTime()}` EditCanvasConfigEnum.BACKGROUND_IMAGE,
) `${uploadRes.data.fileurl}?time=${new Date().getTime()}`
chartEditStore.setEditCanvasConfig( )
EditCanvasConfigEnum.SELECT_COLOR, } else {
false chartEditStore.setEditCanvasConfig(
) EditCanvasConfigEnum.BACKGROUND_IMAGE,
`${systemStore.getFetchInfo.OSSUrl || ''}${uploadRes.data.fileName}?time=${new Date().getTime()}`
)
}
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.SELECT_COLOR, false)
return return
} }
window['$message'].error('添加图片失败,请稍后重试!') window['$message'].error('添加图片失败,请稍后重试!')

View File

@ -294,10 +294,17 @@ export const useSync = () => {
const uploadRes = await uploadFile(uploadParams) const uploadRes = await uploadFile(uploadParams)
// 保存预览图 // 保存预览图
if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) { if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) {
await updateProjectApi({ if (uploadRes.data.fileurl) {
id: fetchRouteParamsLocation(), await updateProjectApi({
indexImage: `${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}` id: fetchRouteParamsLocation(),
}) indexImage: `${uploadRes.data.fileurl}`
})
} else {
await updateProjectApi({
id: fetchRouteParamsLocation(),
indexImage: `${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}`
})
}
} }
} }
} catch (e) { } catch (e) {

View File

@ -124,22 +124,6 @@ const selectOptions = ref([
key: 'preview', key: 'preview',
icon: renderIcon(BrowsersOutlineIcon) icon: renderIcon(BrowsersOutlineIcon)
}, },
{
label: renderLang('global.r_copy'),
key: 'copy',
icon: renderIcon(CopyIcon),
disabled: true
},
{
label: renderLang('global.r_rename'),
key: 'rename',
icon: renderIcon(PencilIcon),
disabled: true
},
{
type: 'divider',
key: 'd1'
},
{ {
label: props.cardData?.release label: props.cardData?.release
? renderLang('global.r_unpublish') ? renderLang('global.r_unpublish')
@ -147,15 +131,9 @@ const selectOptions = ref([
key: 'release', key: 'release',
icon: renderIcon(SendIcon) icon: renderIcon(SendIcon)
}, },
{
label: renderLang('global.r_download'),
key: 'download',
icon: renderIcon(DownloadIcon),
disabled: true
},
{ {
type: 'divider', type: 'divider',
key: 'd2' key: 'd1'
}, },
{ {
label: renderLang('global.r_delete'), label: renderLang('global.r_delete'),