Skip to content

Commit fbbfaa8

Browse files
authored
fix: 修复小图标出码BUG (opentiny#1447)
* fix: 修复小图标出码BUG
1 parent 6bdcd39 commit fbbfaa8

6 files changed

Lines changed: 163 additions & 5 deletions

File tree

packages/common/component/ConfigItem.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,7 @@ export default {
295295
return
296296
}
297297
298-
if (
299-
property !== 'name' &&
300-
['SelectIconConfigurator', 'SelectIconConfigurator'].includes(props.property.widget.component)
301-
) {
298+
if (property !== 'name' && ['SelectIconConfigurator'].includes(props.property.widget.component)) {
302299
// icon以组件形式传入,实现类似:icon="IconPlus"的图标配置(排除Icon组件本身)
303300
value = {
304301
componentName: 'Icon',

packages/vue-generator/src/generator/vue/sfc/generateAttribute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export const handleTinyIconPropsHook = (schemaData, globalHooks, config) => {
427427
})
428428
}
429429

430-
attributes.push(isJSX ? `icon={${iconName}}` : `:icon="${iconName}"`)
430+
attributes.push(isJSX ? `${key}={${iconName}}` : `:${key}="${iconName}"`)
431431

432432
delete props[key]
433433
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { expect, test } from 'vitest'
2+
import { genSFCWithDefaultPlugin } from '@/generator/vue/sfc'
3+
import schema from './page.schema.json'
4+
import componentsMap from './componentsMap.json'
5+
import { formatCode } from '@/utils/formatCode'
6+
7+
test('should use [suffix-icon] as icon relative attr', async () => {
8+
const res = genSFCWithDefaultPlugin(schema, componentsMap)
9+
const formattedCode = formatCode(res, 'vue')
10+
11+
await expect(formattedCode).toMatchFileSnapshot('./expected/iconTest.vue')
12+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"componentName": "TinyButton",
4+
"exportName": "Button",
5+
"package": "@opentiny/vue",
6+
"version": "^3.10.0",
7+
"destructuring": true
8+
},
9+
{
10+
"componentName": "TinyIcon",
11+
"exportName": "Icon",
12+
"package": "@opentiny/vue",
13+
"version": "^3.10.0",
14+
"destructuring": true
15+
},
16+
{
17+
"componentName": "TinyDropdown",
18+
"exportName": "Dropdown",
19+
"package": "@opentiny/vue",
20+
"version": "^3.10.0",
21+
"destructuring": true
22+
}
23+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<div class="page-base-style">
3+
<tiny-button text="按钮文案" :resetTime="0" type="success" class="" :icon="TinyIconEdit"></tiny-button>
4+
<tiny-dropdown
5+
class=""
6+
:suffix-icon="TinyIconMore"
7+
:menu-options="{
8+
options: [
9+
{ name: '老友粉', disabled: true },
10+
{ name: '狮子头', divided: true },
11+
{ name: '黄金糕', divided: true }
12+
]
13+
}"
14+
></tiny-dropdown>
15+
<tiny-icon-custom fill="currentColor" class=""></tiny-icon-custom>
16+
</div>
17+
</template>
18+
19+
<script setup>
20+
import { Button as TinyButton, Dropdown as TinyDropdown } from '@opentiny/vue'
21+
import { IconEdit, IconMore, IconCustom } from '@opentiny/vue-icon'
22+
import * as vue from 'vue'
23+
import { defineProps, defineEmits } from 'vue'
24+
import { I18nInjectionKey } from 'vue-i18n'
25+
const TinyIconEdit = IconEdit()
26+
const TinyIconMore = IconMore()
27+
const TinyIconCustom = IconCustom()
28+
const props = defineProps({})
29+
const emit = defineEmits([])
30+
const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode()
31+
const wrap = lowcodeWrap(props, {
32+
emit
33+
})
34+
wrap({
35+
stores
36+
})
37+
const state = vue.reactive({})
38+
wrap({
39+
state
40+
})
41+
</script>
42+
<style scoped>
43+
.page-base-style {
44+
display: flex;
45+
margin: 0;
46+
gap: 12px;
47+
padding: 24px;
48+
}
49+
</style>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"componentName": "Page",
3+
"css": ".page-base-style {\r\n display: flex;\r\n margin: 0;\r\n gap: 12px;\r\n padding: 24px;\r\n}\r\n",
4+
"props": {
5+
"className": "page-base-style"
6+
},
7+
"lifeCycles": {},
8+
"children": [
9+
{
10+
"componentName": "TinyButton",
11+
"props": {
12+
"text": "按钮文案",
13+
"resetTime": 0,
14+
"className": "",
15+
"icon": {
16+
"componentName": "Icon",
17+
"props": {
18+
"name": "IconEdit"
19+
}
20+
},
21+
"type": "success"
22+
},
23+
"children": [],
24+
"id": "4e666212"
25+
},
26+
{
27+
"componentName": "TinyDropdown",
28+
"props": {
29+
"className": "",
30+
"suffix-icon": {
31+
"componentName": "Icon",
32+
"props": {
33+
"name": "IconMore"
34+
}
35+
},
36+
"menu-options": {
37+
"options": [
38+
{
39+
"name": "老友粉",
40+
"disabled": true
41+
},
42+
{
43+
"name": "狮子头",
44+
"divided": true
45+
},
46+
{
47+
"name": "黄金糕",
48+
"divided": true
49+
}
50+
]
51+
}
52+
},
53+
"children": [],
54+
"id": "45532625"
55+
},
56+
{
57+
"componentName": "Icon",
58+
"props": {
59+
"name": "IconCustom",
60+
"className": ""
61+
},
62+
"children": [],
63+
"id": "22235426"
64+
}
65+
],
66+
"dataSource": {
67+
"list": []
68+
},
69+
"state": {},
70+
"methods": {},
71+
"utils": [],
72+
"bridge": [],
73+
"inputs": [],
74+
"outputs": [],
75+
"fileName": "TestIcon",
76+
"id": "body"
77+
}

0 commit comments

Comments
 (0)