|
@@ -1,12 +1,25 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div :style="styleMap?.mainStyle" class="w-full h-full relative">
|
|
<div :style="styleMap?.mainStyle" class="w-full h-full relative">
|
|
|
<ImageBg :src="styleMap?.mainStyle?.imageSrc" :imageStyle="styleMap?.mainStyle?.imageStyle" />
|
|
<ImageBg :src="styleMap?.mainStyle?.imageSrc" :imageStyle="styleMap?.mainStyle?.imageStyle" />
|
|
|
- <div class="w-full h-full absolute left-0 top-0 z-0 flex items-center justify-center">
|
|
|
|
|
|
|
+ <div class="w-full h-full absolute left-0 top-0 z-0">
|
|
|
<ImageBg
|
|
<ImageBg
|
|
|
- :src="src || defaultImg"
|
|
|
|
|
|
|
+ v-if="img.left.src"
|
|
|
|
|
+ :src="img.left.src"
|
|
|
:image-style="styleMap?.mainStyle?.image"
|
|
:image-style="styleMap?.mainStyle?.image"
|
|
|
- :image-props="{ height: '100%', width: '100%' }"
|
|
|
|
|
|
|
+ :style="{ ...img.left.style, zIndex: 2 }"
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <ImageBg
|
|
|
|
|
+ :src="img.center.src"
|
|
|
|
|
+ :image-style="styleMap?.mainStyle?.image"
|
|
|
|
|
+ :style="{ ...img.center.style, zIndex: 1, left: '50%', transform: 'translateX(-50%)' }"
|
|
|
|
|
+ />
|
|
|
|
|
+ <ImageBg
|
|
|
|
|
+ v-if="img.right.src"
|
|
|
|
|
+ :src="img.right.src"
|
|
|
|
|
+ :image-style="styleMap?.mainStyle?.image"
|
|
|
|
|
+ :style="{ ...img.right.style, zIndex: 3, right: 0, left: 'auto' }"
|
|
|
|
|
+ />
|
|
|
|
|
+ <div v-else />
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
<div
|
|
@@ -20,12 +33,12 @@
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { computed, ref, watch } from 'vue'
|
|
import { computed, ref, watch } from 'vue'
|
|
|
-import defaultImg from '@/assets/default.png'
|
|
|
|
|
-import { getImageByPath } from '@/utils'
|
|
|
|
|
|
|
+// import defaultImg from '@/assets/default.png'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
import { useWidgetStyle } from '../hooks/useWidgetStyle'
|
|
import { useWidgetStyle } from '../hooks/useWidgetStyle'
|
|
|
import ImageBg from '../ImageBg.vue'
|
|
import ImageBg from '../ImageBg.vue'
|
|
|
import { useLanguage } from '../hooks/useLanguage'
|
|
import { useLanguage } from '../hooks/useLanguage'
|
|
|
|
|
+import { getImageByPath } from '@/utils'
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
width: number
|
|
width: number
|
|
@@ -33,15 +46,54 @@ const props = defineProps<{
|
|
|
text?: string
|
|
text?: string
|
|
|
styles: any
|
|
styles: any
|
|
|
state?: string
|
|
state?: string
|
|
|
- ReleasedImage: string
|
|
|
|
|
- PressedImage: string
|
|
|
|
|
- CheckedReleasedImage: string
|
|
|
|
|
- CheckedPressedImage: string
|
|
|
|
|
|
|
+ ReleasedImage: {
|
|
|
|
|
+ left: string
|
|
|
|
|
+ center: string
|
|
|
|
|
+ right: string
|
|
|
|
|
+ }
|
|
|
|
|
+ DisableImage: {
|
|
|
|
|
+ left: string
|
|
|
|
|
+ center: string
|
|
|
|
|
+ right: string
|
|
|
|
|
+ }
|
|
|
|
|
+ PessedImage: {
|
|
|
|
|
+ left: string
|
|
|
|
|
+ center: string
|
|
|
|
|
+ right: string
|
|
|
|
|
+ }
|
|
|
|
|
+ CheckedReleasedImage: {
|
|
|
|
|
+ left: string
|
|
|
|
|
+ center: string
|
|
|
|
|
+ right: string
|
|
|
|
|
+ }
|
|
|
|
|
+ CheckedPressedImage: {
|
|
|
|
|
+ left: string
|
|
|
|
|
+ center: string
|
|
|
|
|
+ right: string
|
|
|
|
|
+ }
|
|
|
|
|
+ CheckedDisableImage: {
|
|
|
|
|
+ left: string
|
|
|
|
|
+ center: string
|
|
|
|
|
+ right: string
|
|
|
|
|
+ }
|
|
|
scale?: number
|
|
scale?: number
|
|
|
antiAliasing?: boolean
|
|
antiAliasing?: boolean
|
|
|
}>()
|
|
}>()
|
|
|
|
|
|
|
|
-const src = ref('')
|
|
|
|
|
|
|
+const img = ref({
|
|
|
|
|
+ left: {
|
|
|
|
|
+ src: '',
|
|
|
|
|
+ style: {}
|
|
|
|
|
+ },
|
|
|
|
|
+ center: {
|
|
|
|
|
+ src: '',
|
|
|
|
|
+ style: {}
|
|
|
|
|
+ },
|
|
|
|
|
+ right: {
|
|
|
|
|
+ src: '',
|
|
|
|
|
+ style: {}
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
const projectStore = useProjectStore()
|
|
const projectStore = useProjectStore()
|
|
|
const { resolveText, getTextStyle } = useLanguage()
|
|
const { resolveText, getTextStyle } = useLanguage()
|
|
|
const resolvedText = computed(() => resolveText(props.text))
|
|
const resolvedText = computed(() => resolveText(props.text))
|
|
@@ -61,15 +113,20 @@ watch(
|
|
|
if (val && projectStore.project) {
|
|
if (val && projectStore.project) {
|
|
|
// 加载图片
|
|
// 加载图片
|
|
|
const basePath = projectStore.projectPath
|
|
const basePath = projectStore.projectPath
|
|
|
- const imagePath = projectStore.imagePathMap[val]
|
|
|
|
|
- if (!imagePath) {
|
|
|
|
|
- src.value = ''
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- const result = await getImageByPath(basePath + imagePath)
|
|
|
|
|
- src.value = result?.src!
|
|
|
|
|
- } else {
|
|
|
|
|
- src.value = ''
|
|
|
|
|
|
|
+ Object.keys(val).forEach(async (key) => {
|
|
|
|
|
+ const imagePath = projectStore.imagePathMap[val[key]]
|
|
|
|
|
+ if (!imagePath) {
|
|
|
|
|
+ img.value[key].src = ''
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const imgInfo = await getImageByPath(basePath + imagePath)
|
|
|
|
|
+ const { src, dimensions = { width: 0, height: 0 } } = imgInfo || {}
|
|
|
|
|
+ img.value[key].src = src
|
|
|
|
|
+ img.value[key].style = {
|
|
|
|
|
+ width: dimensions?.width ? `${dimensions.width}px` : 'auto',
|
|
|
|
|
+ height: dimensions?.height ? `${dimensions.height}px` : 'auto'
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|