From 2edc8203649bfc6a97f0461a5d1376cb5e0644ce Mon Sep 17 00:00:00 2001 From: IchliebedichZhu <54796446@qq.com> Date: Thu, 21 Mar 2024 18:17:50 +0000 Subject: [PATCH] feat: convert wSvg component to composition API --- .../methods/DesignFeatures/setWidgetData.ts | 5 +- .../modules/panel/wrap/GraphListWrap.vue | 5 +- .../settings/EffectSelect/ContainerWrap.vue | 5 +- src/components/modules/widgets/wSvg/wSvg.vue | 602 ++++++++++-------- .../modules/widgets/wSvg/wSvgSetting.ts | 54 ++ .../modules/widgets/wSvg/wSvgStyle.vue | 221 ++++--- 6 files changed, 512 insertions(+), 380 deletions(-) create mode 100644 src/components/modules/widgets/wSvg/wSvgSetting.ts diff --git a/src/common/methods/DesignFeatures/setWidgetData.ts b/src/common/methods/DesignFeatures/setWidgetData.ts index 2d54607..2a74872 100644 --- a/src/common/methods/DesignFeatures/setWidgetData.ts +++ b/src/common/methods/DesignFeatures/setWidgetData.ts @@ -13,7 +13,8 @@ import wImageSetting from '@/components/modules/widgets/wImage/wImageSetting' // import wText from '@/components/modules/widgets/wText/wText.vue' import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting' import wImage from '@/components/modules/widgets/wImage/wImage.vue' -import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue' +// import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue' +import { wSvgSetting } from '@/components/modules/widgets/wSvg/wSvgSetting' export default async function(type: string, item: TCommonItemData, data: Record) { let setting = data @@ -36,7 +37,7 @@ export default async function(type: string, item: TCommonItemData, data: Record< setting.mask = item.value.url } if (type === 'svg') { - setting = JSON.parse(JSON.stringify(wSvg.setting)) + setting = JSON.parse(JSON.stringify(wSvgSetting)) const img = await setImageData(item.value) setting.width = img.width setting.height = img.height // parseInt(100 / item.value.ratio, 10) diff --git a/src/components/modules/panel/wrap/GraphListWrap.vue b/src/components/modules/panel/wrap/GraphListWrap.vue index 7d16256..a7d639a 100644 --- a/src/components/modules/panel/wrap/GraphListWrap.vue +++ b/src/components/modules/panel/wrap/GraphListWrap.vue @@ -43,7 +43,8 @@ import { defineComponent, reactive, toRefs, onMounted, watch } from 'vue' import api from '@/api' // import wImage from '../../widgets/wImage/wImage.vue' import wImageSetting from '../../widgets/wImage/wImageSetting' -import wSvg from '../../widgets/wSvg/wSvg.vue' +// import wSvg from '../../widgets/wSvg/wSvg.vue' +import { wSvgSetting } from '../../widgets/wSvg/wSvgSetting' import { mapActions, mapGetters } from 'vuex' import setImageData from '@/common/methods/DesignFeatures/setImage' import DragHelper from '@/common/hooks/dragHelper' @@ -160,7 +161,7 @@ export default defineComponent({ return } this.$store.commit('setShowMoveable', false) // 清理掉上一次的选择 - let setting = item.type === 'svg' ? JSON.parse(JSON.stringify(wSvg.setting)) : JSON.parse(JSON.stringify(wImageSetting)) + let setting = item.type === 'svg' ? JSON.parse(JSON.stringify(wSvgSetting)) : JSON.parse(JSON.stringify(wImageSetting)) const img: any = await setImageData(item) setting.width = img.width diff --git a/src/components/modules/settings/EffectSelect/ContainerWrap.vue b/src/components/modules/settings/EffectSelect/ContainerWrap.vue index e715464..2b4a349 100644 --- a/src/components/modules/settings/EffectSelect/ContainerWrap.vue +++ b/src/components/modules/settings/EffectSelect/ContainerWrap.vue @@ -42,7 +42,8 @@ import api from '@/api' import { toRefs, reactive, watch, onMounted, nextTick } from 'vue' import { ElRadioGroup, ElRadioButton } from 'element-plus' -import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue' +// import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue' +import {wSvgSetting} from '@/components/modules/widgets/wSvg/wSvgSetting' import { TGetListResult } from '@/api/material'; type TProps = { @@ -75,7 +76,7 @@ const state = reactive({ const select = (value: string = '') => { state.visiable = false - const setting = JSON.parse(JSON.stringify(wSvg.setting)) + const setting = JSON.parse(JSON.stringify(wSvgSetting)) setting.svgUrl = value emit('change', setting) } diff --git a/src/components/modules/widgets/wSvg/wSvg.vue b/src/components/modules/widgets/wSvg/wSvg.vue index 5b06ad8..1665d44 100644 --- a/src/components/modules/widgets/wSvg/wSvg.vue +++ b/src/components/modules/widgets/wSvg/wSvg.vue @@ -4,10 +4,10 @@