From fb4915c13885cfca728f5b4c7624cf20bdb1d968 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周六, 03 5月 2025 14:39:38 +0800
Subject: [PATCH] 222
---
PipeLineLems/web/src/components/Icon/Icon.tsx | 40 +++++++++++++++++++++++++++++++++++++---
1 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/PipeLineLems/web/src/components/Icon/Icon.tsx b/PipeLineLems/web/src/components/Icon/Icon.tsx
index 5b5d157..f38e4b9 100644
--- a/PipeLineLems/web/src/components/Icon/Icon.tsx
+++ b/PipeLineLems/web/src/components/Icon/Icon.tsx
@@ -1,4 +1,5 @@
-import { computed, defineComponent } from 'vue'
+import { computed, defineComponent, ref } from 'vue'
+import parse from 'style-to-object'
export default defineComponent({
name: '鍥炬爣',
props: {
@@ -14,21 +15,54 @@
type: Number,
default: 12,
},
+ draggable: {
+ type: Boolean,
+ default: false,
+ },
+ cursor: {
+ type: String,
+ default: '',
+ },
+ class: {
+ type: String,
+ default: '',
+ },
+ style: {
+ type: [Object, String],
+ default: () => ({}),
+ },
},
emits: ['click'],
setup(props, { attrs, slots, emit }) {
+ const VITE_STATIC_URL = process.env.VITE_STATIC_URL || ''
const imgUrl = computed(() => {
- const imgName = props.icon
- return new URL(`../../assets/images/${imgName}.png`, import.meta.url).href
+ let imgName = props.icon
+ if (!imgName) return ''
+ let baseDir = 'images'
+ if (imgName.includes('files/')) {
+ baseDir = 'files'
+ imgName = imgName.split('/')[1]
+ }
+ return `${VITE_STATIC_URL}/resources/assets/${baseDir}/${imgName}.png`
+ })
+ const style = computed(() => {
+ if (typeof props.style === 'string') {
+ return parse(props.style)
+ }
+ return props.style
})
return () => {
+ if (imgUrl.value.includes('undefined')) return null
+
return (
<img
onClick={(evt: Event) => emit('click', evt)}
width={props.width}
height={props.height}
src={imgUrl.value}
+ style={{ cursor: props.cursor, ...style.value }}
+ class={props.class}
{...attrs}
/>
)
--
Gitblit v1.9.3