feat: 兼容新版本后端
This commit is contained in:
parent
f23439d31f
commit
092a252ac4
@ -89,7 +89,8 @@ export const uploadFile = async (data: object) => {
|
|||||||
/**
|
/**
|
||||||
* 文件地址
|
* 文件地址
|
||||||
*/
|
*/
|
||||||
fileName: string
|
fileName: string,
|
||||||
|
httpurl: string,
|
||||||
}>(`${ModuleTypeEnum.PROJECT}/upload`, data, ContentTypeEnum.FORM_DATA)
|
}>(`${ModuleTypeEnum.PROJECT}/upload`, data, ContentTypeEnum.FORM_DATA)
|
||||||
return res
|
return res
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -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.httpurl) {
|
||||||
EditCanvasConfigEnum.BACKGROUND_IMAGE,
|
chartEditStore.setEditCanvasConfig(
|
||||||
`${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}?time=${new Date().getTime()}`
|
EditCanvasConfigEnum.BACKGROUND_IMAGE,
|
||||||
)
|
`${uploadRes.data.httpurl}?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('添加图片失败,请稍后重试!')
|
||||||
|
@ -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.httpurl) {
|
||||||
id: fetchRouteParamsLocation(),
|
await updateProjectApi({
|
||||||
indexImage: `${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}`
|
id: fetchRouteParamsLocation(),
|
||||||
})
|
indexImage: `${uploadRes.data.httpurl}`
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
await updateProjectApi({
|
||||||
|
id: fetchRouteParamsLocation(),
|
||||||
|
indexImage: `${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}`
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user