|
|
@@ -1,5 +1,13 @@
|
|
|
<template>
|
|
|
- <div :style="styleMap?.mainStyle" class="w-full h-full box-border flex flex-col overflow-hidden">
|
|
|
+ <div
|
|
|
+ :style="styleMap?.mainStyle"
|
|
|
+ class="w-full h-full box-border flex flex-col overflow-hidden relative"
|
|
|
+ >
|
|
|
+ <ImageBg
|
|
|
+ v-if="styleMap?.mainStyle?.imageSrc"
|
|
|
+ :src="styleMap?.mainStyle?.imageSrc"
|
|
|
+ :image-color-style="styleMap?.mainStyle?.imageStyle"
|
|
|
+ />
|
|
|
<div
|
|
|
v-for="(row, index) in group || []"
|
|
|
:key="index"
|
|
|
@@ -7,7 +15,7 @@
|
|
|
:style="{ columnGap: styleMap?.mainStyle?.columnGap }"
|
|
|
>
|
|
|
<div
|
|
|
- class="h-full flex items-center justify-center overflow-hidden whitespace-pre!"
|
|
|
+ class="h-full flex items-center justify-center overflow-hidden whitespace-pre! relative"
|
|
|
v-for="(item, index) in row || []"
|
|
|
:key="`${index}-${index}`"
|
|
|
:style="{
|
|
|
@@ -18,7 +26,12 @@
|
|
|
)
|
|
|
}"
|
|
|
>
|
|
|
- {{ item.text }}
|
|
|
+ <ImageBg
|
|
|
+ v-if="getBtnStyle(item)?.imageSrc"
|
|
|
+ :src="getBtnStyle(item)?.imageSrc"
|
|
|
+ :image-color-style="getBtnStyle(item)?.imageStyle"
|
|
|
+ />
|
|
|
+ <span class="z-2">{{ item.text }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -28,6 +41,9 @@
|
|
|
import { useWidgetStyle, getStyle } from '../hooks/useWidgetStyle'
|
|
|
import { ButtonItem } from './data'
|
|
|
import { isEmpty, assign } from 'lodash-es'
|
|
|
+import { useProjectStore } from '@/store/modules/project'
|
|
|
+
|
|
|
+import ImageBg from '../ImageBg.vue'
|
|
|
|
|
|
const props = defineProps<{
|
|
|
width: number
|
|
|
@@ -43,14 +59,30 @@ const styleMap = useWidgetStyle({
|
|
|
props
|
|
|
})
|
|
|
|
|
|
+const projectStore = useProjectStore()
|
|
|
+
|
|
|
/**
|
|
|
* 获取自定义样式
|
|
|
*/
|
|
|
const getBtnStyle = (btnItem: ButtonItem) => {
|
|
|
const style = btnItem.style.find((item) => item.part.state === 'default') || {}
|
|
|
- const styleMap = {}
|
|
|
+ const styleMap: Record<string, any> = {}
|
|
|
Object.keys(style).forEach((key) => {
|
|
|
assign(styleMap, getStyle(key, style?.[key]))
|
|
|
+
|
|
|
+ if (key === 'background' && style?.[key]?.image?.imgId) {
|
|
|
+ const basePath = projectStore?.projectPath
|
|
|
+ const imagePath = projectStore?.project?.resources.images.find(
|
|
|
+ (item) => item.id === style?.[key]?.image?.imgId
|
|
|
+ )?.path
|
|
|
+ if (basePath && imagePath) {
|
|
|
+ styleMap.imageSrc = `local:///${(basePath + imagePath).replaceAll('\\', '/')}`
|
|
|
+ styleMap.imageStyle = {
|
|
|
+ backgroundColor: style?.[key]?.image?.color,
|
|
|
+ opacity: (style?.[key]?.image?.alpha || 255) / 255
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
return isEmpty(styleMap) ? null : styleMap
|