xt-element-ui 2.2.2 → 2.2.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/README.md +140 -192
- package/docs/README.md +162 -81
- package/docs/components/base/theme.md +248 -0
- package/docs/components/base/xt-button.md +11 -4
- package/docs/components/base/xt-card.md +5 -11
- package/docs/components/base/xt-config-provider.md +2 -0
- package/docs/components/base/xt-flow.md +404 -0
- package/docs/components/base/xt-list.md +1 -1
- package/docs/components/base/xt-multi.md +5 -5
- package/docs/components/base/xt-scroll-arrow.md +87 -1
- package/docs/components/base/xt-scroll.md +237 -0
- package/docs/components/business/xt-chart.md +1 -0
- package/docs/components/utils/config.md +18 -4
- package/docs/components/utils/theme.md +280 -183
- package/lib/index.common.1.js +4 -26
- package/lib/index.common.2.js +1 -1
- package/lib/index.common.js +4577 -109925
- package/lib/index.css +1 -1
- package/lib/index.umd.1.js +4 -26
- package/lib/index.umd.2.js +1 -1
- package/lib/index.umd.js +4583 -109930
- package/lib/index.umd.min.1.js +1 -1
- package/lib/index.umd.min.js +1 -1
- package/lib/theme/element-overrides.css +607 -0
- package/lib/theme/element-vars.css +280 -0
- package/lib/xt-badge/xt-badge.common.js +1 -1
- package/lib/xt-badge/xt-badge.css +1 -1
- package/lib/xt-badge/xt-badge.umd.js +1 -1
- package/lib/xt-button/xt-button.common.js +13 -8
- package/lib/xt-button/xt-button.css +1 -1
- package/lib/xt-button/xt-button.umd.js +13 -8
- package/lib/xt-button/xt-button.umd.min.js +1 -1
- package/lib/xt-card/xt-card.common.js +5 -5
- package/lib/xt-card/xt-card.umd.js +5 -5
- package/lib/xt-card/xt-card.umd.min.js +1 -1
- package/lib/xt-card-item/xt-card-item.common.js +4 -4
- package/lib/xt-card-item/xt-card-item.umd.js +4 -4
- package/lib/xt-card-item/xt-card-item.umd.min.js +1 -1
- package/lib/xt-chart/xt-chart.common.js +1969 -108924
- package/lib/xt-chart/xt-chart.css +1 -1
- package/lib/xt-chart/xt-chart.umd.js +1975 -108929
- package/lib/xt-chart/xt-chart.umd.min.js +1 -1
- package/lib/xt-config-provider/xt-config-provider.common.js +561 -107504
- package/lib/xt-config-provider/xt-config-provider.css +1 -1
- package/lib/xt-config-provider/xt-config-provider.umd.js +567 -107509
- package/lib/xt-config-provider/xt-config-provider.umd.min.js +1 -1
- package/lib/xt-date-picker/xt-date-picker.common.1.js +4 -26
- package/lib/xt-date-picker/xt-date-picker.common.2.js +1 -1
- package/lib/xt-date-picker/xt-date-picker.common.js +1 -47
- package/lib/xt-date-picker/xt-date-picker.css +1 -1
- package/lib/xt-date-picker/xt-date-picker.umd.1.js +4 -26
- package/lib/xt-date-picker/xt-date-picker.umd.2.js +1 -1
- package/lib/xt-date-picker/xt-date-picker.umd.js +1 -47
- package/lib/xt-date-picker/xt-date-picker.umd.min.1.js +1 -1
- package/lib/xt-date-picker/xt-date-picker.umd.min.js +1 -1
- package/lib/xt-flex-box/xt-flex-box.common.js +1 -1
- package/lib/xt-flex-box/xt-flex-box.umd.js +1 -1
- package/lib/xt-flow/demo.html +10 -0
- package/lib/xt-flow/index.js +1 -0
- package/lib/xt-flow/xt-flow.common.js +638 -0
- package/lib/xt-flow/xt-flow.css +1 -0
- package/lib/xt-flow/xt-flow.umd.js +648 -0
- package/lib/xt-flow/xt-flow.umd.min.js +1 -0
- package/lib/xt-form-schema/xt-form-schema.common.js +1 -1
- package/lib/xt-form-schema/xt-form-schema.umd.js +1 -1
- package/lib/xt-grid-box/xt-grid-box.common.js +1 -1
- package/lib/xt-grid-box/xt-grid-box.umd.js +1 -1
- package/lib/xt-grid-item/xt-grid-item.common.js +1 -1
- package/lib/xt-grid-item/xt-grid-item.umd.js +1 -1
- package/lib/xt-icon/xt-icon.common.js +1 -1
- package/lib/xt-icon/xt-icon.umd.js +1 -1
- package/lib/xt-input/xt-input.common.js +1 -1
- package/lib/xt-input/xt-input.umd.js +1 -1
- package/lib/xt-list/xt-list.common.js +457 -118
- package/lib/xt-list/xt-list.css +1 -1
- package/lib/xt-list/xt-list.umd.js +457 -118
- package/lib/xt-list/xt-list.umd.min.js +1 -1
- package/lib/xt-map/xt-map.common.js +1 -1
- package/lib/xt-map/xt-map.umd.js +1 -1
- package/lib/xt-map-provider/xt-map-provider.common.js +1 -1
- package/lib/xt-map-provider/xt-map-provider.umd.js +1 -1
- package/lib/xt-page/xt-page.common.js +1 -1
- package/lib/xt-page/xt-page.umd.js +1 -1
- package/lib/xt-progress/xt-progress.common.js +1 -1
- package/lib/xt-progress/xt-progress.umd.js +1 -1
- package/lib/xt-scroll/demo.html +10 -0
- package/lib/xt-scroll/index.js +1 -0
- package/lib/xt-scroll/xt-scroll.common.js +551 -0
- package/lib/xt-scroll/xt-scroll.css +1 -0
- package/lib/xt-scroll/xt-scroll.umd.js +561 -0
- package/lib/xt-scroll/xt-scroll.umd.min.js +1 -0
- package/lib/xt-scroll-arrow/xt-scroll-arrow.common.js +591 -170
- package/lib/xt-scroll-arrow/xt-scroll-arrow.css +1 -1
- package/lib/xt-scroll-arrow/xt-scroll-arrow.umd.js +591 -170
- package/lib/xt-scroll-arrow/xt-scroll-arrow.umd.min.js +1 -1
- package/lib/xt-select-tree/xt-select-tree.common.js +1 -1
- package/lib/xt-select-tree/xt-select-tree.umd.js +1 -1
- package/lib/xt-step-price/xt-step-price.common.js +2 -2
- package/lib/xt-step-price/xt-step-price.umd.js +2 -2
- package/lib/xt-step-price-item/xt-step-price-item.common.js +1 -1
- package/lib/xt-step-price-item/xt-step-price-item.umd.js +1 -1
- package/lib/xt-tab-pane/xt-tab-pane.common.js +1 -1
- package/lib/xt-tab-pane/xt-tab-pane.umd.js +1 -1
- package/lib/xt-table/xt-table.common.js +2 -2
- package/lib/xt-table/xt-table.umd.js +2 -2
- package/lib/xt-tabs/xt-tabs.common.js +1 -1
- package/lib/xt-tabs/xt-tabs.umd.js +1 -1
- package/lib/xt-text/xt-text.common.js +1 -1
- package/lib/xt-text/xt-text.css +1 -1
- package/lib/xt-text/xt-text.umd.js +1 -1
- package/lib/xt-time/xt-time.common.js +1 -1
- package/lib/xt-time/xt-time.umd.js +1 -1
- package/lib/xt-transfer-tree/xt-transfer-tree.common.js +1 -1
- package/lib/xt-transfer-tree/xt-transfer-tree.umd.js +1 -1
- package/lib/xt-upload/xt-upload.common.js +11 -11
- package/lib/xt-upload/xt-upload.umd.js +12 -12
- package/lib/xt-upload/xt-upload.umd.min.js +1 -1
- package/package.json +6 -5
- package/src/components/index.scss +7 -1
- package/src/components/theme/element-overrides.css +607 -0
- package/src/components/theme/element-vars.css +280 -0
- package/src/components/theme/iframe-injector.js +502 -0
- package/src/components/theme/index.js +64 -0
- package/src/components/xt-badge/style/index.scss +6 -6
- package/src/components/xt-button/index.vue +11 -6
- package/src/components/xt-button/style/index.scss +7 -5
- package/src/components/xt-card/index.vue +3 -3
- package/src/components/xt-card-item/index.vue +2 -2
- package/src/components/xt-chart/XtMulti.vue +8 -18
- package/src/components/xt-chart/XtPie.vue +1 -0
- package/src/components/xt-chart/utils.js +84 -50
- package/src/components/xt-config-provider/index.vue +56 -54
- package/src/components/xt-config-provider/style/index.scss +0 -11
- package/src/components/xt-date-picker/component/RangeDate.vue +1 -29
- package/src/components/xt-date-picker/style/index.scss +79 -54
- package/src/components/xt-flow/flowable-parser.js +244 -0
- package/src/components/xt-flow/index.js +8 -0
- package/src/components/xt-flow/index.vue +226 -0
- package/src/components/xt-flow/style/index.scss +359 -0
- package/src/components/xt-list/index.vue +23 -12
- package/src/components/xt-scroll/index.js +9 -0
- package/src/components/xt-scroll/index.vue +363 -0
- package/src/components/xt-scroll/style/index.scss +107 -0
- package/src/components/xt-scroll-arrow/index.vue +200 -83
- package/src/components/xt-scroll-arrow/style/index.scss +16 -5
- package/src/components/xt-text/style/index.scss +6 -6
- package/src/index.js +15 -13
- package/src/styles/css-variables.scss +73 -1
- package/src/utils/color.js +105 -0
- package/src/utils/index.js +456 -468
- package/src/utils/theme-vars.js +134 -0
- package/lib/css/1.87a493be.css +0 -1
- package/lib/xt-date-picker/css/1.87a493be.css +0 -1
|
@@ -1,183 +1,280 @@
|
|
|
1
|
-
## 主题配置
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
通过工具函数可以全局设置主题模式,支持两种主题:`white`(亮色主题)和 `dark`(暗色主题)。
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
</
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
1
|
+
## 主题配置
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
通过工具函数可以全局设置主题模式,支持两种主题:`white`(亮色主题)和 `dark`(暗色主题)。
|
|
6
|
+
|
|
7
|
+
主题系统采用统一的 CSS 变量架构,主题切换时会**同时设置两套变量**:
|
|
8
|
+
|
|
9
|
+
| 变量前缀 | 用途 |
|
|
10
|
+
|----------|------|
|
|
11
|
+
| `--el-*` | 覆盖 Element UI 组件样式 |
|
|
12
|
+
| `--xt-*` | xt-element-ui 自定义组件样式 |
|
|
13
|
+
|
|
14
|
+
两套变量保持同步,确保 Element UI 原生组件和 xt 组件在主题切换时表现一致。
|
|
15
|
+
|
|
16
|
+
## 架构说明
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
┌─────────────────────────────────────────────┐
|
|
20
|
+
│ utils/theme-vars.js │
|
|
21
|
+
│ ┌─────────────────────────────────────┐ │
|
|
22
|
+
│ │ applyThemeVars(element, config) │ │ ← 唯一事实源
|
|
23
|
+
│ │ - LIGHT_THEME_VARS / DARK_THEME_VARS│ │
|
|
24
|
+
│ │ - BRAND_COLORS │ │
|
|
25
|
+
│ └─────────────────────────────────────┘ │
|
|
26
|
+
└─────────────────────────────────────────────┘
|
|
27
|
+
▲ ▲
|
|
28
|
+
│ 调用 │ 调用
|
|
29
|
+
┌─────────┴──────┐ ┌───────┴────────────┐
|
|
30
|
+
│ utils/index.js │ │ theme/iframe- │
|
|
31
|
+
│ setTheme() │ │ injector.js │
|
|
32
|
+
│ setPrimaryColor()│ │ iframe 主题同步 │
|
|
33
|
+
└─────────────────┘ └────────────────────┘
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 方法说明
|
|
37
|
+
|
|
38
|
+
### setTheme(theme)
|
|
39
|
+
|
|
40
|
+
设置全局主题,同时更新 `--el-*` 和 `--xt-*` 两套 CSS 变量。
|
|
41
|
+
|
|
42
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
43
|
+
|------|------|------|------|
|
|
44
|
+
| `theme` | String | 是 | 主题类型:`white`、`dark` |
|
|
45
|
+
|
|
46
|
+
```vue
|
|
47
|
+
<template>
|
|
48
|
+
<div>
|
|
49
|
+
<XtButton @click="setWhiteTheme">亮色主题</XtButton>
|
|
50
|
+
<XtButton @click="setDarkTheme">暗色主题</XtButton>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
import { setTheme } from 'xt-element-ui'
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
methods: {
|
|
59
|
+
setWhiteTheme() {
|
|
60
|
+
setTheme('white')
|
|
61
|
+
},
|
|
62
|
+
setDarkTheme() {
|
|
63
|
+
setTheme('dark')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**内部行为**:
|
|
71
|
+
1. 调用 `applyThemeVars()` 设置 `--el-*` 主题变量(主色、背景、文字、边框等)
|
|
72
|
+
2. 设置 `--xt-*` 组件主色变量
|
|
73
|
+
3. 在 `<html>` 上设置 `data-theme` 属性
|
|
74
|
+
4. 同步更新 ECharts 图表主题
|
|
75
|
+
|
|
76
|
+
### getTheme()
|
|
77
|
+
|
|
78
|
+
获取当前主题配置。
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<template>
|
|
82
|
+
<div>
|
|
83
|
+
<XtText>当前主题:{{ currentTheme }}</XtText>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script>
|
|
88
|
+
import { getTheme } from 'xt-element-ui'
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
computed: {
|
|
92
|
+
currentTheme() {
|
|
93
|
+
return getTheme()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### setPrimaryColor(color)
|
|
101
|
+
|
|
102
|
+
设置全局主色调,同时更新 `--el-color-primary*` 和 `--xt-color-primary*` 变量。
|
|
103
|
+
|
|
104
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
105
|
+
|------|------|------|------|
|
|
106
|
+
| `color` | String | 是 | 十六进制颜色值,如 `#1890ff` |
|
|
107
|
+
|
|
108
|
+
```vue
|
|
109
|
+
<template>
|
|
110
|
+
<div>
|
|
111
|
+
<XtButton @click="changePrimary('#ff5722')">橙色主题</XtButton>
|
|
112
|
+
<XtButton @click="changePrimary('#4caf50')">绿色主题</XtButton>
|
|
113
|
+
</div>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script>
|
|
117
|
+
import { setPrimaryColor } from 'xt-element-ui'
|
|
118
|
+
|
|
119
|
+
export default {
|
|
120
|
+
methods: {
|
|
121
|
+
changePrimary(color) {
|
|
122
|
+
setPrimaryColor(color)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</script>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**自动衍生变量**:设置主色后会自动生成以下变量:
|
|
130
|
+
|
|
131
|
+
| 变量 | 说明 |
|
|
132
|
+
|------|------|
|
|
133
|
+
| `--el-color-primary` | 主色 |
|
|
134
|
+
| `--el-color-primary-light-3` | 主色 +30% 亮度 |
|
|
135
|
+
| `--el-color-primary-light-5` | 主色 +50% 亮度 |
|
|
136
|
+
| `--el-color-primary-light-7` | 主色 +70% 亮度 |
|
|
137
|
+
| `--el-color-primary-light-8` | 主色 +80% 亮度 |
|
|
138
|
+
| `--el-color-primary-light-9` | 主色 +90% 亮度 |
|
|
139
|
+
| `--el-color-primary-dark-2` | 主色 -20% 亮度 |
|
|
140
|
+
| `--el-color-primary-rgb` | 主色 RGB 值 |
|
|
141
|
+
|
|
142
|
+
## 主题对照表
|
|
143
|
+
|
|
144
|
+
| 主题 | 说明 |
|
|
145
|
+
|------|------|
|
|
146
|
+
| `white` | 亮色主题,适合日间使用(默认值) |
|
|
147
|
+
| `dark` | 暗色主题,适合夜间使用 |
|
|
148
|
+
|
|
149
|
+
## 使用示例
|
|
150
|
+
|
|
151
|
+
### 在组件安装时配置
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
import XtElementUI from 'xt-element-ui'
|
|
155
|
+
|
|
156
|
+
Vue.use(XtElementUI, {
|
|
157
|
+
theme: 'dark' // 全局设置暗色主题
|
|
158
|
+
})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 动态切换主题
|
|
162
|
+
|
|
163
|
+
```vue
|
|
164
|
+
<template>
|
|
165
|
+
<div>
|
|
166
|
+
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
167
|
+
<XtButton
|
|
168
|
+
v-for="theme in themes"
|
|
169
|
+
:key="theme"
|
|
170
|
+
:type="currentTheme === theme ? 'primary' : ''"
|
|
171
|
+
@click="changeTheme(theme)"
|
|
172
|
+
>
|
|
173
|
+
{{ themeLabels[theme] }}
|
|
174
|
+
</XtButton>
|
|
175
|
+
</XtFlexBox>
|
|
176
|
+
|
|
177
|
+
<XtCard>
|
|
178
|
+
<XtCardItem title="当前主题">
|
|
179
|
+
<XtText type="primary" bold>{{ themeLabels[currentTheme] }}</XtText>
|
|
180
|
+
</XtCardItem>
|
|
181
|
+
<XtCardItem title="主题状态">
|
|
182
|
+
<XtText :type="currentTheme === 'dark' ? 'warning' : 'success'">
|
|
183
|
+
{{ currentTheme === 'dark' ? '暗色模式已开启' : '亮色模式已开启' }}
|
|
184
|
+
</XtText>
|
|
185
|
+
</XtCardItem>
|
|
186
|
+
</XtCard>
|
|
187
|
+
</div>
|
|
188
|
+
</template>
|
|
189
|
+
|
|
190
|
+
<script>
|
|
191
|
+
import { setTheme, getTheme } from 'xt-element-ui'
|
|
192
|
+
|
|
193
|
+
export default {
|
|
194
|
+
data() {
|
|
195
|
+
return {
|
|
196
|
+
themes: ['white', 'dark'],
|
|
197
|
+
themeLabels: {
|
|
198
|
+
white: '亮色',
|
|
199
|
+
dark: '暗色'
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
computed: {
|
|
204
|
+
currentTheme() {
|
|
205
|
+
return getTheme()
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
methods: {
|
|
209
|
+
changeTheme(theme) {
|
|
210
|
+
setTheme(theme)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
</script>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 监听主题变化
|
|
218
|
+
|
|
219
|
+
```vue
|
|
220
|
+
<template>
|
|
221
|
+
<div>
|
|
222
|
+
<XtText>主题变化次数:{{ changeCount }}</XtText>
|
|
223
|
+
</div>
|
|
224
|
+
</template>
|
|
225
|
+
|
|
226
|
+
<script>
|
|
227
|
+
import { onConfigChange } from 'xt-element-ui'
|
|
228
|
+
|
|
229
|
+
export default {
|
|
230
|
+
data() {
|
|
231
|
+
return {
|
|
232
|
+
changeCount: 0,
|
|
233
|
+
unsubscribe: null
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
mounted() {
|
|
237
|
+
// 监听主题变化
|
|
238
|
+
this.unsubscribe = onConfigChange((key, value) => {
|
|
239
|
+
if (key === 'theme') {
|
|
240
|
+
this.changeCount++
|
|
241
|
+
console.log('主题已切换为:', value)
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
},
|
|
245
|
+
beforeDestroy() {
|
|
246
|
+
// 取消监听
|
|
247
|
+
if (this.unsubscribe) {
|
|
248
|
+
this.unsubscribe()
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
</script>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### 微前端架构(iframe 场景)
|
|
256
|
+
|
|
257
|
+
主系统切换主题后,子系统 iframe 中的 Element UI 组件会自动同步换色。详细用法参见 [iframe 主题注入](#/base/theme)。
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
// 主系统
|
|
261
|
+
import { setTheme } from 'xt-element-ui'
|
|
262
|
+
import { createThemeInjector } from 'xt-element-ui'
|
|
263
|
+
|
|
264
|
+
// 1. 创建注入器
|
|
265
|
+
const injector = createThemeInjector({ theme: 'white' })
|
|
266
|
+
|
|
267
|
+
// 2. 注入现有 iframe
|
|
268
|
+
injector.injectAll('iframe')
|
|
269
|
+
|
|
270
|
+
// 3. 切换主题(自动同步到所有 iframe)
|
|
271
|
+
setTheme('dark')
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## 注意事项
|
|
275
|
+
|
|
276
|
+
1. 主题切换会影响所有使用组件库样式的元素
|
|
277
|
+
2. 设置后会在 `html` 标签上添加/移除 `data-theme="dark"` 属性
|
|
278
|
+
3. `setTheme` 和 `setPrimaryColor` 会**同时设置** `--el-*` 和 `--xt-*` 两套变量
|
|
279
|
+
4. 建议在应用初始化时设置主题,可以结合用户偏好存储(如 localStorage)
|
|
280
|
+
5. 微前端架构下,主系统通过 `createThemeInjector` 可实现 iframe 自动同步
|
package/lib/index.common.1.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
((typeof self !== 'undefined' ? self : this)["webpackJsonpindex"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpindex"] || []).push([[1,2],{
|
|
2
2
|
|
|
3
|
-
/***/ "0e3e":
|
|
4
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_RangeDate_vue_vue_type_style_index_0_id_32b85e82_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("16dd");
|
|
8
|
-
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_RangeDate_vue_vue_type_style_index_0_id_32b85e82_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_RangeDate_vue_vue_type_style_index_0_id_32b85e82_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0__);
|
|
9
|
-
/* unused harmony reexport * */
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/***/ }),
|
|
13
|
-
|
|
14
|
-
/***/ "16dd":
|
|
15
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
16
|
-
|
|
17
|
-
// extracted by mini-css-extract-plugin
|
|
18
|
-
|
|
19
|
-
/***/ }),
|
|
20
|
-
|
|
21
3
|
/***/ "1db3":
|
|
22
4
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
23
5
|
|
|
@@ -25,13 +7,13 @@
|
|
|
25
7
|
// ESM COMPAT FLAG
|
|
26
8
|
__webpack_require__.r(__webpack_exports__);
|
|
27
9
|
|
|
28
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"
|
|
10
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"1d9e3ae5-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-date-picker/component/RangeDate.vue?vue&type=template&id=a698fa3e
|
|
29
11
|
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"range-picker"},[_c('Picker',{attrs:{"type":_vm.type,"size":"small","placeholder":_vm.startPlaceholder,"disabled":_vm.disabled,"disabled-date":_vm.disabledStart},on:{"change":_vm.handleChange},model:{value:(_vm.startVal),callback:function ($$v) {_vm.startVal=$$v},expression:"startVal"}}),_c('span',{staticClass:"split"},[_vm._v(_vm._s(_vm.separator))]),_c('Picker',{attrs:{"type":_vm.type,"size":"small","placeholder":_vm.endPlaceholder,"disabled":_vm.disabled,"disabled-date":_vm.disabledEnd},on:{"change":_vm.handleChange},model:{value:(_vm.endVal),callback:function ($$v) {_vm.endVal=$$v},expression:"endVal"}})],1)
|
|
30
12
|
}
|
|
31
13
|
var staticRenderFns = []
|
|
32
14
|
|
|
33
15
|
|
|
34
|
-
// CONCATENATED MODULE: ./src/components/xt-date-picker/component/RangeDate.vue?vue&type=template&id=
|
|
16
|
+
// CONCATENATED MODULE: ./src/components/xt-date-picker/component/RangeDate.vue?vue&type=template&id=a698fa3e
|
|
35
17
|
|
|
36
18
|
// EXTERNAL MODULE: ./src/components/xt-date-picker/component/Picker.vue + 4 modules
|
|
37
19
|
var Picker = __webpack_require__("b0ea");
|
|
@@ -123,9 +105,6 @@ var Picker = __webpack_require__("b0ea");
|
|
|
123
105
|
|
|
124
106
|
// CONCATENATED MODULE: ./src/components/xt-date-picker/component/RangeDate.vue?vue&type=script&lang=js
|
|
125
107
|
/* harmony default export */ var component_RangeDatevue_type_script_lang_js = (RangeDatevue_type_script_lang_js);
|
|
126
|
-
// EXTERNAL MODULE: ./src/components/xt-date-picker/component/RangeDate.vue?vue&type=style&index=0&id=32b85e82&prod&scoped=true&lang=css
|
|
127
|
-
var RangeDatevue_type_style_index_0_id_32b85e82_prod_scoped_true_lang_css = __webpack_require__("0e3e");
|
|
128
|
-
|
|
129
108
|
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
130
109
|
var componentNormalizer = __webpack_require__("2877");
|
|
131
110
|
|
|
@@ -135,7 +114,6 @@ var componentNormalizer = __webpack_require__("2877");
|
|
|
135
114
|
|
|
136
115
|
|
|
137
116
|
|
|
138
|
-
|
|
139
117
|
/* normalize component */
|
|
140
118
|
|
|
141
119
|
var component = Object(componentNormalizer["a" /* default */])(
|
|
@@ -144,7 +122,7 @@ var component = Object(componentNormalizer["a" /* default */])(
|
|
|
144
122
|
staticRenderFns,
|
|
145
123
|
false,
|
|
146
124
|
null,
|
|
147
|
-
|
|
125
|
+
null,
|
|
148
126
|
null
|
|
149
127
|
|
|
150
128
|
)
|
|
@@ -160,7 +138,7 @@ var component = Object(componentNormalizer["a" /* default */])(
|
|
|
160
138
|
// ESM COMPAT FLAG
|
|
161
139
|
__webpack_require__.r(__webpack_exports__);
|
|
162
140
|
|
|
163
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"
|
|
141
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"1d9e3ae5-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-date-picker/component/Picker.vue?vue&type=template&id=4a866a03
|
|
164
142
|
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"date-picker"},[(_vm.type !== 'quarter')?_c('el-date-picker',_vm._g(_vm._b({attrs:{"type":_vm.pickerType,"value-format":_vm.valueFormat,"disabled":_vm.disabled,"placeholder":_vm.placeholder,"popper-append-to-body":"","popper-class":"base-date-popper"},model:{value:(_vm.innerValue),callback:function ($$v) {_vm.innerValue=$$v},expression:"innerValue"}},'el-date-picker',_vm.$attrs,false),_vm.$listeners)):_c('el-popover',{attrs:{"trigger":"manual","placement":"bottom-start","width":"240"},model:{value:(_vm.quarterPopVisible),callback:function ($$v) {_vm.quarterPopVisible=$$v},expression:"quarterPopVisible"}},[_c('div',{staticClass:"quarter-panel"},[_c('div',{staticClass:"quarter-header"},[_c('el-button',{attrs:{"icon":"el-icon-d-arrow-left"},on:{"click":function($event){_vm.year--}}}),_c('span',[_vm._v(_vm._s(_vm.year)+" 年")]),_c('el-button',{attrs:{"icon":"el-icon-d-arrow-right"},on:{"click":function($event){_vm.year++}}})],1),_c('div',{staticClass:"quarter-list"},_vm._l((4),function(q){return _c('div',{key:q,staticClass:"quarter-item",class:{ active: _vm.quarterNum === q },on:{"click":function($event){return _vm.selectQuarter(q)}}},[_vm._v(" Q"+_vm._s(q)+" ")])}),0)]),_c('el-input',{ref:"quarterInput",attrs:{"slot":"reference","size":"small","readonly":"","placeholder":_vm.placeholder,"disabled":_vm.disabled,"clearable":""},on:{"clear":_vm.handleClearQuarter},slot:"reference",model:{value:(_vm.quarterShowText),callback:function ($$v) {_vm.quarterShowText=$$v},expression:"quarterShowText"}},[_c('i',{staticClass:"el-icon-date",attrs:{"slot":"affix"},slot:"affix"})])],1)],1)
|
|
165
143
|
}
|
|
166
144
|
var staticRenderFns = []
|
package/lib/index.common.2.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ESM COMPAT FLAG
|
|
8
8
|
__webpack_require__.r(__webpack_exports__);
|
|
9
9
|
|
|
10
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"
|
|
10
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"1d9e3ae5-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-date-picker/component/Picker.vue?vue&type=template&id=4a866a03
|
|
11
11
|
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"date-picker"},[(_vm.type !== 'quarter')?_c('el-date-picker',_vm._g(_vm._b({attrs:{"type":_vm.pickerType,"value-format":_vm.valueFormat,"disabled":_vm.disabled,"placeholder":_vm.placeholder,"popper-append-to-body":"","popper-class":"base-date-popper"},model:{value:(_vm.innerValue),callback:function ($$v) {_vm.innerValue=$$v},expression:"innerValue"}},'el-date-picker',_vm.$attrs,false),_vm.$listeners)):_c('el-popover',{attrs:{"trigger":"manual","placement":"bottom-start","width":"240"},model:{value:(_vm.quarterPopVisible),callback:function ($$v) {_vm.quarterPopVisible=$$v},expression:"quarterPopVisible"}},[_c('div',{staticClass:"quarter-panel"},[_c('div',{staticClass:"quarter-header"},[_c('el-button',{attrs:{"icon":"el-icon-d-arrow-left"},on:{"click":function($event){_vm.year--}}}),_c('span',[_vm._v(_vm._s(_vm.year)+" 年")]),_c('el-button',{attrs:{"icon":"el-icon-d-arrow-right"},on:{"click":function($event){_vm.year++}}})],1),_c('div',{staticClass:"quarter-list"},_vm._l((4),function(q){return _c('div',{key:q,staticClass:"quarter-item",class:{ active: _vm.quarterNum === q },on:{"click":function($event){return _vm.selectQuarter(q)}}},[_vm._v(" Q"+_vm._s(q)+" ")])}),0)]),_c('el-input',{ref:"quarterInput",attrs:{"slot":"reference","size":"small","readonly":"","placeholder":_vm.placeholder,"disabled":_vm.disabled,"clearable":""},on:{"clear":_vm.handleClearQuarter},slot:"reference",model:{value:(_vm.quarterShowText),callback:function ($$v) {_vm.quarterShowText=$$v},expression:"quarterShowText"}},[_c('i',{staticClass:"el-icon-date",attrs:{"slot":"affix"},slot:"affix"})])],1)],1)
|
|
12
12
|
}
|
|
13
13
|
var staticRenderFns = []
|