|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div :style="boxStyle" class="overflow-hidden flex items-center justify-center">
|
|
|
+ <div :style="boxStyle" class="flex items-center justify-center">
|
|
|
<ImageBg
|
|
|
:src="src || defaultImg"
|
|
|
:image-style="styleMap?.mainStyle?.imageStyle"
|
|
|
@@ -10,7 +10,6 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { computed, watch, ref } from 'vue'
|
|
|
-import { getImageByPath } from '@/utils'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
import defaultImg from '@/assets/default.png'
|
|
|
import ImageBg from '../ImageBg.vue'
|
|
|
@@ -31,12 +30,11 @@ const props = defineProps<{
|
|
|
openScale: boolean
|
|
|
scale: number
|
|
|
antiAliasing: boolean
|
|
|
+ id?: string
|
|
|
}>()
|
|
|
|
|
|
const src = ref('')
|
|
|
const projectStore = useProjectStore()
|
|
|
-const width = ref(props.width)
|
|
|
-const height = ref(props.height)
|
|
|
|
|
|
const styleMap = useWidgetStyle({
|
|
|
widget: 'lv_image',
|
|
|
@@ -44,21 +42,13 @@ const styleMap = useWidgetStyle({
|
|
|
})
|
|
|
|
|
|
const imageProps = computed(() => {
|
|
|
- const { openScale, scale = 256, image } = props
|
|
|
- const s = scale / 256
|
|
|
- if (openScale) {
|
|
|
- return {
|
|
|
- width: `${width.value * s}px`,
|
|
|
- height: `${height.value * s}px`
|
|
|
- }
|
|
|
- }
|
|
|
- if (!image) {
|
|
|
- return {
|
|
|
- height: '100%',
|
|
|
- width: '100%'
|
|
|
- }
|
|
|
+ const { openScale, scale = 256, width, height } = props
|
|
|
+ const s = openScale ? scale / 256 : 1
|
|
|
+
|
|
|
+ return {
|
|
|
+ width: `${width * s}px`,
|
|
|
+ height: `${height * s}px`
|
|
|
}
|
|
|
- return {}
|
|
|
})
|
|
|
|
|
|
watch(
|
|
|
@@ -66,14 +56,9 @@ watch(
|
|
|
async (val) => {
|
|
|
if (val && projectStore.project) {
|
|
|
// 加载图片
|
|
|
- const basePath = projectStore.project.meta.path
|
|
|
+ const basePath = projectStore.projectPath
|
|
|
const imagePath = projectStore.project.resources.images.find((item) => item.id === val)?.path
|
|
|
- const result = await getImageByPath(basePath + imagePath)
|
|
|
- src.value = result?.src!
|
|
|
- width.value = result?.dimensions.width!
|
|
|
- height.value = result?.dimensions.height!
|
|
|
- } else {
|
|
|
- src.value = ''
|
|
|
+ src.value = `local:///${(basePath + imagePath).replaceAll('\\', '/')}`
|
|
|
}
|
|
|
},
|
|
|
{
|