diff --git a/src/common/methods/DesignFeatures/setImage.ts b/src/common/methods/DesignFeatures/setImage.ts index 95bbbf9..9e7d0cf 100644 --- a/src/common/methods/DesignFeatures/setImage.ts +++ b/src/common/methods/DesignFeatures/setImage.ts @@ -2,17 +2,25 @@ * @Author: ShawnPhang * @Date: 2022-02-22 15:06:14 * @Description: 设置图片类型元素 - * @LastEditors: ShawnPhang - * @LastEditTime: 2024-01-11 17:36:44 + * @LastEditors: ShawnPhang , Jeremy Yu + * @LastEditTime: 2024-03-01 20:55:51 */ import store from '@/store' import { getImage } from '../getImgDetail' -export default async function setItem2Data(item: any) { + +export type TItem2DataParam = { + width: number + height: number + url: string + model?: string +} + +export default async function setItem2Data(item: TItem2DataParam) { const cloneItem = JSON.parse(JSON.stringify(item)) const { width: screenWidth, height: screenHeight } = store.getters.dPage let { width: imgWidth, height: imgHeight } = item if (!imgWidth || !imgHeight) { - const actual: any = await getImage(item.url) + const actual = await getImage(item.url) cloneItem.width = imgWidth = actual.width cloneItem.height = imgHeight = actual.height } diff --git a/src/common/methods/DesignFeatures/setWidgetData.ts b/src/common/methods/DesignFeatures/setWidgetData.ts index be7f87b..c3fc7a9 100644 --- a/src/common/methods/DesignFeatures/setWidgetData.ts +++ b/src/common/methods/DesignFeatures/setWidgetData.ts @@ -11,7 +11,8 @@ import setImageData from '@/common/methods/DesignFeatures/setImage' import wText from '@/components/modules/widgets/wText/wText.vue' import wImage from '@/components/modules/widgets/wImage/wImage.vue' import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue' -export default async function(type: string, item: any, data: any) { + +export default async function(type: string, item: TCommonItemData, data: Record) { let setting = data if (type === 'text') { !item.fontFamily && !item.color ? (setting = JSON.parse(JSON.stringify(wText.setting))) : (setting = item) diff --git a/src/common/methods/getImgDetail.ts b/src/common/methods/getImgDetail.ts index d85934c..b208357 100644 --- a/src/common/methods/getImgDetail.ts +++ b/src/common/methods/getImgDetail.ts @@ -5,7 +5,7 @@ * @LastEditors: ShawnPhang * @LastEditTime: 2023-10-09 10:42:54 */ -export const getImage = (imgItem: string | File) => { +export const getImage = (imgItem: string | File): Promise => { // 创建对象 const img = new Image() diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 3af95d2..efc7432 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -7,3 +7,13 @@ type TCommResResult = { result: T } + + +type TCommonItemData = { + fontFamily?: string + color?: string + fontSize: number + width?: number + fontWeight: number + value: TItem2DataParam +}