@travel-screen/l-module-components 1.0.0
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 +86 -0
- package/package.json +34 -0
- package/src/index.js +60 -0
- package/src/l-bar-chart/README.md +302 -0
- package/src/l-bar-chart/index.vue +405 -0
- package/src/l-bar-chart/interface/index.js +210 -0
- package/src/l-data-panel/README.md +331 -0
- package/src/l-data-panel/img/images.js +47 -0
- package/src/l-data-panel/img/l-data-panel_bg_1.png +0 -0
- package/src/l-data-panel/img/l-data-panel_bg_2.png +0 -0
- package/src/l-data-panel/img/l-data-panel_bg_3.png +0 -0
- package/src/l-data-panel/index.vue +150 -0
- package/src/l-data-panel/interface/index.js +249 -0
- package/src/l-data-ring/README.md +292 -0
- package/src/l-data-ring/img/images.js +21 -0
- package/src/l-data-ring/img/l-data-ring_bg.png +0 -0
- package/src/l-data-ring/index.vue +93 -0
- package/src/l-data-ring/interface/index.js +116 -0
- package/src/l-date-picker/README.md +276 -0
- package/src/l-date-picker/index.vue +185 -0
- package/src/l-date-picker/interface/index.js +128 -0
- package/src/l-icon-label/README.md +356 -0
- package/src/l-icon-label/img/images.js +28 -0
- package/src/l-icon-label/img/l-icon-label_bg.png +0 -0
- package/src/l-icon-label/img/l-icon-label_icon.png +0 -0
- package/src/l-icon-label/index.vue +162 -0
- package/src/l-icon-label/interface/index.js +234 -0
- package/src/l-label-value/README.md +358 -0
- package/src/l-label-value/img/images.js +19 -0
- package/src/l-label-value/img/l-label-value_line.png +0 -0
- package/src/l-label-value/index.vue +132 -0
- package/src/l-label-value/interface/index.js +116 -0
- package/src/l-metric-tile/README.md +391 -0
- package/src/l-metric-tile/img/images.js +19 -0
- package/src/l-metric-tile/img/l-metric-tile_bg_1.png +0 -0
- package/src/l-metric-tile/index.vue +138 -0
- package/src/l-metric-tile/interface/index.js +241 -0
- package/src/l-module-box/README.md +289 -0
- package/src/l-module-box/img/images.js +28 -0
- package/src/l-module-box/img/l-module-box_bg.png +0 -0
- package/src/l-module-box/img/l-module-box_icon.png +0 -0
- package/src/l-module-box/index.vue +125 -0
- package/src/l-module-box/interface/index.js +93 -0
- package/src/l-module-tag/README.md +243 -0
- package/src/l-module-tag/index.vue +137 -0
- package/src/l-module-tag/interface/index.js +91 -0
- package/src/l-rank-list/README.md +553 -0
- package/src/l-rank-list/img/images.js +34 -0
- package/src/l-rank-list/img/l-rank-list_icon_line.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_1.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_2.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_other.png +0 -0
- package/src/l-rank-list/index.vue +610 -0
- package/src/l-rank-list/interface/index.js +343 -0
- package/src/l-stat-card/README.md +309 -0
- package/src/l-stat-card/img/images.js +36 -0
- package/src/l-stat-card/img/img-bg.png +0 -0
- package/src/l-stat-card/img/l-stat-card_img_1.png +0 -0
- package/src/l-stat-card/index.vue +136 -0
- package/src/l-stat-card/interface/index.js +159 -0
- package/src/l-tabs/README.md +285 -0
- package/src/l-tabs/img/images.js +19 -0
- package/src/l-tabs/img/l-tabs_bg.png +0 -0
- package/src/l-tabs/index.vue +97 -0
- package/src/l-tabs/interface/index.js +115 -0
- package/src/l-trend-card/README.md +415 -0
- package/src/l-trend-card/img/images.js +41 -0
- package/src/l-trend-card/img/l-trend-card_bg.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_1.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_down.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_up.png +0 -0
- package/src/l-trend-card/index.vue +181 -0
- package/src/l-trend-card/interface/index.js +243 -0
- package/src/utils/tooltip.js +30 -0
- package/src/utils/util.js +27 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
---
|
|
2
|
+
AIGC:
|
|
3
|
+
ContentProducer: '001191110102MAD55U9H0F10002'
|
|
4
|
+
ContentPropagator: '001191110102MAD55U9H0F10002'
|
|
5
|
+
Label: '1'
|
|
6
|
+
ProduceID: '53e2959e-837d-40d7-95d7-41823961efef'
|
|
7
|
+
PropagateID: '53e2959e-837d-40d7-95d7-41823961efef'
|
|
8
|
+
ReservedCode1: 'e5c50599-74e3-4476-8032-ba40ea2f6708'
|
|
9
|
+
ReservedCode2: 'e5c50599-74e3-4476-8032-ba40ea2f6708'
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# LIconLabel 组件说明
|
|
13
|
+
|
|
14
|
+
## 概述
|
|
15
|
+
|
|
16
|
+
`LIconLabel` 是一个参数化驱动的图标标签卡片组件,采用类似 Element UI 的封装方式。用于展示带图标、标题、数值和单位的卡片(如今日累计客流、住宿监测等)。所有样式(背景图、图标、文字大小/颜色等)均通过 props 参数动态控制。
|
|
17
|
+
|
|
18
|
+
## 核心特性
|
|
19
|
+
|
|
20
|
+
- ✅ **Props 驱动**:所有样式通过 props 参数控制,类似 Element UI
|
|
21
|
+
- ✅ **默认背景图和图标**:未传入时自动使用组件内置默认背景图和图标
|
|
22
|
+
- ✅ **高度灵活**:支持自定义背景图、图标、尺寸、颜色、字体等所有样式
|
|
23
|
+
- ✅ **类型安全**:支持 String 和 Number 类型的尺寸参数
|
|
24
|
+
- ✅ **渐变数值**:支持数值文字渐变效果
|
|
25
|
+
|
|
26
|
+
## 文件结构
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
l-icon-label/
|
|
30
|
+
├── img/
|
|
31
|
+
│ ├── images.js # 图片映射文件
|
|
32
|
+
│ ├── l-icon-label_bg.png # 默认背景图
|
|
33
|
+
│ └── l-icon-label_icon.png # 默认图标
|
|
34
|
+
├── interface/
|
|
35
|
+
│ └── index.js # Props 定义(30+ 个参数)
|
|
36
|
+
├── index.vue # 主组件(内联样式驱动)
|
|
37
|
+
└── README.md # 组件说明文档
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Props 参数
|
|
41
|
+
|
|
42
|
+
### 基础数据
|
|
43
|
+
|
|
44
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
45
|
+
|--------|------|--------|------|
|
|
46
|
+
| `title` | String | `'标题'` | 显示的标题文字 |
|
|
47
|
+
| `data` | String/Number | `0` | 显示的数值 |
|
|
48
|
+
| `unit` | String | `''` | 数值单位 |
|
|
49
|
+
|
|
50
|
+
### 背景图相关
|
|
51
|
+
|
|
52
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
53
|
+
|--------|------|--------|------|
|
|
54
|
+
| `bgImage` | String | `''` | 背景图图片URL(留空则使用默认背景图) |
|
|
55
|
+
| `bgSize` | String | `'100% 100%'` | 背景图尺寸(缩放方式) |
|
|
56
|
+
|
|
57
|
+
### 图标相关
|
|
58
|
+
|
|
59
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
60
|
+
|--------|------|--------|------|
|
|
61
|
+
| `icon` | String | `''` | 图标图片URL(留空则使用默认图标) |
|
|
62
|
+
| `iconWidth` | String/Number | `'40px'` | 图标宽度 |
|
|
63
|
+
| `iconHeight` | String/Number | `'40px'` | 图标高度 |
|
|
64
|
+
| `iconMarginRight` | String/Number | `'12px'` | 图标右侧边距 |
|
|
65
|
+
| `iconFlexShrink` | String/Number | `0` | 图标flex收缩(0为不允许) |
|
|
66
|
+
|
|
67
|
+
### 卡片容器相关
|
|
68
|
+
|
|
69
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
70
|
+
|--------|------|--------|------|
|
|
71
|
+
| `cardWidth` | String/Number | `'230px'` | 卡片宽度 |
|
|
72
|
+
| `cardHeight` | String/Number | `'66px'` | 卡片高度 |
|
|
73
|
+
| `cardPadding` | String | `'0 14px'` | 卡片内边距 |
|
|
74
|
+
| `cardBoxSizing` | String | `'border-box'` | 卡片盒模型 |
|
|
75
|
+
| `cardAlignItems` | String | `'center'` | 卡片对齐方式 |
|
|
76
|
+
|
|
77
|
+
### 信息容器相关
|
|
78
|
+
|
|
79
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
80
|
+
|--------|------|--------|------|
|
|
81
|
+
| `infoFlex` | String/Number | `1` | 信息容器flex值 |
|
|
82
|
+
| `infoDisplay` | String | `'flex'` | 信息容器显示方式 |
|
|
83
|
+
| `infoFlexDirection` | String | `'column'` | 信息容器主轴方向 |
|
|
84
|
+
| `infoJustifyContent` | String | `'center'` | 信息容器交叉轴对齐 |
|
|
85
|
+
|
|
86
|
+
### 标题相关
|
|
87
|
+
|
|
88
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
89
|
+
|--------|------|--------|------|
|
|
90
|
+
| `titleFontFamily` | String | `'PingFangSC, PingFang SC'` | 标题字体 |
|
|
91
|
+
| `titleFontWeight` | String/Number | `500` | 标题字重 |
|
|
92
|
+
| `titleFontSize` | String/Number | `'18px'` | 标题字号 |
|
|
93
|
+
| `titleColor` | String | `'#ffffff'` | 标题颜色 |
|
|
94
|
+
| `titleLineHeight` | String/Number | `1` | 标题行高 |
|
|
95
|
+
| `titleMarginBottom` | String/Number | `'2px'` | 标题底部边距 |
|
|
96
|
+
|
|
97
|
+
### 数值相关
|
|
98
|
+
|
|
99
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
100
|
+
|--------|------|--------|------|
|
|
101
|
+
| `numDisplay` | String | `'flex'` | 数值显示方式 |
|
|
102
|
+
| `numAlignItems` | String | `'baseline'` | 数值对齐方式 |
|
|
103
|
+
| `numFontFamily` | String | `'DINAlternate, DIN Alternate, YouSheBiaoTiHei, sans-serif'` | 数值字体 |
|
|
104
|
+
| `numFontWeight` | String/Number | `'bold'` | 数值字重 |
|
|
105
|
+
| `numFontStyle` | String | `'italic'` | 数值字体样式 |
|
|
106
|
+
| `numFontSize` | String/Number | `'26px'` | 数值字号 |
|
|
107
|
+
| `numLineHeight` | String/Number | `1` | 数值行高 |
|
|
108
|
+
| `numMarginRight` | String/Number | `'4px'` | 数值右侧边距 |
|
|
109
|
+
| `numPaddingRight` | String/Number | `'2px'` | 数值右侧内边距 |
|
|
110
|
+
| `numColor` | String | `'transparent'` | 数值颜色(使用渐变色时设为transparent) |
|
|
111
|
+
| `numBackground` | String | `'linear-gradient(180deg, #ffffff 0%, #4aefa0 100%)'` | 数值背景渐变色 |
|
|
112
|
+
| `numBackgroundClip` | String | `'text'` | 数值背景裁剪 |
|
|
113
|
+
| `numTextShadow` | String | `'0px 2px 4px rgba(74, 239, 160, 0.5)'` | 数值文字阴影 |
|
|
114
|
+
|
|
115
|
+
### 单位相关
|
|
116
|
+
|
|
117
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
118
|
+
|--------|------|--------|------|
|
|
119
|
+
| `unitFontFamily` | String | `'PingFangSC, PingFang SC'` | 单位字体 |
|
|
120
|
+
| `unitFontWeight` | String/Number | `400` | 单位字重 |
|
|
121
|
+
| `unitFontSize` | String/Number | `'12px'` | 单位字号 |
|
|
122
|
+
| `unitColor` | String | `'#ffffff'` | 单位颜色 |
|
|
123
|
+
| `unitLineHeight` | String/Number | `1` | 单位行高 |
|
|
124
|
+
|
|
125
|
+
## 使用方式
|
|
126
|
+
|
|
127
|
+
### 基本使用
|
|
128
|
+
|
|
129
|
+
```vue
|
|
130
|
+
<template>
|
|
131
|
+
<l-icon-label
|
|
132
|
+
title="全域客流"
|
|
133
|
+
:data="359647"
|
|
134
|
+
unit="人次"
|
|
135
|
+
/>
|
|
136
|
+
</template>
|
|
137
|
+
|
|
138
|
+
<script>
|
|
139
|
+
import LIconLabel from '@/components/moduleDataNew/l-icon-label/index.vue'
|
|
140
|
+
|
|
141
|
+
export default {
|
|
142
|
+
components: {
|
|
143
|
+
LIconLabel
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</script>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 自定义图标
|
|
150
|
+
|
|
151
|
+
```vue
|
|
152
|
+
<template>
|
|
153
|
+
<l-icon-label
|
|
154
|
+
title="重点景区客流"
|
|
155
|
+
:data="123456"
|
|
156
|
+
unit="人次"
|
|
157
|
+
:icon="require('@/assets/custom-icon.png')"
|
|
158
|
+
/>
|
|
159
|
+
</template>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 自定义背景图
|
|
163
|
+
|
|
164
|
+
```vue
|
|
165
|
+
<template>
|
|
166
|
+
<l-icon-label
|
|
167
|
+
title="住宿监测"
|
|
168
|
+
:data="85"
|
|
169
|
+
unit="%"
|
|
170
|
+
:bgImage="require('@/assets/custom-bg.png')"
|
|
171
|
+
/>
|
|
172
|
+
</template>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 自定义数值和标题样式
|
|
176
|
+
|
|
177
|
+
```vue
|
|
178
|
+
<template>
|
|
179
|
+
<l-icon-label
|
|
180
|
+
title="今日累计客流"
|
|
181
|
+
:data="4230737"
|
|
182
|
+
unit="人次"
|
|
183
|
+
:numFontSize="30"
|
|
184
|
+
:numBackground="'linear-gradient(180deg, #FF6B6B 0%, #4CE27E 100%)'"
|
|
185
|
+
:numTextShadow="'0px 2px 8px rgba(255, 107, 107, 0.6)'"
|
|
186
|
+
:titleFontSize="16"
|
|
187
|
+
titleColor="#E8EEF4"
|
|
188
|
+
/>
|
|
189
|
+
</template>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 完整自定义
|
|
193
|
+
|
|
194
|
+
```vue
|
|
195
|
+
<template>
|
|
196
|
+
<l-icon-label
|
|
197
|
+
title="文博场馆接待量"
|
|
198
|
+
:data="690"
|
|
199
|
+
unit="人次"
|
|
200
|
+
:cardWidth="250"
|
|
201
|
+
:cardHeight="70"
|
|
202
|
+
:cardPadding="'0 16px'"
|
|
203
|
+
:iconWidth="44"
|
|
204
|
+
:iconHeight="44"
|
|
205
|
+
:iconMarginRight="14"
|
|
206
|
+
:numFontSize="28"
|
|
207
|
+
:numBackground="'linear-gradient(180deg, #4CE27E 0%, #36D399 100%)'"
|
|
208
|
+
:numTextShadow="'0px 2px 10px rgba(76, 226, 126, 0.7)'"
|
|
209
|
+
:titleFontSize="16"
|
|
210
|
+
:titleMarginBottom="4"
|
|
211
|
+
:unitFontSize="14"
|
|
212
|
+
/>
|
|
213
|
+
</template>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 循环使用(v-for)
|
|
217
|
+
|
|
218
|
+
```vue
|
|
219
|
+
<template>
|
|
220
|
+
<div class="today-flow-list">
|
|
221
|
+
<l-icon-label
|
|
222
|
+
v-for="(item, index) in todayFlowList"
|
|
223
|
+
:key="index"
|
|
224
|
+
:title="item.title"
|
|
225
|
+
:data="item.num"
|
|
226
|
+
:unit="item.unit"
|
|
227
|
+
:icon="item.icon"
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
</template>
|
|
231
|
+
|
|
232
|
+
<script>
|
|
233
|
+
import LIconLabel from '@/components/moduleDataNew/l-icon-label/index.vue'
|
|
234
|
+
|
|
235
|
+
export default {
|
|
236
|
+
components: {
|
|
237
|
+
LIconLabel
|
|
238
|
+
},
|
|
239
|
+
data() {
|
|
240
|
+
return {
|
|
241
|
+
todayFlowList: [
|
|
242
|
+
{ title: '全域客流', num: 359647, unit: '人次', icon: require('@/assets/icon-1.png') },
|
|
243
|
+
{ title: '重点景区客流', num: 123456, unit: '人次', icon: require('@/assets/icon-2.png') },
|
|
244
|
+
{ title: '文博场馆客流', num: 690, unit: '人次', icon: require('@/assets/icon-3.png') }
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<style scoped>
|
|
252
|
+
.today-flow-list {
|
|
253
|
+
display: flex;
|
|
254
|
+
gap: 16px;
|
|
255
|
+
}
|
|
256
|
+
</style>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## 技术实现
|
|
260
|
+
|
|
261
|
+
### 内联样式生成
|
|
262
|
+
|
|
263
|
+
组件通过 computed 属性动态生成内联样式:
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
computed: {
|
|
267
|
+
numStyle() {
|
|
268
|
+
return {
|
|
269
|
+
fontFamily: this.numFontFamily,
|
|
270
|
+
fontWeight: this.numFontWeight,
|
|
271
|
+
fontStyle: this.numFontStyle,
|
|
272
|
+
fontSize: typeof this.numFontSize === 'number'
|
|
273
|
+
? `${this.numFontSize}px`
|
|
274
|
+
: this.numFontSize,
|
|
275
|
+
color: this.numColor,
|
|
276
|
+
background: this.numBackground,
|
|
277
|
+
WebkitBackgroundClip: this.numBackgroundClip,
|
|
278
|
+
backgroundClip: this.numBackgroundClip,
|
|
279
|
+
textShadow: this.numTextShadow
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 默认背景图和图标兜底
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
import { getBgPath, getIconPath } from './img/images'
|
|
289
|
+
|
|
290
|
+
computed: {
|
|
291
|
+
computedIcon() {
|
|
292
|
+
if (this.icon) {
|
|
293
|
+
return this.icon
|
|
294
|
+
}
|
|
295
|
+
// 使用默认图标
|
|
296
|
+
return getIconPath()
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
computedBgImage() {
|
|
300
|
+
if (this.bgImage) {
|
|
301
|
+
return this.bgImage
|
|
302
|
+
}
|
|
303
|
+
// 使用默认背景图
|
|
304
|
+
return getBgPath()
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 模板绑定
|
|
310
|
+
|
|
311
|
+
```vue
|
|
312
|
+
<template>
|
|
313
|
+
<div class="l-icon-label" :style="cardStyle">
|
|
314
|
+
<img class="l-icon-label__icon" :src="computedIcon" :style="iconStyle" />
|
|
315
|
+
<div class="l-icon-label__info" :style="infoStyle">
|
|
316
|
+
<div class="l-icon-label__title" :style="titleStyle">{{ title }}</div>
|
|
317
|
+
<div class="l-icon-label__num" :style="numContainerStyle">
|
|
318
|
+
<span class="l-icon-label__num-value" :style="numStyle">{{ data }}</span>
|
|
319
|
+
<span class="l-icon-label__num-unit" :style="unitStyle">{{ unit }}</span>
|
|
320
|
+
</div>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</template>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## 注意事项
|
|
327
|
+
|
|
328
|
+
1. **背景图和图标可选**:`bgImage` 和 `icon` 参数是可选的,未传入时使用默认值
|
|
329
|
+
2. **尺寸单位**:Number 类型会自动添加 `px` 单位,String 类型需自行包含单位
|
|
330
|
+
3. **默认资源**:组件内置默认背景图和图标,位于 `img/` 目录下
|
|
331
|
+
4. **性能优化**:内联样式通过 computed 缓存,避免重复计算
|
|
332
|
+
5. **BEM 命名**:使用 `l-icon-label__icon`、`l-icon-label__title`、`l-icon-label__num-value` 等 BEM 命名规范
|
|
333
|
+
6. **渐变数值**:使用渐变色时,`numColor` 应设为 `transparent`,通过 `numBackground` 设置渐变色
|
|
334
|
+
7. **flex 布局**:组件使用 flex 布局,图标和信息容器水平排列
|
|
335
|
+
|
|
336
|
+
## 适用场景
|
|
337
|
+
|
|
338
|
+
- ✅ 今日累计客流展示
|
|
339
|
+
- ✅ 住宿监测数据展示
|
|
340
|
+
- ✅ 带图标的数据卡片
|
|
341
|
+
- ✅ 需要自定义背景图和图标的场景
|
|
342
|
+
- ✅ 多项指标并排展示(通过 v-for)
|
|
343
|
+
|
|
344
|
+
## 更新日志
|
|
345
|
+
|
|
346
|
+
- **v1.0.0** (2026-06-18)
|
|
347
|
+
- 从 `moduleData_7` 重命名为 `l-icon-label`
|
|
348
|
+
- 参考 `l-stat-card` 封装结构进行参数化重构
|
|
349
|
+
- 所有样式配置项抽离为 Props 参数(替代 SCSS 变量)
|
|
350
|
+
- 添加详细的字段注释说明
|
|
351
|
+
- 添加默认背景图和默认图标支持
|
|
352
|
+
- 支持背景图、图标、数值、标题、单位等所有样式自定义
|
|
353
|
+
- 使用内联样式实现(类似 Element UI)
|
|
354
|
+
- 移除 css/*.scss 文件,全部改为动态参数控制
|
|
355
|
+
|
|
356
|
+
> AI生成
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIconLabel 组件图片资源映射
|
|
3
|
+
* 提供默认背景图和默认图标的导出函数
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// 预加载所有图片资源
|
|
7
|
+
const images = {
|
|
8
|
+
bg: require('./l-icon-label_bg.png'),
|
|
9
|
+
icon: require('./l-icon-label_icon.png')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 获取默认背景图路径
|
|
14
|
+
* @returns {string} 背景图路径
|
|
15
|
+
*/
|
|
16
|
+
export function getBgPath() {
|
|
17
|
+
return images.bg
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 获取默认图标路径
|
|
22
|
+
* @returns {string} 图标路径
|
|
23
|
+
*/
|
|
24
|
+
export function getIconPath() {
|
|
25
|
+
return images.icon
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default images
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="l-icon-label" :style="cardStyle">
|
|
3
|
+
<img class="l-icon-label__icon" :src="computedIcon" :style="iconStyle" />
|
|
4
|
+
<div class="l-icon-label__info" :style="infoStyle">
|
|
5
|
+
<div class="l-icon-label__title" :style="titleStyle">{{ title }}</div>
|
|
6
|
+
<div class="l-icon-label__num" :style="numContainerStyle">
|
|
7
|
+
<span class="l-icon-label__num-value" :style="numStyle">{{ data }}</span>
|
|
8
|
+
<span class="l-icon-label__num-unit" :style="unitStyle">{{ unit }}</span>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import interfaceObj from './interface/index'
|
|
16
|
+
import { getBgPath, getIconPath } from './img/images'
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'LIconLabel',
|
|
20
|
+
props: interfaceObj,
|
|
21
|
+
components: {},
|
|
22
|
+
data() {
|
|
23
|
+
return {}
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
// 图标图片(外部传入优先,否则使用默认)
|
|
27
|
+
computedIcon() {
|
|
28
|
+
if (this.icon) {
|
|
29
|
+
return this.icon
|
|
30
|
+
}
|
|
31
|
+
// 使用默认图标
|
|
32
|
+
return getIconPath()
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// 背景图(外部传入优先,否则使用默认)
|
|
36
|
+
computedBgImage() {
|
|
37
|
+
if (this.bgImage) {
|
|
38
|
+
return this.bgImage
|
|
39
|
+
}
|
|
40
|
+
// 使用默认背景图
|
|
41
|
+
return getBgPath()
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// 卡片容器样式
|
|
45
|
+
cardStyle() {
|
|
46
|
+
return {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: this.cardAlignItems,
|
|
49
|
+
width: typeof this.cardWidth === 'number' ? `${this.cardWidth}px` : this.cardWidth,
|
|
50
|
+
height: typeof this.cardHeight === 'number' ? `${this.cardHeight}px` : this.cardHeight,
|
|
51
|
+
background: this.computedBgImage ? `url(${this.computedBgImage}) 0 0 no-repeat` : '',
|
|
52
|
+
backgroundSize: this.bgSize,
|
|
53
|
+
padding: this.cardPadding,
|
|
54
|
+
boxSizing: this.cardBoxSizing
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// 图标样式
|
|
59
|
+
iconStyle() {
|
|
60
|
+
return {
|
|
61
|
+
width: typeof this.iconWidth === 'number' ? `${this.iconWidth}px` : this.iconWidth,
|
|
62
|
+
height: typeof this.iconHeight === 'number' ? `${this.iconHeight}px` : this.iconHeight,
|
|
63
|
+
flexShrink: this.iconFlexShrink,
|
|
64
|
+
marginRight: typeof this.iconMarginRight === 'number' ? `${this.iconMarginRight}px` : this.iconMarginRight
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
// 信息容器样式
|
|
69
|
+
infoStyle() {
|
|
70
|
+
return {
|
|
71
|
+
flex: this.infoFlex,
|
|
72
|
+
display: this.infoDisplay,
|
|
73
|
+
flexDirection: this.infoFlexDirection,
|
|
74
|
+
justifyContent: this.infoJustifyContent
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// 标题样式
|
|
79
|
+
titleStyle() {
|
|
80
|
+
return {
|
|
81
|
+
fontFamily: this.titleFontFamily,
|
|
82
|
+
fontWeight: this.titleFontWeight,
|
|
83
|
+
fontSize: typeof this.titleFontSize === 'number' ? `${this.titleFontSize}px` : this.titleFontSize,
|
|
84
|
+
color: this.titleColor,
|
|
85
|
+
lineHeight: typeof this.titleLineHeight === 'number' ? this.titleLineHeight : this.titleLineHeight,
|
|
86
|
+
marginBottom: typeof this.titleMarginBottom === 'number' ? `${this.titleMarginBottom}px` : this.titleMarginBottom
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// 数值容器样式
|
|
91
|
+
numContainerStyle() {
|
|
92
|
+
return {
|
|
93
|
+
display: this.numDisplay,
|
|
94
|
+
alignItems: this.numAlignItems
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// 数值样式
|
|
99
|
+
numStyle() {
|
|
100
|
+
return {
|
|
101
|
+
fontFamily: this.numFontFamily,
|
|
102
|
+
fontWeight: this.numFontWeight,
|
|
103
|
+
fontStyle: this.numFontStyle,
|
|
104
|
+
fontSize: typeof this.numFontSize === 'number' ? `${this.numFontSize}px` : this.numFontSize,
|
|
105
|
+
lineHeight: typeof this.numLineHeight === 'number' ? this.numLineHeight : this.numLineHeight,
|
|
106
|
+
marginRight: typeof this.numMarginRight === 'number' ? `${this.numMarginRight}px` : this.numMarginRight,
|
|
107
|
+
paddingRight: typeof this.numPaddingRight === 'number' ? `${this.numPaddingRight}px` : this.numPaddingRight,
|
|
108
|
+
color: this.numColor,
|
|
109
|
+
background: this.numBackground,
|
|
110
|
+
WebkitBackgroundClip: this.numBackgroundClip,
|
|
111
|
+
backgroundClip: this.numBackgroundClip,
|
|
112
|
+
textShadow: this.numTextShadow
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// 单位样式
|
|
117
|
+
unitStyle() {
|
|
118
|
+
return {
|
|
119
|
+
fontFamily: this.unitFontFamily,
|
|
120
|
+
fontWeight: this.unitFontWeight,
|
|
121
|
+
fontSize: typeof this.unitFontSize === 'number' ? `${this.unitFontSize}px` : this.unitFontSize,
|
|
122
|
+
color: this.unitColor,
|
|
123
|
+
lineHeight: typeof this.unitLineHeight === 'number' ? this.unitLineHeight : this.unitLineHeight
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
watch: {},
|
|
128
|
+
mounted() {},
|
|
129
|
+
created() {},
|
|
130
|
+
methods: {}
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<style lang="scss" scoped>
|
|
135
|
+
.l-icon-label {
|
|
136
|
+
// 基础样式通过内联样式控制
|
|
137
|
+
|
|
138
|
+
&__icon {
|
|
139
|
+
// 图标样式通过内联样式控制
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&__info {
|
|
143
|
+
// 信息容器样式通过内联样式控制
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&__title {
|
|
147
|
+
// 标题样式通过内联样式控制
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__num {
|
|
151
|
+
// 数值容器样式通过内联样式控制
|
|
152
|
+
|
|
153
|
+
&-value {
|
|
154
|
+
// 数值样式通过内联样式控制
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&-unit {
|
|
158
|
+
// 单位样式通过内联样式控制
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
</style>
|