muzhiyu-ui 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,13 @@
1
1
  <template>
2
2
  <view class="mu-icon" :style="iconWrapStyle" @tap="handleClick">
3
- <!-- 图片模式 (网络图片/本地图片/Base64) -->
3
+ <!-- 图片模式与 SVG DataURI 矢量模式(100% 兼容微信小程序) -->
4
4
  <image
5
- v-if="isImageUrl"
5
+ v-if="isImageUrl || svgDataUri"
6
6
  class="mu-icon__image"
7
- :src="imageUrl"
7
+ :src="isImageUrl ? imageUrl : svgDataUri"
8
8
  :style="imageSizeStyle"
9
9
  mode="aspectFit"
10
10
  />
11
- <!-- 内联 SVG 矢量图标 - 100% 极速精准渲染 -->
12
- <view
13
- v-else-if="svgInnerHtml"
14
- class="mu-icon__svg-wrap"
15
- :style="imageSizeStyle"
16
- v-html="svgInnerHtml"
17
- ></view>
18
11
  <!-- 回退文本 -->
19
12
  <text v-else class="mu-icon__fallback" :style="textStyle">{{ name }}</text>
20
13
  </view>
@@ -723,19 +716,19 @@ const isImageUrl = computed(() => {
723
716
  )
724
717
  })
725
718
 
726
- const svgInnerHtml = computed(() => {
719
+ const svgDataUri = computed(() => {
727
720
  if (isImageUrl.value) return ''
728
721
  const key = props.name ? props.name.toLowerCase() : 'info'
729
722
  const targetKey = aliasMap[key] || key
730
723
  const path = rawSvgPaths[targetKey] || rawSvgPaths['info']
731
724
  if (!path) return ''
732
-
733
- const colorVal = (!props.color || props.color === 'currentColor') ? 'currentColor' : props.color
725
+ // 替换 # 为 %23 以兼容微信小程序 SVG DataURI 编码
726
+ let colorVal = (!props.color || props.color === 'currentColor') ? '%23ffffff' : props.color.replace(/#/g, '%23')
734
727
  const isFill = ['star', 'heart'].includes(targetKey)
735
728
  const fillAttr = isFill ? colorVal : 'none'
736
729
  const strokeAttr = isFill ? 'none' : colorVal
737
-
738
- return `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="${fillAttr}" stroke="${strokeAttr}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${path}</svg>`
730
+ const svgString = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="${fillAttr}" stroke="${strokeAttr}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${path}</svg>`
731
+ return `data:image/svg+xml;utf8,${svgString}`
739
732
  })
740
733
 
741
734
  const iconWrapStyle = computed(() => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muzhiyu-ui",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "基于 UniApp Vue3 + SCSS 打造的全端极奢组件库",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "uni_modules": {
30
30
  "id": "muzhiyu-ui",
31
31
  "name": "muzhiyu-ui 极奢组件库",
32
- "version": "1.0.3",
32
+ "version": "1.0.4",
33
33
  "description": "基于 UniApp Vue3 + SCSS 打造的全端极奢 UI 组件库",
34
34
  "site": "",
35
35
  "displayName": "MuzhiyuUI 极奢全端组件库"