@mc-markets/ui 1.0.86 → 1.0.90
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.
- package/README.md +40 -141
- package/dist/404.html +22 -22
- package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +5 -13
- package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts.map +1 -1
- package/dist/components/Breadcrumb/BreadcrumbSeparator.vue.d.ts +3 -0
- package/dist/components/Breadcrumb/BreadcrumbSeparator.vue.d.ts.map +1 -0
- package/dist/components/DatePicker/DatePicker.vue.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/TabCard/TabCard.vue.d.ts.map +1 -1
- package/dist/components/Tag/Tag.vue.d.ts +2 -0
- package/dist/components/Tag/Tag.vue.d.ts.map +1 -1
- package/dist/index.cjs +1 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +605 -661
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/packages/components/Alert/Alert.vue +139 -139
- package/packages/components/Banner/Banner.vue +299 -299
- package/packages/components/Breadcrumb/Breadcrumb.vue +113 -77
- package/packages/components/Breadcrumb/BreadcrumbSeparator.vue +31 -0
- package/packages/components/Button/Button.vue +17 -17
- package/packages/components/DatePicker/DatePicker.vue +85 -86
- package/packages/components/Dialog/Dialog.vue +61 -61
- package/packages/components/Empty/Empty.vue +74 -74
- package/packages/components/Form/Form.vue +30 -30
- package/packages/components/FormItem/FormItem.vue +19 -19
- package/packages/components/Icon/Icon.vue +210 -210
- package/packages/components/Input/Input.vue +15 -15
- package/packages/components/Message/Message.vue +503 -503
- package/packages/components/NotifiMessage/NotifiMessage.vue +293 -293
- package/packages/components/Notification/Notification.vue +19 -19
- package/packages/components/Option/Option.vue +13 -13
- package/packages/components/OptionGroup/OptionGroup.vue +13 -13
- package/packages/components/Pagination/Pagination.vue +61 -61
- package/packages/components/Radio/Radio.vue +67 -67
- package/packages/components/RadioButton/RadioButton.vue +110 -110
- package/packages/components/RadioGroup/RadioGroup.vue +155 -155
- package/packages/components/Select/Select.vue +22 -22
- package/packages/components/Switch/Switch.vue +47 -47
- package/packages/components/TabCard/TabCard.vue +107 -177
- package/packages/components/TabCard/TabCardItem.vue +105 -102
- package/packages/components/Table/Table.vue +17 -17
- package/packages/components/Table/TableColumn.vue +20 -20
- package/packages/components/Tabs/TabPane.vue +79 -79
- package/packages/components/Tabs/Tabs.vue +267 -267
- package/packages/components/Tag/Tag.vue +211 -164
- package/packages/components/Tooltip/Tooltip.vue +58 -58
- package/packages/hooks/useClassName.js +23 -23
- package/packages/styles/README.md +129 -129
- package/packages/styles/components/button.scss +121 -121
- package/packages/styles/components/checkbox.scss +18 -18
- package/packages/styles/components/dialog.scss +47 -47
- package/packages/styles/components/form.scss +18 -18
- package/packages/styles/components/input.scss +14 -14
- package/packages/styles/components/select.scss +62 -60
- package/packages/styles/components/table.scss +37 -37
- package/packages/styles/components/tabs.scss +76 -76
- package/packages/styles/components/tag.scss +142 -142
- package/packages/styles/font/iconfont.scss +363 -363
- package/packages/styles/index.scss +94 -94
- package/packages/styles/variables/border-mode.css +6 -6
- package/packages/styles/variables/color-modes-dark.css +143 -143
- package/packages/styles/variables/index.scss +5 -5
- package/packages/styles/variables/primitives-style.css +112 -112
- package/packages/styles/variables/radius-mode.css +14 -14
- package/packages/styles/variables/spacing-mode.css +20 -20
- package/packages/styles/variables/typography-desktop.css +40 -40
- package/packages/styles/variables/typography-mobile.css +40 -40
- package/packages/utils/classNames.js +23 -23
- package/packages/utils/styleUtils.js +105 -105
- package/dist/components/Breadcrumb/BreadcrumbItem.vue.d.ts +0 -17
- package/dist/components/Breadcrumb/BreadcrumbItem.vue.d.ts.map +0 -1
- package/packages/components/Breadcrumb/BreadcrumbItem.vue +0 -142
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-empty v-bind="mergedAttrs" :image="imageUrl">
|
|
3
|
-
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
-
<slot :name="name" />
|
|
5
|
-
</template>
|
|
6
|
-
</el-empty>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
// 定义可选的图片文件名(在模块作用域中)
|
|
11
|
-
const availableImages = [
|
|
12
|
-
'404',
|
|
13
|
-
'billing',
|
|
14
|
-
'cart',
|
|
15
|
-
'comments',
|
|
16
|
-
'dashboard',
|
|
17
|
-
'files',
|
|
18
|
-
'inbox',
|
|
19
|
-
'location',
|
|
20
|
-
'network',
|
|
21
|
-
'notifications',
|
|
22
|
-
'orders',
|
|
23
|
-
'records',
|
|
24
|
-
'session',
|
|
25
|
-
'subscription',
|
|
26
|
-
'todo',
|
|
27
|
-
'wishlist'
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
export default {
|
|
31
|
-
name: 'MEmpty'
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<script setup>
|
|
36
|
-
import { computed, useAttrs } from 'vue'
|
|
37
|
-
|
|
38
|
-
const props = defineProps({
|
|
39
|
-
image: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: 'orders',
|
|
42
|
-
validator: (value) => {
|
|
43
|
-
// 如果是完整的URL或路径,直接通过验证
|
|
44
|
-
if (value.includes('/') || value.includes('http')) {
|
|
45
|
-
return true
|
|
46
|
-
}
|
|
47
|
-
// 否则检查是否在可选列表中
|
|
48
|
-
return availableImages.includes(value)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const attrs = useAttrs()
|
|
54
|
-
|
|
55
|
-
// 排除 image 属性,避免重复绑定
|
|
56
|
-
const mergedAttrs = computed(() => {
|
|
57
|
-
const { image, ...rest } = attrs
|
|
58
|
-
return rest
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
// 计算图片URL
|
|
62
|
-
const imageUrl = computed(() => {
|
|
63
|
-
const { image } = props
|
|
64
|
-
|
|
65
|
-
// 如果是完整的URL或路径,直接返回
|
|
66
|
-
if (image.includes('/') || image.includes('http')) {
|
|
67
|
-
return image
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 使用 public 目录中的图片
|
|
71
|
-
// Vite 会自动处理 public 目录中的静态资源
|
|
72
|
-
return
|
|
73
|
-
})
|
|
74
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<el-empty v-bind="mergedAttrs" :image="imageUrl">
|
|
3
|
+
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
+
<slot :name="name" />
|
|
5
|
+
</template>
|
|
6
|
+
</el-empty>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
// 定义可选的图片文件名(在模块作用域中)
|
|
11
|
+
const availableImages = [
|
|
12
|
+
'404',
|
|
13
|
+
'billing',
|
|
14
|
+
'cart',
|
|
15
|
+
'comments',
|
|
16
|
+
'dashboard',
|
|
17
|
+
'files',
|
|
18
|
+
'inbox',
|
|
19
|
+
'location',
|
|
20
|
+
'network',
|
|
21
|
+
'notifications',
|
|
22
|
+
'orders',
|
|
23
|
+
'records',
|
|
24
|
+
'session',
|
|
25
|
+
'subscription',
|
|
26
|
+
'todo',
|
|
27
|
+
'wishlist'
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
name: 'MEmpty'
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import { computed, useAttrs } from 'vue'
|
|
37
|
+
|
|
38
|
+
const props = defineProps({
|
|
39
|
+
image: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: 'orders',
|
|
42
|
+
validator: (value) => {
|
|
43
|
+
// 如果是完整的URL或路径,直接通过验证
|
|
44
|
+
if (value.includes('/') || value.includes('http')) {
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
// 否则检查是否在可选列表中
|
|
48
|
+
return availableImages.includes(value)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const attrs = useAttrs()
|
|
54
|
+
|
|
55
|
+
// 排除 image 属性,避免重复绑定
|
|
56
|
+
const mergedAttrs = computed(() => {
|
|
57
|
+
const { image, ...rest } = attrs
|
|
58
|
+
return rest
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// 计算图片URL
|
|
62
|
+
const imageUrl = computed(() => {
|
|
63
|
+
const { image } = props
|
|
64
|
+
|
|
65
|
+
// 如果是完整的URL或路径,直接返回
|
|
66
|
+
if (image.includes('/') || image.includes('http')) {
|
|
67
|
+
return image
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 使用 public 目录中的图片
|
|
71
|
+
// Vite 会自动处理 public 目录中的静态资源
|
|
72
|
+
return `https://cfdsaas-pre.oss-cn-hongkong.aliyuncs.com/mc-assets/mc-ui/empty/${image}.png`
|
|
73
|
+
})
|
|
74
|
+
</script>
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-form ref="formRef" v-bind="$attrs" class="m-form">
|
|
3
|
-
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
-
<slot :name="name" />
|
|
5
|
-
</template>
|
|
6
|
-
</el-form>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
import { ref, useAttrs
|
|
11
|
-
|
|
12
|
-
defineOptions({
|
|
13
|
-
name: 'MForm'
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const formRef = ref()
|
|
17
|
-
const attrs = useAttrs()
|
|
18
|
-
|
|
19
|
-
// 暴露表单方法
|
|
20
|
-
defineExpose({
|
|
21
|
-
validate: (callback) => formRef.value?.validate(callback),
|
|
22
|
-
validateField: (props, callback) => formRef.value?.validateField(props, callback),
|
|
23
|
-
resetFields: () => formRef.value?.resetFields(),
|
|
24
|
-
scrollToField: (prop) => formRef.value?.scrollToField(prop),
|
|
25
|
-
clearValidate: (props) => formRef.value?.clearValidate(props)
|
|
26
|
-
})
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<style lang="scss">
|
|
30
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<el-form ref="formRef" v-bind="$attrs" class="m-form">
|
|
3
|
+
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
+
<slot :name="name" />
|
|
5
|
+
</template>
|
|
6
|
+
</el-form>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { ref, useAttrs } from 'vue'
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
name: 'MForm'
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const formRef = ref()
|
|
17
|
+
const attrs = useAttrs()
|
|
18
|
+
|
|
19
|
+
// 暴露表单方法
|
|
20
|
+
defineExpose({
|
|
21
|
+
validate: (callback) => formRef.value?.validate(callback),
|
|
22
|
+
validateField: (props, callback) => formRef.value?.validateField(props, callback),
|
|
23
|
+
resetFields: () => formRef.value?.resetFields(),
|
|
24
|
+
scrollToField: (prop) => formRef.value?.scrollToField(prop),
|
|
25
|
+
clearValidate: (props) => formRef.value?.clearValidate(props)
|
|
26
|
+
})
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<style lang="scss">
|
|
30
|
+
|
|
31
31
|
</style>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-form-item v-bind="$attrs" class="m-form-item">
|
|
3
|
-
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
-
<slot :name="name" />
|
|
5
|
-
</template>
|
|
6
|
-
</el-form-item>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
defineOptions({
|
|
11
|
-
name: 'MFormItem'
|
|
12
|
-
})
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<style lang="scss">
|
|
16
|
-
// FormItem 组件样式 - 使用 m-form-item 类名隔离样式
|
|
17
|
-
.m-form-item {
|
|
18
|
-
// 自定义样式可以在这里添加
|
|
19
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-item v-bind="$attrs" class="m-form-item">
|
|
3
|
+
<template v-for="(_, name) in $slots" :key="name" #[name]>
|
|
4
|
+
<slot :name="name" />
|
|
5
|
+
</template>
|
|
6
|
+
</el-form-item>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: 'MFormItem'
|
|
12
|
+
})
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<style lang="scss">
|
|
16
|
+
// FormItem 组件样式 - 使用 m-form-item 类名隔离样式
|
|
17
|
+
.m-form-item {
|
|
18
|
+
// 自定义样式可以在这里添加
|
|
19
|
+
}
|
|
20
20
|
</style>
|
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<i
|
|
3
|
-
:class="iconClass"
|
|
4
|
-
:style="iconStyle"
|
|
5
|
-
v-bind="$attrs"
|
|
6
|
-
@click="handleClick"
|
|
7
|
-
>
|
|
8
|
-
<slot></slot>
|
|
9
|
-
</i>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup>
|
|
13
|
-
import { computed } from 'vue'
|
|
14
|
-
|
|
15
|
-
// 定义组件名
|
|
16
|
-
defineOptions({
|
|
17
|
-
name: 'MIcon'
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
name: {
|
|
22
|
-
type: String,
|
|
23
|
-
required: true
|
|
24
|
-
},
|
|
25
|
-
size: {
|
|
26
|
-
type: [String, Number],
|
|
27
|
-
default: '16px'
|
|
28
|
-
},
|
|
29
|
-
color: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'inherit'
|
|
32
|
-
},
|
|
33
|
-
spin: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: false
|
|
36
|
-
},
|
|
37
|
-
pulse: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false
|
|
40
|
-
},
|
|
41
|
-
rotate: {
|
|
42
|
-
type: Number,
|
|
43
|
-
default: 0
|
|
44
|
-
},
|
|
45
|
-
flip: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: undefined
|
|
48
|
-
},
|
|
49
|
-
prefix: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: 'icon'
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const emit = defineEmits(['click'])
|
|
56
|
-
|
|
57
|
-
// 计算图标类名
|
|
58
|
-
const iconClass = computed(() => {
|
|
59
|
-
const classes = ['iconfont']
|
|
60
|
-
|
|
61
|
-
// 添加图标名称类
|
|
62
|
-
if (props.name) {
|
|
63
|
-
classes.push(`${props.prefix}-${props.name}`)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 添加动画类
|
|
67
|
-
if (props.spin) {
|
|
68
|
-
classes.push('icon-spin')
|
|
69
|
-
}
|
|
70
|
-
if (props.pulse) {
|
|
71
|
-
classes.push('icon-pulse')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// 添加翻转类
|
|
75
|
-
if (props.flip) {
|
|
76
|
-
classes.push(`icon-flip-${props.flip}`)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return classes
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
// 计算图标样式
|
|
83
|
-
const iconStyle = computed(() => {
|
|
84
|
-
const style = {}
|
|
85
|
-
|
|
86
|
-
// 设置大小
|
|
87
|
-
if (props.size) {
|
|
88
|
-
if (typeof props.size === 'number') {
|
|
89
|
-
style.fontSize = `${props.size}px`
|
|
90
|
-
} else {
|
|
91
|
-
style.fontSize = props.size
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 设置颜色
|
|
96
|
-
if (props.color) {
|
|
97
|
-
style.color = props.color
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// 设置旋转
|
|
101
|
-
if (props.rotate !== 0) {
|
|
102
|
-
style.transform = `rotate(${props.rotate}deg)`
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return style
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
// 点击事件处理
|
|
109
|
-
const handleClick = (event) => {
|
|
110
|
-
emit('click', event)
|
|
111
|
-
}
|
|
112
|
-
</script>
|
|
113
|
-
|
|
114
|
-
<style scoped lang="scss">
|
|
115
|
-
.iconfont {
|
|
116
|
-
display: inline-block;
|
|
117
|
-
font-style: normal;
|
|
118
|
-
vertical-align: baseline;
|
|
119
|
-
text-align: center;
|
|
120
|
-
text-transform: none;
|
|
121
|
-
line-height: 1;
|
|
122
|
-
text-rendering: optimizeLegibility;
|
|
123
|
-
-webkit-font-smoothing: antialiased;
|
|
124
|
-
-moz-osx-font-smoothing: grayscale;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/* 旋转动画 */
|
|
128
|
-
.icon-spin {
|
|
129
|
-
animation: icon-spin 1s linear infinite;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@keyframes icon-spin {
|
|
133
|
-
from {
|
|
134
|
-
transform: rotate(0deg);
|
|
135
|
-
}
|
|
136
|
-
to {
|
|
137
|
-
transform: rotate(360deg);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/* 脉冲动画 */
|
|
142
|
-
.icon-pulse {
|
|
143
|
-
animation: icon-pulse 1s ease-in-out infinite;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@keyframes icon-pulse {
|
|
147
|
-
0% {
|
|
148
|
-
transform: scale(1);
|
|
149
|
-
}
|
|
150
|
-
50% {
|
|
151
|
-
transform: scale(1.1);
|
|
152
|
-
}
|
|
153
|
-
100% {
|
|
154
|
-
transform: scale(1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* 翻转效果 */
|
|
159
|
-
.icon-flip-horizontal {
|
|
160
|
-
transform: scaleX(-1);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.icon-flip-vertical {
|
|
164
|
-
transform: scaleY(-1);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.icon-flip-both {
|
|
168
|
-
transform: scale(-1);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/* 当有旋转时,需要与翻转效果结合 */
|
|
172
|
-
.icon-spin.icon-flip-horizontal {
|
|
173
|
-
animation: icon-spin-flip-horizontal 1s linear infinite;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.icon-spin.icon-flip-vertical {
|
|
177
|
-
animation: icon-spin-flip-vertical 1s linear infinite;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.icon-spin.icon-flip-both {
|
|
181
|
-
animation: icon-spin-flip-both 1s linear infinite;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
@keyframes icon-spin-flip-horizontal {
|
|
185
|
-
from {
|
|
186
|
-
transform: rotate(0deg) scaleX(-1);
|
|
187
|
-
}
|
|
188
|
-
to {
|
|
189
|
-
transform: rotate(360deg) scaleX(-1);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@keyframes icon-spin-flip-vertical {
|
|
194
|
-
from {
|
|
195
|
-
transform: rotate(0deg) scaleY(-1);
|
|
196
|
-
}
|
|
197
|
-
to {
|
|
198
|
-
transform: rotate(360deg) scaleY(-1);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
@keyframes icon-spin-flip-both {
|
|
203
|
-
from {
|
|
204
|
-
transform: rotate(0deg) scale(-1);
|
|
205
|
-
}
|
|
206
|
-
to {
|
|
207
|
-
transform: rotate(360deg) scale(-1);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<i
|
|
3
|
+
:class="iconClass"
|
|
4
|
+
:style="iconStyle"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
@click="handleClick"
|
|
7
|
+
>
|
|
8
|
+
<slot></slot>
|
|
9
|
+
</i>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { computed } from 'vue'
|
|
14
|
+
|
|
15
|
+
// 定义组件名
|
|
16
|
+
defineOptions({
|
|
17
|
+
name: 'MIcon'
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
name: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
type: [String, Number],
|
|
27
|
+
default: '16px'
|
|
28
|
+
},
|
|
29
|
+
color: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'inherit'
|
|
32
|
+
},
|
|
33
|
+
spin: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
pulse: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
rotate: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 0
|
|
44
|
+
},
|
|
45
|
+
flip: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: undefined
|
|
48
|
+
},
|
|
49
|
+
prefix: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: 'icon'
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const emit = defineEmits(['click'])
|
|
56
|
+
|
|
57
|
+
// 计算图标类名
|
|
58
|
+
const iconClass = computed(() => {
|
|
59
|
+
const classes = ['iconfont']
|
|
60
|
+
|
|
61
|
+
// 添加图标名称类
|
|
62
|
+
if (props.name) {
|
|
63
|
+
classes.push(`${props.prefix}-${props.name}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 添加动画类
|
|
67
|
+
if (props.spin) {
|
|
68
|
+
classes.push('icon-spin')
|
|
69
|
+
}
|
|
70
|
+
if (props.pulse) {
|
|
71
|
+
classes.push('icon-pulse')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 添加翻转类
|
|
75
|
+
if (props.flip) {
|
|
76
|
+
classes.push(`icon-flip-${props.flip}`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return classes
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// 计算图标样式
|
|
83
|
+
const iconStyle = computed(() => {
|
|
84
|
+
const style = {}
|
|
85
|
+
|
|
86
|
+
// 设置大小
|
|
87
|
+
if (props.size) {
|
|
88
|
+
if (typeof props.size === 'number') {
|
|
89
|
+
style.fontSize = `${props.size}px`
|
|
90
|
+
} else {
|
|
91
|
+
style.fontSize = props.size
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 设置颜色
|
|
96
|
+
if (props.color) {
|
|
97
|
+
style.color = props.color
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 设置旋转
|
|
101
|
+
if (props.rotate !== 0) {
|
|
102
|
+
style.transform = `rotate(${props.rotate}deg)`
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return style
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
// 点击事件处理
|
|
109
|
+
const handleClick = (event) => {
|
|
110
|
+
emit('click', event)
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style scoped lang="scss">
|
|
115
|
+
.iconfont {
|
|
116
|
+
display: inline-block;
|
|
117
|
+
font-style: normal;
|
|
118
|
+
vertical-align: baseline;
|
|
119
|
+
text-align: center;
|
|
120
|
+
text-transform: none;
|
|
121
|
+
line-height: 1;
|
|
122
|
+
text-rendering: optimizeLegibility;
|
|
123
|
+
-webkit-font-smoothing: antialiased;
|
|
124
|
+
-moz-osx-font-smoothing: grayscale;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* 旋转动画 */
|
|
128
|
+
.icon-spin {
|
|
129
|
+
animation: icon-spin 1s linear infinite;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@keyframes icon-spin {
|
|
133
|
+
from {
|
|
134
|
+
transform: rotate(0deg);
|
|
135
|
+
}
|
|
136
|
+
to {
|
|
137
|
+
transform: rotate(360deg);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* 脉冲动画 */
|
|
142
|
+
.icon-pulse {
|
|
143
|
+
animation: icon-pulse 1s ease-in-out infinite;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes icon-pulse {
|
|
147
|
+
0% {
|
|
148
|
+
transform: scale(1);
|
|
149
|
+
}
|
|
150
|
+
50% {
|
|
151
|
+
transform: scale(1.1);
|
|
152
|
+
}
|
|
153
|
+
100% {
|
|
154
|
+
transform: scale(1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 翻转效果 */
|
|
159
|
+
.icon-flip-horizontal {
|
|
160
|
+
transform: scaleX(-1);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.icon-flip-vertical {
|
|
164
|
+
transform: scaleY(-1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.icon-flip-both {
|
|
168
|
+
transform: scale(-1);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* 当有旋转时,需要与翻转效果结合 */
|
|
172
|
+
.icon-spin.icon-flip-horizontal {
|
|
173
|
+
animation: icon-spin-flip-horizontal 1s linear infinite;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.icon-spin.icon-flip-vertical {
|
|
177
|
+
animation: icon-spin-flip-vertical 1s linear infinite;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.icon-spin.icon-flip-both {
|
|
181
|
+
animation: icon-spin-flip-both 1s linear infinite;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@keyframes icon-spin-flip-horizontal {
|
|
185
|
+
from {
|
|
186
|
+
transform: rotate(0deg) scaleX(-1);
|
|
187
|
+
}
|
|
188
|
+
to {
|
|
189
|
+
transform: rotate(360deg) scaleX(-1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@keyframes icon-spin-flip-vertical {
|
|
194
|
+
from {
|
|
195
|
+
transform: rotate(0deg) scaleY(-1);
|
|
196
|
+
}
|
|
197
|
+
to {
|
|
198
|
+
transform: rotate(360deg) scaleY(-1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@keyframes icon-spin-flip-both {
|
|
203
|
+
from {
|
|
204
|
+
transform: rotate(0deg) scale(-1);
|
|
205
|
+
}
|
|
206
|
+
to {
|
|
207
|
+
transform: rotate(360deg) scale(-1);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
</style>
|