xt-element-ui 1.3.2 → 1.3.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.
- package/CHANGELOG.md +72 -72
- package/LICENSE +21 -21
- package/README.md +240 -240
- package/docs/README.md +100 -100
- package/docs/components/base/xt-button.md +114 -114
- package/docs/components/base/xt-card-item.md +104 -104
- package/docs/components/base/xt-card.md +108 -108
- package/docs/components/base/xt-config-provider.md +199 -199
- package/docs/components/base/xt-flex-box.md +115 -115
- package/docs/components/base/xt-grid-box.md +302 -302
- package/docs/components/base/xt-input.md +150 -150
- package/docs/components/base/xt-map-provider.md +23 -0
- package/docs/components/base/xt-map.md +331 -331
- package/docs/components/base/xt-step-price.md +165 -165
- package/docs/components/base/xt-text.md +212 -212
- package/docs/components/base/xt-time.md +165 -165
- package/docs/components/extend/ex-bar.md +67 -67
- package/docs/components/extend/ex-button.md +62 -62
- package/docs/components/extend/ex-card.md +86 -86
- package/docs/components/extend/ex-chart.md +463 -463
- package/docs/components/extend/ex-icon.md +189 -189
- package/docs/components/extend/ex-line.md +70 -70
- package/docs/components/extend/ex-multi.md +155 -155
- package/docs/components/extend/ex-pie.md +69 -69
- package/docs/components/extend/ex-select-tree.md +210 -210
- package/docs/components/extend/ex-table.md +590 -590
- package/docs/components/extend/ex-upload.md +134 -134
- package/docs/components/utils/size.md +147 -147
- package/docs/components/utils/theme.md +182 -182
- package/lib/index.common.js +4131 -4162
- package/lib/index.css +1 -1
- package/lib/index.umd.js +4099 -4129
- package/lib/index.umd.min.js +3 -3
- package/package.json +80 -81
- package/src/components/ex-button/index.js +7 -7
- package/src/components/ex-button/index.vue +66 -66
- package/src/components/ex-button/style/index.scss +67 -67
- package/src/components/ex-card/index.js +7 -7
- package/src/components/ex-card/index.vue +68 -68
- package/src/components/ex-card/style/index.scss +73 -73
- package/src/components/ex-chart/index.js +7 -7
- package/src/components/ex-chart/index.vue +136 -136
- package/src/components/ex-date-picker/index.js +7 -7
- package/src/components/ex-icon/index.js +7 -7
- package/src/components/ex-icon/index.vue +168 -168
- package/src/components/ex-icon/style/index.scss +7 -7
- package/src/components/ex-page/index.js +7 -7
- package/src/components/ex-select-tree/index.js +7 -7
- package/src/components/ex-table/ExTableCell.vue +22 -22
- package/src/components/ex-table/index.js +7 -7
- package/src/components/ex-table/virtualScrollData.js +35 -35
- package/src/components/ex-upload/index.js +7 -7
- package/src/components/index.scss +39 -39
- package/src/components/xt-button/index.js +7 -7
- package/src/components/xt-button/index.vue +97 -97
- package/src/components/xt-card/index.js +7 -7
- package/src/components/xt-card/style/index.scss +48 -48
- package/src/components/xt-card-item/index.js +7 -7
- package/src/components/xt-card-item/style/index copy.scss +71 -71
- package/src/components/xt-card-item/style/index.scss +82 -82
- package/src/components/xt-config-provider/index.js +7 -7
- package/src/components/xt-config-provider/index.vue +362 -362
- package/src/components/xt-config-provider/style/index.scss +11 -11
- package/src/components/xt-flex-box/index.js +7 -7
- package/src/components/xt-flex-box/style/index.scss +81 -81
- package/src/components/xt-grid-box/index.js +7 -7
- package/src/components/xt-grid-box/style/index.scss +92 -92
- package/src/components/xt-grid-item/index.js +7 -7
- package/src/components/xt-grid-item/index.vue +106 -106
- package/src/components/xt-input/index.js +7 -7
- package/src/components/xt-input/index.vue +66 -66
- package/src/components/xt-input/style/index.scss +84 -84
- package/src/components/xt-map/adapters/amap.js +235 -235
- package/src/components/xt-map/adapters/baidu.js +254 -254
- package/src/components/xt-map/adapters/base.js +267 -267
- package/src/components/xt-map/adapters/index.js +29 -29
- package/src/components/xt-map/adapters/tianditu.js +242 -242
- package/src/components/xt-map/config/xt-map-config.js +197 -197
- package/src/components/xt-map/index.js +8 -30
- package/src/components/xt-map/index.vue +351 -351
- package/src/components/xt-map/loaders/script-loader.js +114 -114
- package/src/components/xt-map/provider.vue +200 -200
- package/src/components/xt-map/style/index.scss +77 -77
- package/src/components/xt-map-provider/index.js +8 -0
- package/src/components/xt-step-price/index.js +10 -10
- package/src/components/xt-step-price/index.vue +272 -272
- package/src/components/xt-step-price/style/index.scss +123 -123
- package/src/components/xt-step-price-item/index.js +7 -7
- package/src/components/xt-step-price-item/index.vue +187 -187
- package/src/components/xt-text/index.js +7 -7
- package/src/components/xt-text/index.vue +1 -1
- package/src/components/xt-text/style/index.scss +92 -92
- package/src/components/xt-time/index.js +7 -7
- package/src/components/xt-time/index.vue +313 -313
- package/src/components/xt-time/style/index.scss +23 -23
- package/src/config/element-registry.js +135 -135
- package/src/index.js +162 -178
- package/src/styles/css-variables.scss +257 -257
- package/src/styles/theme/background.scss +5 -5
- package/src/styles/theme/border-radius.scss +3 -3
- package/src/styles/theme/borders.scss +3 -3
- package/src/styles/theme/colors.scss +101 -101
- package/src/styles/theme/component-variables.scss +69 -69
- package/src/styles/theme/dark-variables.scss +28 -28
- package/src/styles/theme/font.scss +12 -12
- package/src/styles/theme/index.scss +11 -11
- package/src/styles/theme/shadows.scss +2 -2
- package/src/styles/theme/spacing.scss +4 -4
- package/src/styles/theme/transitions.scss +2 -2
- package/src/styles/theme/typography.scss +4 -4
- package/src/styles/variables-export.scss +85 -85
- package/src/utils/index.js +191 -202
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
## XtCard 卡片组件
|
|
2
|
-
|
|
3
|
-
卡片组件用于展示信息,通常包含标题和内容区域。
|
|
4
|
-
|
|
5
|
-
## 基本用法
|
|
6
|
-
|
|
7
|
-
::: demo 基本用法
|
|
8
|
-
```vue
|
|
9
|
-
<template>
|
|
10
|
-
<XtCard title="卡片标题" value="123" unit="元"></XtCard>
|
|
11
|
-
</template>
|
|
12
|
-
```
|
|
13
|
-
:::
|
|
14
|
-
|
|
15
|
-
## 属性说明
|
|
16
|
-
|
|
17
|
-
| 属性 | 类型 | 默认值 | 说明 |
|
|
18
|
-
|------|------|--------|------|
|
|
19
|
-
| `title` | String | - | 卡片标题 |
|
|
20
|
-
| `value` | String / Number | - | 卡片数值 |
|
|
21
|
-
| `unit` | String | - | 数值单位 |
|
|
22
|
-
| `noPadding` | Boolean | false | 是否取消内边距 |
|
|
23
|
-
|
|
24
|
-
## 插槽说明
|
|
25
|
-
|
|
26
|
-
| 插槽名 | 说明 |
|
|
27
|
-
|--------|------|
|
|
28
|
-
| `default` | 自定义内容区域 |
|
|
29
|
-
| `title` | 自定义标题区域 |
|
|
30
|
-
| `value` | 自定义数值区域 |
|
|
31
|
-
|
|
32
|
-
## 示例
|
|
33
|
-
|
|
34
|
-
### 基础卡片
|
|
35
|
-
|
|
36
|
-
::: demo 基础卡片
|
|
37
|
-
```vue
|
|
38
|
-
<template>
|
|
39
|
-
<XtCard title="今日销售额" :value="123456" unit="元"></XtCard>
|
|
40
|
-
</template>
|
|
41
|
-
```
|
|
42
|
-
:::
|
|
43
|
-
|
|
44
|
-
### 自定义内容
|
|
45
|
-
|
|
46
|
-
::: demo 自定义内容
|
|
47
|
-
```vue
|
|
48
|
-
<template>
|
|
49
|
-
<XtCard title="用户统计">
|
|
50
|
-
<div style="display: flex; justify-content: space-around;">
|
|
51
|
-
<div style="text-align: center;">
|
|
52
|
-
<span style="display: block; font-size: 12px; color: #999;">新增用户</span>
|
|
53
|
-
<span style="font-size: 24px; font-weight: bold; color: #1890ff;">520</span>
|
|
54
|
-
</div>
|
|
55
|
-
<div style="text-align: center;">
|
|
56
|
-
<span style="display: block; font-size: 12px; color: #999;">活跃用户</span>
|
|
57
|
-
<span style="font-size: 24px; font-weight: bold; color: #52c41a;">3840</span>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
</XtCard>
|
|
61
|
-
</template>
|
|
62
|
-
```
|
|
63
|
-
:::
|
|
64
|
-
|
|
65
|
-
### 自定义标题和数值
|
|
66
|
-
|
|
67
|
-
::: demo 自定义标题和数值
|
|
68
|
-
```vue
|
|
69
|
-
<template>
|
|
70
|
-
<XtCard>
|
|
71
|
-
<template #title>
|
|
72
|
-
<span style="color: #1890ff;">📊 数据分析</span>
|
|
73
|
-
</template>
|
|
74
|
-
<template #value>
|
|
75
|
-
<span style="font-size: 32px; color: #52c41a;">98.5%</span>
|
|
76
|
-
</template>
|
|
77
|
-
</XtCard>
|
|
78
|
-
</template>
|
|
79
|
-
```
|
|
80
|
-
:::
|
|
81
|
-
|
|
82
|
-
### 无边距卡片
|
|
83
|
-
|
|
84
|
-
::: demo 无边距卡片
|
|
85
|
-
```vue
|
|
86
|
-
<template>
|
|
87
|
-
<XtCard title="紧凑卡片" :value="100" noPadding>
|
|
88
|
-
<div style="padding: 8px;">
|
|
89
|
-
<p>内容区域没有额外内边距</p>
|
|
90
|
-
</div>
|
|
91
|
-
</XtCard>
|
|
92
|
-
</template>
|
|
93
|
-
```
|
|
94
|
-
:::
|
|
95
|
-
|
|
96
|
-
### 卡片组
|
|
97
|
-
|
|
98
|
-
::: demo 卡片组
|
|
99
|
-
```vue
|
|
100
|
-
<template>
|
|
101
|
-
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;">
|
|
102
|
-
<XtCard title="销售额" value="12345" unit="元"></XtCard>
|
|
103
|
-
<XtCard title="订单数" value="520" unit="单"></XtCard>
|
|
104
|
-
<XtCard title="转化率" value="23.5" unit="%"></XtCard>
|
|
105
|
-
</div>
|
|
106
|
-
</template>
|
|
107
|
-
```
|
|
108
|
-
:::
|
|
1
|
+
## XtCard 卡片组件
|
|
2
|
+
|
|
3
|
+
卡片组件用于展示信息,通常包含标题和内容区域。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
::: demo 基本用法
|
|
8
|
+
```vue
|
|
9
|
+
<template>
|
|
10
|
+
<XtCard title="卡片标题" value="123" unit="元"></XtCard>
|
|
11
|
+
</template>
|
|
12
|
+
```
|
|
13
|
+
:::
|
|
14
|
+
|
|
15
|
+
## 属性说明
|
|
16
|
+
|
|
17
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
18
|
+
|------|------|--------|------|
|
|
19
|
+
| `title` | String | - | 卡片标题 |
|
|
20
|
+
| `value` | String / Number | - | 卡片数值 |
|
|
21
|
+
| `unit` | String | - | 数值单位 |
|
|
22
|
+
| `noPadding` | Boolean | false | 是否取消内边距 |
|
|
23
|
+
|
|
24
|
+
## 插槽说明
|
|
25
|
+
|
|
26
|
+
| 插槽名 | 说明 |
|
|
27
|
+
|--------|------|
|
|
28
|
+
| `default` | 自定义内容区域 |
|
|
29
|
+
| `title` | 自定义标题区域 |
|
|
30
|
+
| `value` | 自定义数值区域 |
|
|
31
|
+
|
|
32
|
+
## 示例
|
|
33
|
+
|
|
34
|
+
### 基础卡片
|
|
35
|
+
|
|
36
|
+
::: demo 基础卡片
|
|
37
|
+
```vue
|
|
38
|
+
<template>
|
|
39
|
+
<XtCard title="今日销售额" :value="123456" unit="元"></XtCard>
|
|
40
|
+
</template>
|
|
41
|
+
```
|
|
42
|
+
:::
|
|
43
|
+
|
|
44
|
+
### 自定义内容
|
|
45
|
+
|
|
46
|
+
::: demo 自定义内容
|
|
47
|
+
```vue
|
|
48
|
+
<template>
|
|
49
|
+
<XtCard title="用户统计">
|
|
50
|
+
<div style="display: flex; justify-content: space-around;">
|
|
51
|
+
<div style="text-align: center;">
|
|
52
|
+
<span style="display: block; font-size: 12px; color: #999;">新增用户</span>
|
|
53
|
+
<span style="font-size: 24px; font-weight: bold; color: #1890ff;">520</span>
|
|
54
|
+
</div>
|
|
55
|
+
<div style="text-align: center;">
|
|
56
|
+
<span style="display: block; font-size: 12px; color: #999;">活跃用户</span>
|
|
57
|
+
<span style="font-size: 24px; font-weight: bold; color: #52c41a;">3840</span>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</XtCard>
|
|
61
|
+
</template>
|
|
62
|
+
```
|
|
63
|
+
:::
|
|
64
|
+
|
|
65
|
+
### 自定义标题和数值
|
|
66
|
+
|
|
67
|
+
::: demo 自定义标题和数值
|
|
68
|
+
```vue
|
|
69
|
+
<template>
|
|
70
|
+
<XtCard>
|
|
71
|
+
<template #title>
|
|
72
|
+
<span style="color: #1890ff;">📊 数据分析</span>
|
|
73
|
+
</template>
|
|
74
|
+
<template #value>
|
|
75
|
+
<span style="font-size: 32px; color: #52c41a;">98.5%</span>
|
|
76
|
+
</template>
|
|
77
|
+
</XtCard>
|
|
78
|
+
</template>
|
|
79
|
+
```
|
|
80
|
+
:::
|
|
81
|
+
|
|
82
|
+
### 无边距卡片
|
|
83
|
+
|
|
84
|
+
::: demo 无边距卡片
|
|
85
|
+
```vue
|
|
86
|
+
<template>
|
|
87
|
+
<XtCard title="紧凑卡片" :value="100" noPadding>
|
|
88
|
+
<div style="padding: 8px;">
|
|
89
|
+
<p>内容区域没有额外内边距</p>
|
|
90
|
+
</div>
|
|
91
|
+
</XtCard>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
:::
|
|
95
|
+
|
|
96
|
+
### 卡片组
|
|
97
|
+
|
|
98
|
+
::: demo 卡片组
|
|
99
|
+
```vue
|
|
100
|
+
<template>
|
|
101
|
+
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;">
|
|
102
|
+
<XtCard title="销售额" value="12345" unit="元"></XtCard>
|
|
103
|
+
<XtCard title="订单数" value="520" unit="单"></XtCard>
|
|
104
|
+
<XtCard title="转化率" value="23.5" unit="%"></XtCard>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
```
|
|
108
|
+
:::
|
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
## XtConfigProvider 配置提供者
|
|
2
|
-
|
|
3
|
-
配置提供者组件用于全局配置主题和样式变量。
|
|
4
|
-
|
|
5
|
-
## 基本用法
|
|
6
|
-
|
|
7
|
-
::: demo 基本用法
|
|
8
|
-
```vue
|
|
9
|
-
<template>
|
|
10
|
-
<XtConfigProvider :theme="theme" proxyElement="body">
|
|
11
|
-
<div>
|
|
12
|
-
<XtButton type="primary" @click="handleSwitchTheme">主题按钮</XtButton>
|
|
13
|
-
</div>
|
|
14
|
-
</XtConfigProvider>
|
|
15
|
-
</template>
|
|
16
|
-
<script>
|
|
17
|
-
export default {
|
|
18
|
-
data(){
|
|
19
|
-
return {
|
|
20
|
-
theme: 'white'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
methods: {
|
|
24
|
-
handleSwitchTheme() {
|
|
25
|
-
this.theme = this.theme == 'dark' ? 'white': 'dark'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
```
|
|
31
|
-
:::
|
|
32
|
-
|
|
33
|
-
## 属性说明
|
|
34
|
-
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
35
|
-
|------|------|--------|--------|------|
|
|
36
|
-
| `primaryColor` | String | - | - | 自定义主题色 |
|
|
37
|
-
| `theme` | String | - | `dark`、`light` | 主题模式 |
|
|
38
|
-
| `size` | String | - | `small`、`medium`、`large` | 组件尺寸 |
|
|
39
|
-
| `injectBackground` | Boolean | - | - | 是否注入背景色到根元素 |
|
|
40
|
-
| `injectColor` | Boolean | - | - | 是否注入文字颜色到根元素 |
|
|
41
|
-
| `tag` | String | 'div' | - | 根元素标签 |
|
|
42
|
-
| `proxyElement` | HTMLElement / String | - | - | 代理元素 |
|
|
43
|
-
| `vars` | Object | - | - | 自定义 CSS 变量 |
|
|
44
|
-
|
|
45
|
-
## 示例
|
|
46
|
-
|
|
47
|
-
### 自定义主题色
|
|
48
|
-
|
|
49
|
-
::: demo 自定义主题色
|
|
50
|
-
```vue
|
|
51
|
-
<template>
|
|
52
|
-
<XtConfigProvider :primaryColor="'#722ed1'">
|
|
53
|
-
<div>
|
|
54
|
-
<XtButton type="primary">紫色主题按钮</XtButton>
|
|
55
|
-
<XtCard title="自定义主题卡片">
|
|
56
|
-
<XtText type="primary">主题色文本</XtText>
|
|
57
|
-
</XtCard>
|
|
58
|
-
</div>
|
|
59
|
-
</XtConfigProvider>
|
|
60
|
-
</template>
|
|
61
|
-
```
|
|
62
|
-
:::
|
|
63
|
-
|
|
64
|
-
### 亮色主题
|
|
65
|
-
|
|
66
|
-
::: demo 亮色主题
|
|
67
|
-
```vue
|
|
68
|
-
<template>
|
|
69
|
-
<XtConfigProvider theme="light" injectBackground>
|
|
70
|
-
<div style="min-height: 100px; padding: 16px;">
|
|
71
|
-
<XtCard title="亮色模式卡片">
|
|
72
|
-
<XtText type="primary">亮色主题内容</XtText>
|
|
73
|
-
</XtCard>
|
|
74
|
-
<XtButton type="primary">亮色主题按钮</XtButton>
|
|
75
|
-
</div>
|
|
76
|
-
</XtConfigProvider>
|
|
77
|
-
</template>
|
|
78
|
-
```
|
|
79
|
-
:::
|
|
80
|
-
|
|
81
|
-
### 自定义 CSS 变量
|
|
82
|
-
|
|
83
|
-
::: demo 自定义 CSS 变量
|
|
84
|
-
```vue
|
|
85
|
-
<template>
|
|
86
|
-
<XtConfigProvider :vars="{
|
|
87
|
-
'--xt-color-primary': '#52c41a',
|
|
88
|
-
'--xt-color-success': '#13c2c2',
|
|
89
|
-
'--xt-flex-box-gap': '20px'
|
|
90
|
-
}">
|
|
91
|
-
<XtFlexBox>
|
|
92
|
-
<XtButton type="primary">绿色主题按钮</XtButton>
|
|
93
|
-
<XtButton type="success">青色成功按钮</XtButton>
|
|
94
|
-
</XtFlexBox>
|
|
95
|
-
</XtConfigProvider>
|
|
96
|
-
</template>
|
|
97
|
-
```
|
|
98
|
-
:::
|
|
99
|
-
|
|
100
|
-
### 组合配置
|
|
101
|
-
|
|
102
|
-
::: demo 组合配置
|
|
103
|
-
```vue
|
|
104
|
-
<template>
|
|
105
|
-
<XtConfigProvider
|
|
106
|
-
:primaryColor="'#1890ff'"
|
|
107
|
-
size="medium"
|
|
108
|
-
>
|
|
109
|
-
<div style="padding: 16px;">
|
|
110
|
-
<XtCard title="综合配置示例">
|
|
111
|
-
<XtText type="primary">主题色: #1890ff</XtText>
|
|
112
|
-
<XtText type="success">尺寸: medium</XtText>
|
|
113
|
-
</XtCard>
|
|
114
|
-
<XtFlexBox gap="16px" style="margin-top: 16px;">
|
|
115
|
-
<XtButton type="primary">主要按钮</XtButton>
|
|
116
|
-
<XtButton type="success">成功按钮</XtButton>
|
|
117
|
-
<XtButton type="warning">警告按钮</XtButton>
|
|
118
|
-
</XtFlexBox>
|
|
119
|
-
</div>
|
|
120
|
-
</XtConfigProvider>
|
|
121
|
-
</template>
|
|
122
|
-
```
|
|
123
|
-
:::
|
|
124
|
-
|
|
125
|
-
### 动态主题切换
|
|
126
|
-
::: demo 动态主题切换
|
|
127
|
-
```vue
|
|
128
|
-
<template>
|
|
129
|
-
<XtConfigProvider
|
|
130
|
-
:primaryColor="primaryColor"
|
|
131
|
-
:theme="currentTheme"
|
|
132
|
-
injectBackground
|
|
133
|
-
>
|
|
134
|
-
<div style="min-height: 120px; padding: 16px;">
|
|
135
|
-
<XtFlexBox content="space-between" style="margin-bottom: 16px;">
|
|
136
|
-
<span>当前主题: {{ currentTheme }}</span>
|
|
137
|
-
<XtFlexBox gap="8px">
|
|
138
|
-
<XtButton
|
|
139
|
-
type="primary"
|
|
140
|
-
plain
|
|
141
|
-
@click="switchTheme"
|
|
142
|
-
>
|
|
143
|
-
切换主题
|
|
144
|
-
</XtButton>
|
|
145
|
-
<XtButton
|
|
146
|
-
type="success"
|
|
147
|
-
plain
|
|
148
|
-
@click="changeColor"
|
|
149
|
-
>
|
|
150
|
-
更换主题色
|
|
151
|
-
</XtButton>
|
|
152
|
-
</XtFlexBox>
|
|
153
|
-
</XtFlexBox>
|
|
154
|
-
<XtCard title="动态主题示例">
|
|
155
|
-
<XtText type="primary">当前主题色: {{ primaryColor }}</XtText>
|
|
156
|
-
</XtCard>
|
|
157
|
-
</div>
|
|
158
|
-
</XtConfigProvider>
|
|
159
|
-
</template>
|
|
160
|
-
|
|
161
|
-
<script>
|
|
162
|
-
export default {
|
|
163
|
-
data() {
|
|
164
|
-
return {
|
|
165
|
-
primaryColor: '#1890ff',
|
|
166
|
-
currentTheme: 'light',
|
|
167
|
-
colors: ['#1890ff', '#52c41a', '#faad14', '#f5222d', '#722ed1']
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
methods: {
|
|
171
|
-
switchTheme() {
|
|
172
|
-
this.currentTheme = this.currentTheme === 'light' ? 'dark' : 'light'
|
|
173
|
-
},
|
|
174
|
-
changeColor() {
|
|
175
|
-
const randomIndex = Math.floor(Math.random() * this.colors.length)
|
|
176
|
-
this.primaryColor = this.colors[randomIndex]
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
</script>
|
|
181
|
-
```
|
|
182
|
-
:::
|
|
183
|
-
|
|
184
|
-
## 支持的 CSS 变量
|
|
185
|
-
|
|
186
|
-
| CSS 变量 | 说明 |
|
|
187
|
-
|----------|------|
|
|
188
|
-
| `--xt-color-primary` | 主色 |
|
|
189
|
-
| `--xt-color-success` | 成功色 |
|
|
190
|
-
| `--xt-color-warning` | 警告色 |
|
|
191
|
-
| `--xt-color-danger` | 危险色 |
|
|
192
|
-
| `--xt-color-info` | 信息色 |
|
|
193
|
-
| `--xt-text-color-primary` | 主要文字颜色 |
|
|
194
|
-
| `--xt-text-color-regular` | 常规文字颜色 |
|
|
195
|
-
| `--xt-text-color-secondary` | 次要文字颜色 |
|
|
196
|
-
| `--xt-bg-color` | 背景颜色 |
|
|
197
|
-
| `--xt-bg-color-page` | 页面背景颜色 |
|
|
198
|
-
| `--xt-border-color` | 边框颜色 |
|
|
199
|
-
| `--xt-flex-box-gap` | FlexBox 默认间距 |
|
|
1
|
+
## XtConfigProvider 配置提供者
|
|
2
|
+
|
|
3
|
+
配置提供者组件用于全局配置主题和样式变量。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
::: demo 基本用法
|
|
8
|
+
```vue
|
|
9
|
+
<template>
|
|
10
|
+
<XtConfigProvider :theme="theme" proxyElement="body">
|
|
11
|
+
<div>
|
|
12
|
+
<XtButton type="primary" @click="handleSwitchTheme">主题按钮</XtButton>
|
|
13
|
+
</div>
|
|
14
|
+
</XtConfigProvider>
|
|
15
|
+
</template>
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
data(){
|
|
19
|
+
return {
|
|
20
|
+
theme: 'white'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
handleSwitchTheme() {
|
|
25
|
+
this.theme = this.theme == 'dark' ? 'white': 'dark'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
:::
|
|
32
|
+
|
|
33
|
+
## 属性说明
|
|
34
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
35
|
+
|------|------|--------|--------|------|
|
|
36
|
+
| `primaryColor` | String | - | - | 自定义主题色 |
|
|
37
|
+
| `theme` | String | - | `dark`、`light` | 主题模式 |
|
|
38
|
+
| `size` | String | - | `small`、`medium`、`large` | 组件尺寸 |
|
|
39
|
+
| `injectBackground` | Boolean | - | - | 是否注入背景色到根元素 |
|
|
40
|
+
| `injectColor` | Boolean | - | - | 是否注入文字颜色到根元素 |
|
|
41
|
+
| `tag` | String | 'div' | - | 根元素标签 |
|
|
42
|
+
| `proxyElement` | HTMLElement / String | - | - | 代理元素 |
|
|
43
|
+
| `vars` | Object | - | - | 自定义 CSS 变量 |
|
|
44
|
+
|
|
45
|
+
## 示例
|
|
46
|
+
|
|
47
|
+
### 自定义主题色
|
|
48
|
+
|
|
49
|
+
::: demo 自定义主题色
|
|
50
|
+
```vue
|
|
51
|
+
<template>
|
|
52
|
+
<XtConfigProvider :primaryColor="'#722ed1'">
|
|
53
|
+
<div>
|
|
54
|
+
<XtButton type="primary">紫色主题按钮</XtButton>
|
|
55
|
+
<XtCard title="自定义主题卡片">
|
|
56
|
+
<XtText type="primary">主题色文本</XtText>
|
|
57
|
+
</XtCard>
|
|
58
|
+
</div>
|
|
59
|
+
</XtConfigProvider>
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
:::
|
|
63
|
+
|
|
64
|
+
### 亮色主题
|
|
65
|
+
|
|
66
|
+
::: demo 亮色主题
|
|
67
|
+
```vue
|
|
68
|
+
<template>
|
|
69
|
+
<XtConfigProvider theme="light" injectBackground>
|
|
70
|
+
<div style="min-height: 100px; padding: 16px;">
|
|
71
|
+
<XtCard title="亮色模式卡片">
|
|
72
|
+
<XtText type="primary">亮色主题内容</XtText>
|
|
73
|
+
</XtCard>
|
|
74
|
+
<XtButton type="primary">亮色主题按钮</XtButton>
|
|
75
|
+
</div>
|
|
76
|
+
</XtConfigProvider>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
79
|
+
:::
|
|
80
|
+
|
|
81
|
+
### 自定义 CSS 变量
|
|
82
|
+
|
|
83
|
+
::: demo 自定义 CSS 变量
|
|
84
|
+
```vue
|
|
85
|
+
<template>
|
|
86
|
+
<XtConfigProvider :vars="{
|
|
87
|
+
'--xt-color-primary': '#52c41a',
|
|
88
|
+
'--xt-color-success': '#13c2c2',
|
|
89
|
+
'--xt-flex-box-gap': '20px'
|
|
90
|
+
}">
|
|
91
|
+
<XtFlexBox>
|
|
92
|
+
<XtButton type="primary">绿色主题按钮</XtButton>
|
|
93
|
+
<XtButton type="success">青色成功按钮</XtButton>
|
|
94
|
+
</XtFlexBox>
|
|
95
|
+
</XtConfigProvider>
|
|
96
|
+
</template>
|
|
97
|
+
```
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
### 组合配置
|
|
101
|
+
|
|
102
|
+
::: demo 组合配置
|
|
103
|
+
```vue
|
|
104
|
+
<template>
|
|
105
|
+
<XtConfigProvider
|
|
106
|
+
:primaryColor="'#1890ff'"
|
|
107
|
+
size="medium"
|
|
108
|
+
>
|
|
109
|
+
<div style="padding: 16px;">
|
|
110
|
+
<XtCard title="综合配置示例">
|
|
111
|
+
<XtText type="primary">主题色: #1890ff</XtText>
|
|
112
|
+
<XtText type="success">尺寸: medium</XtText>
|
|
113
|
+
</XtCard>
|
|
114
|
+
<XtFlexBox gap="16px" style="margin-top: 16px;">
|
|
115
|
+
<XtButton type="primary">主要按钮</XtButton>
|
|
116
|
+
<XtButton type="success">成功按钮</XtButton>
|
|
117
|
+
<XtButton type="warning">警告按钮</XtButton>
|
|
118
|
+
</XtFlexBox>
|
|
119
|
+
</div>
|
|
120
|
+
</XtConfigProvider>
|
|
121
|
+
</template>
|
|
122
|
+
```
|
|
123
|
+
:::
|
|
124
|
+
|
|
125
|
+
### 动态主题切换
|
|
126
|
+
::: demo 动态主题切换
|
|
127
|
+
```vue
|
|
128
|
+
<template>
|
|
129
|
+
<XtConfigProvider
|
|
130
|
+
:primaryColor="primaryColor"
|
|
131
|
+
:theme="currentTheme"
|
|
132
|
+
injectBackground
|
|
133
|
+
>
|
|
134
|
+
<div style="min-height: 120px; padding: 16px;">
|
|
135
|
+
<XtFlexBox content="space-between" style="margin-bottom: 16px;">
|
|
136
|
+
<span>当前主题: {{ currentTheme }}</span>
|
|
137
|
+
<XtFlexBox gap="8px">
|
|
138
|
+
<XtButton
|
|
139
|
+
type="primary"
|
|
140
|
+
plain
|
|
141
|
+
@click="switchTheme"
|
|
142
|
+
>
|
|
143
|
+
切换主题
|
|
144
|
+
</XtButton>
|
|
145
|
+
<XtButton
|
|
146
|
+
type="success"
|
|
147
|
+
plain
|
|
148
|
+
@click="changeColor"
|
|
149
|
+
>
|
|
150
|
+
更换主题色
|
|
151
|
+
</XtButton>
|
|
152
|
+
</XtFlexBox>
|
|
153
|
+
</XtFlexBox>
|
|
154
|
+
<XtCard title="动态主题示例">
|
|
155
|
+
<XtText type="primary">当前主题色: {{ primaryColor }}</XtText>
|
|
156
|
+
</XtCard>
|
|
157
|
+
</div>
|
|
158
|
+
</XtConfigProvider>
|
|
159
|
+
</template>
|
|
160
|
+
|
|
161
|
+
<script>
|
|
162
|
+
export default {
|
|
163
|
+
data() {
|
|
164
|
+
return {
|
|
165
|
+
primaryColor: '#1890ff',
|
|
166
|
+
currentTheme: 'light',
|
|
167
|
+
colors: ['#1890ff', '#52c41a', '#faad14', '#f5222d', '#722ed1']
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
methods: {
|
|
171
|
+
switchTheme() {
|
|
172
|
+
this.currentTheme = this.currentTheme === 'light' ? 'dark' : 'light'
|
|
173
|
+
},
|
|
174
|
+
changeColor() {
|
|
175
|
+
const randomIndex = Math.floor(Math.random() * this.colors.length)
|
|
176
|
+
this.primaryColor = this.colors[randomIndex]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</script>
|
|
181
|
+
```
|
|
182
|
+
:::
|
|
183
|
+
|
|
184
|
+
## 支持的 CSS 变量
|
|
185
|
+
|
|
186
|
+
| CSS 变量 | 说明 |
|
|
187
|
+
|----------|------|
|
|
188
|
+
| `--xt-color-primary` | 主色 |
|
|
189
|
+
| `--xt-color-success` | 成功色 |
|
|
190
|
+
| `--xt-color-warning` | 警告色 |
|
|
191
|
+
| `--xt-color-danger` | 危险色 |
|
|
192
|
+
| `--xt-color-info` | 信息色 |
|
|
193
|
+
| `--xt-text-color-primary` | 主要文字颜色 |
|
|
194
|
+
| `--xt-text-color-regular` | 常规文字颜色 |
|
|
195
|
+
| `--xt-text-color-secondary` | 次要文字颜色 |
|
|
196
|
+
| `--xt-bg-color` | 背景颜色 |
|
|
197
|
+
| `--xt-bg-color-page` | 页面背景颜色 |
|
|
198
|
+
| `--xt-border-color` | 边框颜色 |
|
|
199
|
+
| `--xt-flex-box-gap` | FlexBox 默认间距 |
|