@yh-ui/icons 1.0.7 → 1.0.9
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/LICENSE +1 -1
- package/README.md +32 -230
- package/dist/components.mjs +928 -0
- package/dist/index.mjs +319 -22
- package/dist/src/components.d.ts +25768 -0
- package/dist/src/components.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +8 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,265 +1,67 @@
|
|
|
1
1
|
# @yh-ui/icons
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
YH-UI 的 Iconify 图标集成包。它提供 Vue 图标组件、图标名称解析、预设别名和图标集合配置,既可以直接运行时渲染 Iconify 图标,也可以配合 `unplugin-icons` 做编译时按需加载。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Iconify](https://icon-sets.iconify.design/) | [Documentation](https://1079161148.github.io/yh-ui/icons/)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 📦 **体积小** - Tree-shaking 极致化,只有用到的图标才会被打包
|
|
9
|
-
- 🎨 **100+ 图标集** - 整合 Iconify 生态,20 万+ 图标
|
|
10
|
-
- 🔧 **完全兼容** - 保持与现有 YhIcon 组件 API 兼容
|
|
11
|
-
- 🌳 **SSR 支持** - 支持服务端渲染
|
|
7
|
+
## Highlights
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
- Iconify 生态:可使用 `mdi:home`、`ep:search`、`lucide:check` 等 Iconify 命名。
|
|
10
|
+
- Vue 组件:从 `@yh-ui/icons/vue` 导入 `Icon` 或 `YhIcon`,传入 `icon` / `name` 即可渲染。
|
|
11
|
+
- 预设别名:常用操作、状态、方向和文件图标提供简短名称,适合业务界面快速落地。
|
|
12
|
+
- 类型和工具:导出图标类型、集合信息、`parseIconName`、`iconExists`、`getIconData` 等工具。
|
|
13
|
+
- 轻量集成:包本身依赖 `@iconify/vue`,需要极致体积时可再接入 `unplugin-icons`。
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
pnpm add @yh-ui/icons @iconify/vue
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## 快速开始
|
|
20
|
-
|
|
21
|
-
### 方式一:使用 Vite 插件按需加载(推荐)
|
|
22
|
-
|
|
23
|
-
安装依赖:
|
|
15
|
+
## Install
|
|
24
16
|
|
|
25
17
|
```bash
|
|
26
|
-
pnpm add -
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
配置 `vite.config.ts`:
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
import { defineConfig } from 'vite'
|
|
33
|
-
import vue from '@vitejs/plugin-vue'
|
|
34
|
-
import Icons from 'unplugin-icons/vite'
|
|
35
|
-
import { collections } from '@iconify/json'
|
|
36
|
-
|
|
37
|
-
export default defineConfig({
|
|
38
|
-
plugins: [
|
|
39
|
-
vue(),
|
|
40
|
-
Icons({
|
|
41
|
-
compiler: 'vue3',
|
|
42
|
-
// 自动安装图标集
|
|
43
|
-
autoInstall: true,
|
|
44
|
-
// 启用这些图标集
|
|
45
|
-
collections: {
|
|
46
|
-
mdi: collections.mdi,
|
|
47
|
-
ep: collections.ep,
|
|
48
|
-
lucide: collections.lucide,
|
|
49
|
-
tabler: collections.tabler,
|
|
50
|
-
ri: collections.ri,
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
})
|
|
18
|
+
pnpm add @yh-ui/icons @iconify/vue
|
|
55
19
|
```
|
|
56
20
|
|
|
57
|
-
|
|
21
|
+
## Runtime Usage
|
|
58
22
|
|
|
59
23
|
```vue
|
|
60
|
-
<script setup>
|
|
24
|
+
<script setup lang="ts">
|
|
61
25
|
import { Icon } from '@yh-ui/icons/vue'
|
|
62
26
|
</script>
|
|
63
27
|
|
|
64
28
|
<template>
|
|
65
|
-
|
|
66
|
-
<Icon icon="
|
|
67
|
-
|
|
68
|
-
<!-- 使用自定义尺寸和颜色 -->
|
|
69
|
-
<Icon icon="mdi:home" :size="24" color="#ff0000" />
|
|
70
|
-
|
|
71
|
-
<!-- 旋转动画 -->
|
|
72
|
-
<Icon icon="mdi:loading" spin />
|
|
73
|
-
</template>
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## 使用方法
|
|
77
|
-
|
|
78
|
-
### 图标名称格式
|
|
79
|
-
|
|
80
|
-
支持多种图标名称格式:
|
|
81
|
-
|
|
82
|
-
```vue
|
|
83
|
-
<!-- 1. 前缀:图标名(推荐) -->
|
|
84
|
-
<Icon icon="mdi:home" />
|
|
85
|
-
<Icon icon="ep:search" />
|
|
86
|
-
<Icon icon="lucide:check" />
|
|
87
|
-
|
|
88
|
-
<!-- 2. 斜杠分隔(兼容 Iconify) -->
|
|
89
|
-
<Icon icon="mdi/home" />
|
|
90
|
-
<Icon icon="ep/search" />
|
|
91
|
-
|
|
92
|
-
<!-- 3. 简写名称(需配置默认图标集) -->
|
|
93
|
-
<Icon icon="home" /> <!-- 等同于 mdi:home -->
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### 常用图标集
|
|
97
|
-
|
|
98
|
-
| 图标集 | 前缀 | 图标数量 | 说明 |
|
|
99
|
-
|--------|------|----------|------|
|
|
100
|
-
| Material Design Icons | `mdi` | 7000+ | 最流行的开源图标库 |
|
|
101
|
-
| Element Plus | `ep` | 200+ | Element Plus 官方图标 |
|
|
102
|
-
| Lucide | `lucide` | 1500+ | 现代简洁风格 |
|
|
103
|
-
| Tabler Icons | `tabler` | 4600+ | 高质量 SVG 图标 |
|
|
104
|
-
| Remix Icon | `ri` | 2500+ | 精心设计的图标库 |
|
|
105
|
-
| Heroicons | `heroicons` | 600+ | Tailwind CSS 官方图标 |
|
|
106
|
-
| Bootstrap Icons | `bi` | 2600+ | Bootstrap 官方图标 |
|
|
107
|
-
| Font Awesome 6 | `fa` | 2000+ | 最流行的图标字体 |
|
|
108
|
-
|
|
109
|
-
### Props
|
|
110
|
-
|
|
111
|
-
| 属性 | 类型 | 默认值 | 说明 |
|
|
112
|
-
|------|------|--------|------|
|
|
113
|
-
| `icon` | `string` | `''` | 图标名称 |
|
|
114
|
-
| `size` | `number \| string` | `undefined` | 图标尺寸 |
|
|
115
|
-
| `color` | `string` | `undefined` | 图标颜色 |
|
|
116
|
-
| `spin` | `boolean` | `false` | 是否旋转动画 |
|
|
117
|
-
| `rotate` | `number` | `0` | 旋转角度(0, 90, 180, 270) |
|
|
118
|
-
|
|
119
|
-
### 与现有 YhIcon 组件兼容
|
|
120
|
-
|
|
121
|
-
现有的 `YhIcon` 组件完全兼容,无需修改:
|
|
122
|
-
|
|
123
|
-
```vue
|
|
124
|
-
<script setup>
|
|
125
|
-
import { YhIcon } from '@yh-ui/icons/vue'
|
|
126
|
-
// 或从 @yh-ui/components
|
|
127
|
-
import { YhIcon } from '@yh-ui/components'
|
|
128
|
-
</script>
|
|
129
|
-
|
|
130
|
-
<template>
|
|
131
|
-
<!-- 两种方式都可以使用 -->
|
|
132
|
-
<YhIcon name="mdi:home" />
|
|
133
|
-
<YhIcon icon="ep:search" :size="20" color="#409EFF" />
|
|
134
|
-
</template>
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### 常用图标快捷方式
|
|
138
|
-
|
|
139
|
-
内置常用图标别名:
|
|
140
|
-
|
|
141
|
-
```vue
|
|
142
|
-
<template>
|
|
143
|
-
<!-- 箭头 -->
|
|
144
|
-
<Icon icon="arrow-up" />
|
|
145
|
-
<Icon icon="arrow-down" />
|
|
146
|
-
<Icon icon="arrow-left" />
|
|
147
|
-
<Icon icon="arrow-right" />
|
|
148
|
-
|
|
149
|
-
<!-- 操作 -->
|
|
150
|
-
<Icon icon="close" />
|
|
151
|
-
<Icon icon="check" />
|
|
152
|
-
<Icon icon="plus" />
|
|
153
|
-
<Icon icon="minus" />
|
|
154
|
-
<Icon icon="delete" />
|
|
155
|
-
<Icon icon="edit" />
|
|
156
|
-
<Icon icon="search" />
|
|
157
|
-
<Icon icon="upload" />
|
|
158
|
-
<Icon icon="download" />
|
|
159
|
-
<Icon icon="refresh" />
|
|
160
|
-
<Icon icon="settings" />
|
|
161
|
-
<Icon icon="menu" />
|
|
162
|
-
|
|
163
|
-
<!-- 状态 -->
|
|
164
|
-
<Icon icon="loading" />
|
|
165
|
-
<Icon icon="success" />
|
|
166
|
-
<Icon icon="warning" />
|
|
167
|
-
<Icon icon="error" />
|
|
168
|
-
<Icon icon="info" />
|
|
169
|
-
|
|
170
|
-
<!-- 用户 -->
|
|
171
|
-
<Icon icon="user" />
|
|
172
|
-
<Icon icon="users" />
|
|
173
|
-
|
|
174
|
-
<!-- 文件 -->
|
|
175
|
-
<Icon icon="file" />
|
|
176
|
-
<Icon icon="folder" />
|
|
177
|
-
<Icon icon="image" />
|
|
29
|
+
<Icon icon="mdi:home" :size="24" />
|
|
30
|
+
<Icon icon="lucide:search" color="#409eff" />
|
|
31
|
+
<Icon icon="loading" spin />
|
|
178
32
|
</template>
|
|
179
33
|
```
|
|
180
34
|
|
|
181
|
-
##
|
|
182
|
-
|
|
183
|
-
完整的 TypeScript 类型支持:
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
import type { IconName, IconSize, IconColor } from '@yh-ui/icons'
|
|
187
|
-
import { AVAILABLE_COLLECTIONS, RECOMMENDED_COLLECTIONS } from '@yh-ui/icons'
|
|
35
|
+
## With unplugin-icons
|
|
188
36
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// 获取推荐的图标集
|
|
193
|
-
console.log(RECOMMENDED_COLLECTIONS)
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add -D unplugin-icons @iconify/json
|
|
194
39
|
```
|
|
195
40
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
### 启用/禁用图标集
|
|
199
|
-
|
|
200
|
-
在 vite.config.ts 中配置:
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
41
|
+
```ts
|
|
203
42
|
import Icons from 'unplugin-icons/vite'
|
|
204
|
-
import { collections } from '@iconify/json'
|
|
205
43
|
|
|
206
|
-
export default
|
|
44
|
+
export default {
|
|
207
45
|
plugins: [
|
|
208
46
|
Icons({
|
|
209
47
|
compiler: 'vue3',
|
|
210
|
-
autoInstall: true
|
|
211
|
-
collections: {
|
|
212
|
-
// 只启用需要的图标集,减少打包体积
|
|
213
|
-
mdi: collections.mdi, // Material Design Icons
|
|
214
|
-
ep: collections.ep, // Element Plus
|
|
215
|
-
lucide: collections.lucide, // Lucide
|
|
216
|
-
}
|
|
48
|
+
autoInstall: true
|
|
217
49
|
})
|
|
218
50
|
]
|
|
219
|
-
}
|
|
51
|
+
}
|
|
220
52
|
```
|
|
221
53
|
|
|
222
|
-
|
|
54
|
+
## Useful Exports
|
|
223
55
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
## 常见问题
|
|
233
|
-
|
|
234
|
-
### 1. 图标不显示?
|
|
235
|
-
|
|
236
|
-
确保:
|
|
237
|
-
1. 图标集已在 vite.config.ts 中启用
|
|
238
|
-
2. 图标名称格式正确(如 `mdi:home`)
|
|
239
|
-
3. 已安装 `@iconify/vue` 依赖
|
|
240
|
-
|
|
241
|
-
### 2. 如何查找图标?
|
|
242
|
-
|
|
243
|
-
访问 [Iconify 图标库](https://icon-sets.iconify.design/) 搜索图标。
|
|
244
|
-
|
|
245
|
-
### 3. 如何使用自定义图标?
|
|
246
|
-
|
|
247
|
-
在 vite.config.ts 中添加自定义图标集:
|
|
248
|
-
|
|
249
|
-
```typescript
|
|
250
|
-
import Icons from 'unplugin-icons/vite'
|
|
251
|
-
import customIcons from './custom-icons.json'
|
|
252
|
-
|
|
253
|
-
export default defineConfig({
|
|
254
|
-
plugins: [
|
|
255
|
-
Icons({
|
|
256
|
-
compiler: 'vue3',
|
|
257
|
-
collections: {
|
|
258
|
-
'custom': customIcons
|
|
259
|
-
}
|
|
260
|
-
})
|
|
261
|
-
]
|
|
262
|
-
})
|
|
56
|
+
```ts
|
|
57
|
+
import {
|
|
58
|
+
AVAILABLE_COLLECTIONS,
|
|
59
|
+
RECOMMENDED_COLLECTIONS,
|
|
60
|
+
iconExists,
|
|
61
|
+
parseIconName
|
|
62
|
+
} from '@yh-ui/icons'
|
|
263
63
|
```
|
|
264
64
|
|
|
265
65
|
## License
|
|
66
|
+
|
|
67
|
+
MIT
|