xt-element-ui 1.3.3 → 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 -23
- 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 +4112 -4122
- package/lib/index.umd.js +4072 -4081
- 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 -8
- 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 -8
- 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,183 +1,183 @@
|
|
|
1
|
-
## 主题配置
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
通过工具函数可以全局设置主题模式,支持两种主题:`white`(亮色主题)和 `dark`(暗色主题)。
|
|
6
|
-
|
|
7
|
-
## 方法说明
|
|
8
|
-
|
|
9
|
-
### setTheme(theme)
|
|
10
|
-
|
|
11
|
-
设置全局主题。
|
|
12
|
-
|
|
13
|
-
| 参数 | 类型 | 必填 | 说明 |
|
|
14
|
-
|------|------|------|------|
|
|
15
|
-
| `theme` | String | 是 | 主题类型:`white`、`dark` |
|
|
16
|
-
|
|
17
|
-
```vue
|
|
18
|
-
<template>
|
|
19
|
-
<div>
|
|
20
|
-
<XtButton @click="setWhiteTheme">亮色主题</XtButton>
|
|
21
|
-
<XtButton @click="setDarkTheme">暗色主题</XtButton>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script>
|
|
26
|
-
import { setTheme } from 'xt-element-ui'
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
methods: {
|
|
30
|
-
setWhiteTheme() {
|
|
31
|
-
setTheme('white')
|
|
32
|
-
},
|
|
33
|
-
setDarkTheme() {
|
|
34
|
-
setTheme('dark')
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
</script>
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### getTheme()
|
|
42
|
-
|
|
43
|
-
获取当前主题配置。
|
|
44
|
-
|
|
45
|
-
```vue
|
|
46
|
-
<template>
|
|
47
|
-
<div>
|
|
48
|
-
<XtText>当前主题:{{ currentTheme }}</XtText>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<script>
|
|
53
|
-
import { getTheme } from 'xt-element-ui'
|
|
54
|
-
|
|
55
|
-
export default {
|
|
56
|
-
computed: {
|
|
57
|
-
currentTheme() {
|
|
58
|
-
return getTheme()
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
</script>
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## 主题对照表
|
|
66
|
-
|
|
67
|
-
| 主题 | 说明 |
|
|
68
|
-
|------|------|
|
|
69
|
-
| `white` | 亮色主题,适合日间使用(默认值) |
|
|
70
|
-
| `dark` | 暗色主题,适合夜间使用 |
|
|
71
|
-
|
|
72
|
-
## 使用示例
|
|
73
|
-
|
|
74
|
-
### 在组件安装时配置
|
|
75
|
-
|
|
76
|
-
```javascript
|
|
77
|
-
import XtElementUI from 'xt-element-ui'
|
|
78
|
-
|
|
79
|
-
Vue.use(XtElementUI, {
|
|
80
|
-
theme: 'dark' // 全局设置暗色主题
|
|
81
|
-
})
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 动态切换主题
|
|
85
|
-
|
|
86
|
-
```vue
|
|
87
|
-
<template>
|
|
88
|
-
<div>
|
|
89
|
-
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
90
|
-
<XtButton
|
|
91
|
-
v-for="theme in themes"
|
|
92
|
-
:key="theme"
|
|
93
|
-
:type="currentTheme === theme ? 'primary' : ''"
|
|
94
|
-
@click="changeTheme(theme)"
|
|
95
|
-
>
|
|
96
|
-
{{ themeLabels[theme] }}
|
|
97
|
-
</XtButton>
|
|
98
|
-
</XtFlexBox>
|
|
99
|
-
|
|
100
|
-
<XtCard>
|
|
101
|
-
<XtCardItem title="当前主题">
|
|
102
|
-
<XtText type="primary" bold>{{ themeLabels[currentTheme] }}</XtText>
|
|
103
|
-
</XtCardItem>
|
|
104
|
-
<XtCardItem title="主题状态">
|
|
105
|
-
<XtText :type="currentTheme === 'dark' ? 'warning' : 'success'">
|
|
106
|
-
{{ currentTheme === 'dark' ? '暗色模式已开启' : '亮色模式已开启' }}
|
|
107
|
-
</XtText>
|
|
108
|
-
</XtCardItem>
|
|
109
|
-
</XtCard>
|
|
110
|
-
</div>
|
|
111
|
-
</template>
|
|
112
|
-
|
|
113
|
-
<script>
|
|
114
|
-
import { setTheme, getTheme } from 'xt-element-ui'
|
|
115
|
-
|
|
116
|
-
export default {
|
|
117
|
-
data() {
|
|
118
|
-
return {
|
|
119
|
-
themes: ['white', 'dark'],
|
|
120
|
-
themeLabels: {
|
|
121
|
-
white: '亮色',
|
|
122
|
-
dark: '暗色'
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
computed: {
|
|
127
|
-
currentTheme() {
|
|
128
|
-
return getTheme()
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
methods: {
|
|
132
|
-
changeTheme(theme) {
|
|
133
|
-
setTheme(theme)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
</script>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### 监听主题变化
|
|
141
|
-
|
|
142
|
-
```vue
|
|
143
|
-
<template>
|
|
144
|
-
<div>
|
|
145
|
-
<XtText>主题变化次数:{{ changeCount }}</XtText>
|
|
146
|
-
</div>
|
|
147
|
-
</template>
|
|
148
|
-
|
|
149
|
-
<script>
|
|
150
|
-
import { onConfigChange } from 'xt-element-ui'
|
|
151
|
-
|
|
152
|
-
export default {
|
|
153
|
-
data() {
|
|
154
|
-
return {
|
|
155
|
-
changeCount: 0,
|
|
156
|
-
unsubscribe: null
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
mounted() {
|
|
160
|
-
// 监听主题变化
|
|
161
|
-
this.unsubscribe = onConfigChange((key, value) => {
|
|
162
|
-
if (key === 'theme') {
|
|
163
|
-
this.changeCount++
|
|
164
|
-
console.log('主题已切换为:', value)
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
},
|
|
168
|
-
beforeDestroy() {
|
|
169
|
-
// 取消监听
|
|
170
|
-
if (this.unsubscribe) {
|
|
171
|
-
this.unsubscribe()
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
</script>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## 注意事项
|
|
179
|
-
|
|
180
|
-
1. 主题切换会影响所有使用组件库样式的元素
|
|
181
|
-
2. 设置后会在 `html` 标签上添加/移除 `data-theme="dark"` 属性
|
|
182
|
-
3. 需要配合对应的暗色主题 CSS 样式才能生效
|
|
1
|
+
## 主题配置
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
通过工具函数可以全局设置主题模式,支持两种主题:`white`(亮色主题)和 `dark`(暗色主题)。
|
|
6
|
+
|
|
7
|
+
## 方法说明
|
|
8
|
+
|
|
9
|
+
### setTheme(theme)
|
|
10
|
+
|
|
11
|
+
设置全局主题。
|
|
12
|
+
|
|
13
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
14
|
+
|------|------|------|------|
|
|
15
|
+
| `theme` | String | 是 | 主题类型:`white`、`dark` |
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div>
|
|
20
|
+
<XtButton @click="setWhiteTheme">亮色主题</XtButton>
|
|
21
|
+
<XtButton @click="setDarkTheme">暗色主题</XtButton>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import { setTheme } from 'xt-element-ui'
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
methods: {
|
|
30
|
+
setWhiteTheme() {
|
|
31
|
+
setTheme('white')
|
|
32
|
+
},
|
|
33
|
+
setDarkTheme() {
|
|
34
|
+
setTheme('dark')
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### getTheme()
|
|
42
|
+
|
|
43
|
+
获取当前主题配置。
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<template>
|
|
47
|
+
<div>
|
|
48
|
+
<XtText>当前主题:{{ currentTheme }}</XtText>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import { getTheme } from 'xt-element-ui'
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
computed: {
|
|
57
|
+
currentTheme() {
|
|
58
|
+
return getTheme()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 主题对照表
|
|
66
|
+
|
|
67
|
+
| 主题 | 说明 |
|
|
68
|
+
|------|------|
|
|
69
|
+
| `white` | 亮色主题,适合日间使用(默认值) |
|
|
70
|
+
| `dark` | 暗色主题,适合夜间使用 |
|
|
71
|
+
|
|
72
|
+
## 使用示例
|
|
73
|
+
|
|
74
|
+
### 在组件安装时配置
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
import XtElementUI from 'xt-element-ui'
|
|
78
|
+
|
|
79
|
+
Vue.use(XtElementUI, {
|
|
80
|
+
theme: 'dark' // 全局设置暗色主题
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 动态切换主题
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<template>
|
|
88
|
+
<div>
|
|
89
|
+
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
90
|
+
<XtButton
|
|
91
|
+
v-for="theme in themes"
|
|
92
|
+
:key="theme"
|
|
93
|
+
:type="currentTheme === theme ? 'primary' : ''"
|
|
94
|
+
@click="changeTheme(theme)"
|
|
95
|
+
>
|
|
96
|
+
{{ themeLabels[theme] }}
|
|
97
|
+
</XtButton>
|
|
98
|
+
</XtFlexBox>
|
|
99
|
+
|
|
100
|
+
<XtCard>
|
|
101
|
+
<XtCardItem title="当前主题">
|
|
102
|
+
<XtText type="primary" bold>{{ themeLabels[currentTheme] }}</XtText>
|
|
103
|
+
</XtCardItem>
|
|
104
|
+
<XtCardItem title="主题状态">
|
|
105
|
+
<XtText :type="currentTheme === 'dark' ? 'warning' : 'success'">
|
|
106
|
+
{{ currentTheme === 'dark' ? '暗色模式已开启' : '亮色模式已开启' }}
|
|
107
|
+
</XtText>
|
|
108
|
+
</XtCardItem>
|
|
109
|
+
</XtCard>
|
|
110
|
+
</div>
|
|
111
|
+
</template>
|
|
112
|
+
|
|
113
|
+
<script>
|
|
114
|
+
import { setTheme, getTheme } from 'xt-element-ui'
|
|
115
|
+
|
|
116
|
+
export default {
|
|
117
|
+
data() {
|
|
118
|
+
return {
|
|
119
|
+
themes: ['white', 'dark'],
|
|
120
|
+
themeLabels: {
|
|
121
|
+
white: '亮色',
|
|
122
|
+
dark: '暗色'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
computed: {
|
|
127
|
+
currentTheme() {
|
|
128
|
+
return getTheme()
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
methods: {
|
|
132
|
+
changeTheme(theme) {
|
|
133
|
+
setTheme(theme)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 监听主题变化
|
|
141
|
+
|
|
142
|
+
```vue
|
|
143
|
+
<template>
|
|
144
|
+
<div>
|
|
145
|
+
<XtText>主题变化次数:{{ changeCount }}</XtText>
|
|
146
|
+
</div>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<script>
|
|
150
|
+
import { onConfigChange } from 'xt-element-ui'
|
|
151
|
+
|
|
152
|
+
export default {
|
|
153
|
+
data() {
|
|
154
|
+
return {
|
|
155
|
+
changeCount: 0,
|
|
156
|
+
unsubscribe: null
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
mounted() {
|
|
160
|
+
// 监听主题变化
|
|
161
|
+
this.unsubscribe = onConfigChange((key, value) => {
|
|
162
|
+
if (key === 'theme') {
|
|
163
|
+
this.changeCount++
|
|
164
|
+
console.log('主题已切换为:', value)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
},
|
|
168
|
+
beforeDestroy() {
|
|
169
|
+
// 取消监听
|
|
170
|
+
if (this.unsubscribe) {
|
|
171
|
+
this.unsubscribe()
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
</script>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 注意事项
|
|
179
|
+
|
|
180
|
+
1. 主题切换会影响所有使用组件库样式的元素
|
|
181
|
+
2. 设置后会在 `html` 标签上添加/移除 `data-theme="dark"` 属性
|
|
182
|
+
3. 需要配合对应的暗色主题 CSS 样式才能生效
|
|
183
183
|
4. 建议在应用初始化时设置主题,可以结合用户偏好存储(如 localStorage)
|