UNPKG

@fmdevui/fm-dev

Version:

Page level components developed based on Element Plus.

91 lines (88 loc) 2.72 kB
import { defineComponent, computed, createElementBlock, openBlock, normalizeStyle, createBlock, resolveDynamicComponent, createElementVNode, normalizeClass } from 'vue'; const _hoisted_1 = ["src"]; var _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "svgIcon" }, __name: "svgicon", props: { // svg 图标组件名字 name: { type: String }, // svg 大小 size: { type: Number, default: () => 14 }, // svg 颜色 color: { type: String } }, setup(__props) { const props = __props; const linesString = ["https", "http", "/src", "/assets", "data:image", window.__env__.VITE_PUBLIC_PATH]; const getIconName = computed(() => { return props?.name; }); const isShowIconSvg = computed(() => { return props?.name?.startsWith("ele-"); }); const isShowIconImg = computed(() => { return linesString.find((str) => props.name?.startsWith(str)); }); const setIconSvgStyle = computed(() => { return `font-size: ${props.size}px;color: ${props.color};`; }); const setIconImgOutStyle = computed(() => { return `width: ${props.size}px;height: ${props.size}px;display: inline-block;overflow: hidden;`; }); const setIconSvgInsStyle = computed(() => { const filterStyle = []; const compatibles = ["-webkit", "-ms", "-o", "-moz"]; compatibles.forEach((j) => filterStyle.push(`${j}-filter: drop-shadow(${props.color} ${props.size}px 0);`)); return `width: ${props.size}px;height: ${props.size}px;position: relative;left: -${props.size}px;${filterStyle.join("")}`; }); return (_ctx, _cache) => { return isShowIconSvg.value ? (openBlock(), createElementBlock( "i", { key: 0, class: "el-icon", style: normalizeStyle(setIconSvgStyle.value) }, [ (openBlock(), createBlock(resolveDynamicComponent(getIconName.value))) ], 4 /* STYLE */ )) : isShowIconImg.value ? (openBlock(), createElementBlock( "div", { key: 1, style: normalizeStyle(setIconImgOutStyle.value) }, [ createElementVNode("img", { src: getIconName.value, style: normalizeStyle(setIconSvgInsStyle.value) }, null, 12, _hoisted_1) ], 4 /* STYLE */ )) : (openBlock(), createElementBlock( "i", { key: 2, class: normalizeClass(getIconName.value), style: normalizeStyle(setIconSvgStyle.value) }, null, 6 /* CLASS, STYLE */ )); }; } }); export { _sfc_main as default };