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
|
@@ -32,17 +32,6 @@ export default {
|
|
|
32
32
|
default: false
|
|
33
33
|
},
|
|
34
34
|
highlightKey: String,
|
|
35
|
-
config: {
|
|
36
|
-
type: Object,
|
|
37
|
-
default() {
|
|
38
|
-
return {
|
|
39
|
-
interval: 0,
|
|
40
|
-
rotate: 0,
|
|
41
|
-
gridbottom: 40,
|
|
42
|
-
isShowthreshold: false
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
35
|
chartData: {
|
|
47
36
|
type: Array,
|
|
48
37
|
default: () => {
|
|
@@ -227,16 +216,15 @@ export default {
|
|
|
227
216
|
}
|
|
228
217
|
},
|
|
229
218
|
grid: {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
bottom:
|
|
219
|
+
left: 16,
|
|
220
|
+
right: 16,
|
|
221
|
+
top: 40,
|
|
222
|
+
bottom: 48,
|
|
223
|
+
containLabel: true
|
|
234
224
|
},
|
|
235
225
|
xAxis: {
|
|
236
226
|
type: "category",
|
|
237
|
-
axisLabel: {
|
|
238
|
-
rotate: this.config.rotate
|
|
239
|
-
},
|
|
227
|
+
axisLabel: {},
|
|
240
228
|
data: firstSeriesData.map((item) => {
|
|
241
229
|
return item[keys.label];
|
|
242
230
|
})
|
|
@@ -267,6 +255,8 @@ export default {
|
|
|
267
255
|
name: item[keys.label],
|
|
268
256
|
type: item.type || "bar",
|
|
269
257
|
avoidLabelOverlap: true,
|
|
258
|
+
areaStyle: item.areaStyle ? {} : null,
|
|
259
|
+
smooth: item.smooth ? {} : false,
|
|
270
260
|
data: seriesItems.map(it => it[keys.value]),
|
|
271
261
|
yAxisIndex: unitToYAxisIndex[item.unit || ""] != null ? unitToYAxisIndex[item.unit || ""] : 0
|
|
272
262
|
};
|
|
@@ -7,16 +7,27 @@ const themeKeys = {
|
|
|
7
7
|
"dark": themeDark
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// 品牌色映射 - 用于 ECharts 图表调色板
|
|
11
|
+
const brandColors = {
|
|
12
|
+
"water": ["#0077be", "#0099cc", "#5DB1FF", "#005C91", "#003D61"],
|
|
13
|
+
"electricity": ["#2ecc71", "#27ae60", "#5DD3B0", "#22A85A", "#167039"],
|
|
14
|
+
"gas": ["#f39c12", "#e67e22", "#F5C976", "#C28500", "#8C6000"]
|
|
15
|
+
};
|
|
16
|
+
|
|
11
17
|
let echarts = null;
|
|
18
|
+
let themesRegistered = false;
|
|
12
19
|
|
|
13
20
|
function getEcharts() {
|
|
14
21
|
if (!echarts && typeof window !== 'undefined') {
|
|
15
22
|
try {
|
|
16
23
|
echarts = require('echarts');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
// 主题只注册一次
|
|
26
|
+
if (!themesRegistered) {
|
|
27
|
+
for (const key in themeKeys) {
|
|
28
|
+
echarts.registerTheme(key, themeKeys[key]);
|
|
29
|
+
}
|
|
30
|
+
themesRegistered = true;
|
|
20
31
|
}
|
|
21
32
|
} catch (e) {
|
|
22
33
|
console.warn('[XtChart] echarts 加载失败:', e.message);
|
|
@@ -59,6 +70,43 @@ EchartsUtil.currentTheme = "default";
|
|
|
59
70
|
EchartsUtil.currentSize = "medium";
|
|
60
71
|
EchartsUtil.inverse = false;
|
|
61
72
|
|
|
73
|
+
// 颜色处理工具方法
|
|
74
|
+
EchartsUtil.hexToRgb = function(hex) {
|
|
75
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
76
|
+
return result ? {
|
|
77
|
+
r: parseInt(result[1], 16),
|
|
78
|
+
g: parseInt(result[2], 16),
|
|
79
|
+
b: parseInt(result[3], 16)
|
|
80
|
+
} : null;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
EchartsUtil.rgbToHex = function(r, g, b) {
|
|
84
|
+
return '#' + [r, g, b].map(x => {
|
|
85
|
+
const hex = x.toString(16);
|
|
86
|
+
return hex.length === 1 ? '0' + hex : hex;
|
|
87
|
+
}).join('');
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
EchartsUtil.lightenColor = function(hex, percent) {
|
|
91
|
+
const rgb = this.hexToRgb(hex);
|
|
92
|
+
if (!rgb) return hex;
|
|
93
|
+
const ratio = percent / 100;
|
|
94
|
+
const r = Math.round(rgb.r * (1 - ratio) + 255 * ratio);
|
|
95
|
+
const g = Math.round(rgb.g * (1 - ratio) + 255 * ratio);
|
|
96
|
+
const b = Math.round(rgb.b * (1 - ratio) + 255 * ratio);
|
|
97
|
+
return this.rgbToHex(r, g, b);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
EchartsUtil.darkenColor = function(hex, percent) {
|
|
101
|
+
const rgb = this.hexToRgb(hex);
|
|
102
|
+
if (!rgb) return hex;
|
|
103
|
+
const ratio = percent / 100;
|
|
104
|
+
const r = Math.max(0, Math.round(rgb.r * (1 - ratio)));
|
|
105
|
+
const g = Math.max(0, Math.round(rgb.g * (1 - ratio)));
|
|
106
|
+
const b = Math.max(0, Math.round(rgb.b * (1 - ratio)));
|
|
107
|
+
return this.rgbToHex(r, g, b);
|
|
108
|
+
};
|
|
109
|
+
|
|
62
110
|
EchartsUtil.EchartsUtil = {
|
|
63
111
|
backgroundColor: "transparent",
|
|
64
112
|
tooltip: {
|
|
@@ -74,42 +122,11 @@ EchartsUtil.EchartsUtil = {
|
|
|
74
122
|
}
|
|
75
123
|
},
|
|
76
124
|
grid: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
bottom:
|
|
81
|
-
|
|
82
|
-
xAxis: {
|
|
83
|
-
type: "category",
|
|
84
|
-
boundaryGap: false,
|
|
85
|
-
axisTick: {
|
|
86
|
-
show: true,
|
|
87
|
-
length: 4
|
|
88
|
-
},
|
|
89
|
-
axisLabel: {
|
|
90
|
-
fontSize: 12,
|
|
91
|
-
interval: 0,
|
|
92
|
-
formatter: function(value) {
|
|
93
|
-
return !this.reverse && this.longLable ? value.replace(new RegExp(`(.{${this.longLableSplitNum}})`, "g"), `$1\n`) : value;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
yAxis: {
|
|
98
|
-
type: "value",
|
|
99
|
-
axisTick: {
|
|
100
|
-
show: false
|
|
101
|
-
},
|
|
102
|
-
min: null,
|
|
103
|
-
max: null,
|
|
104
|
-
axisLabel: {
|
|
105
|
-
show: false
|
|
106
|
-
},
|
|
107
|
-
splitLine: {
|
|
108
|
-
lineStyle: {
|
|
109
|
-
type: "dashed",
|
|
110
|
-
width: 1
|
|
111
|
-
}
|
|
112
|
-
}
|
|
125
|
+
left: 16,
|
|
126
|
+
right: 16,
|
|
127
|
+
top: 40,
|
|
128
|
+
bottom: 48,
|
|
129
|
+
containLabel: true
|
|
113
130
|
}
|
|
114
131
|
};
|
|
115
132
|
|
|
@@ -358,11 +375,13 @@ EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
|
358
375
|
this.currentTheme = useTheme;
|
|
359
376
|
this.currentSize = useSize;
|
|
360
377
|
|
|
361
|
-
|
|
378
|
+
// 使用基础选项配置作为 option 模板
|
|
379
|
+
// 主题已通过 ec.init(dom, useTheme) 应用,这里不需要再使用 themeOption
|
|
380
|
+
let baseOption = JSON.parse(JSON.stringify(EchartsUtil.EchartsUtil));
|
|
362
381
|
// 应用字体大小配置
|
|
363
|
-
|
|
382
|
+
baseOption = this.applyFontSize(baseOption, useSize);
|
|
364
383
|
|
|
365
|
-
const option = this.mergeOptions(
|
|
384
|
+
const option = this.mergeOptions(baseOption, customOption);
|
|
366
385
|
|
|
367
386
|
const chart = ec.init(dom, useTheme);
|
|
368
387
|
chart.setOption(option, true);
|
|
@@ -401,12 +420,11 @@ EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme)
|
|
|
401
420
|
return newChart;
|
|
402
421
|
};
|
|
403
422
|
|
|
404
|
-
EchartsUtil.changeAllTheme = function(newTheme, newSize) {
|
|
423
|
+
EchartsUtil.changeAllTheme = function(newTheme, newSize, primaryColor, brand) {
|
|
405
424
|
const ec = getEcharts();
|
|
406
425
|
if (!ec || !newTheme) return;
|
|
407
426
|
|
|
408
427
|
this.currentTheme = newTheme;
|
|
409
|
-
// 如果传入了新的 size,则更新全局 size
|
|
410
428
|
if (newSize) {
|
|
411
429
|
this.currentSize = newSize;
|
|
412
430
|
}
|
|
@@ -415,7 +433,6 @@ EchartsUtil.changeAllTheme = function(newTheme, newSize) {
|
|
|
415
433
|
const dom = item.dom;
|
|
416
434
|
const chart = item.chart;
|
|
417
435
|
const customOption = item.customOption;
|
|
418
|
-
// 使用图表自己的 size,如果没有则使用全局 size
|
|
419
436
|
const useSize = item.size || EchartsUtil.currentSize;
|
|
420
437
|
|
|
421
438
|
if (chart) {
|
|
@@ -423,14 +440,31 @@ EchartsUtil.changeAllTheme = function(newTheme, newSize) {
|
|
|
423
440
|
}
|
|
424
441
|
|
|
425
442
|
const newChart = ec.init(dom, newTheme);
|
|
426
|
-
|
|
443
|
+
|
|
444
|
+
// 使用基础选项配置(EchartsUtil.EchartsUtil)作为 option 模板
|
|
445
|
+
let baseOption = JSON.parse(JSON.stringify(EchartsUtil.EchartsUtil));
|
|
446
|
+
|
|
427
447
|
// 应用字体大小配置
|
|
428
|
-
|
|
429
|
-
|
|
448
|
+
baseOption = EchartsUtil.applyFontSize(baseOption, useSize);
|
|
449
|
+
|
|
450
|
+
// 应用品牌色到图表调色板
|
|
451
|
+
if (brand && brandColors[brand]) {
|
|
452
|
+
baseOption.color = brandColors[brand];
|
|
453
|
+
} else if (primaryColor) {
|
|
454
|
+
// 如果没有品牌色但有自定义主色,生成衍生色系
|
|
455
|
+
baseOption.color = [
|
|
456
|
+
primaryColor,
|
|
457
|
+
EchartsUtil.lightenColor(primaryColor, 30),
|
|
458
|
+
EchartsUtil.lightenColor(primaryColor, 50),
|
|
459
|
+
EchartsUtil.darkenColor(primaryColor, 20),
|
|
460
|
+
EchartsUtil.darkenColor(primaryColor, 40)
|
|
461
|
+
];
|
|
462
|
+
}
|
|
430
463
|
|
|
464
|
+
const option = EchartsUtil.mergeOptions(baseOption, customOption);
|
|
465
|
+
console.log('option1', option);
|
|
431
466
|
newChart.setOption(option, true);
|
|
432
467
|
item.chart = newChart;
|
|
433
|
-
// 更新图表的 size 记录
|
|
434
468
|
item.size = useSize;
|
|
435
469
|
EchartsUtil.bindResize(newChart);
|
|
436
470
|
});
|
|
@@ -7,71 +7,67 @@ const HTMLElementType = typeof HTMLElement !== 'undefined' ? HTMLElement : Objec
|
|
|
7
7
|
export default {
|
|
8
8
|
name: 'XtConfigProvider',
|
|
9
9
|
inheritAttrs: false,
|
|
10
|
-
|
|
10
|
+
data() {
|
|
11
11
|
return {
|
|
12
12
|
xtConfig: {
|
|
13
13
|
theme: this.theme,
|
|
14
14
|
size: this.size,
|
|
15
|
-
primaryColor: this.primaryColor
|
|
15
|
+
primaryColor: this.primaryColor,
|
|
16
|
+
brand: this.brand
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
},
|
|
20
|
+
provide() {
|
|
21
|
+
return {
|
|
22
|
+
xtConfig: this.xtConfig
|
|
23
|
+
}
|
|
24
|
+
},
|
|
19
25
|
watch: {
|
|
20
26
|
theme(newVal) {
|
|
21
|
-
this.xtConfig =
|
|
22
|
-
|
|
23
|
-
size: this.size,
|
|
24
|
-
primaryColor: this.primaryColor
|
|
25
|
-
}
|
|
27
|
+
this.xtConfig.theme = newVal
|
|
28
|
+
this.updateConfig()
|
|
26
29
|
},
|
|
27
30
|
size(newVal) {
|
|
28
|
-
this.xtConfig =
|
|
29
|
-
|
|
30
|
-
size: this.size,
|
|
31
|
-
primaryColor: this.primaryColor
|
|
32
|
-
}
|
|
31
|
+
this.xtConfig.size = newVal
|
|
32
|
+
this.updateConfig()
|
|
33
33
|
},
|
|
34
34
|
primaryColor(newVal) {
|
|
35
|
-
this.xtConfig =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
this.xtConfig.primaryColor = newVal
|
|
36
|
+
this.updateConfig()
|
|
37
|
+
},
|
|
38
|
+
brand(newVal) {
|
|
39
|
+
this.xtConfig.brand = newVal
|
|
40
|
+
this.updateConfig()
|
|
40
41
|
}
|
|
41
42
|
},
|
|
42
43
|
render(h) {
|
|
43
|
-
|
|
44
|
-
// 如果设置了 proxyElement,则不渲染包裹元素,只渲染 slot 内容
|
|
45
|
-
if (this.tag === 'template' || this.proxyElement) {
|
|
46
|
-
// 渲染 slot 内容,如果只有一个元素则直接返回,否则包裹一个 div
|
|
47
|
-
const slotContent = this.$slots.default
|
|
44
|
+
const slotContent = this.$slots.default
|
|
48
45
|
|
|
46
|
+
if (this.tag === 'template' || this.proxyElement) {
|
|
49
47
|
if (!slotContent || slotContent.length === 0) {
|
|
50
48
|
return h('div')
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
// 如果 slot 只有一个元素,直接返回该元素
|
|
54
51
|
if (slotContent.length === 1) {
|
|
55
52
|
return slotContent[0]
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
// Vue 2 不支持多根节点,需要包裹一个 div
|
|
59
|
-
// 使用普通的 div 包裹,避免 display: contents 的兼容性问题
|
|
60
55
|
return h('div', {
|
|
61
56
|
class: 'xt-config-provider-wrapper',
|
|
62
57
|
attrs: {
|
|
63
|
-
'data-theme': this.theme
|
|
58
|
+
'data-theme': this.theme,
|
|
59
|
+
'data-brand': this.brand
|
|
64
60
|
}
|
|
65
61
|
}, slotContent)
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
// 正常渲染包裹元素
|
|
69
64
|
return h(this.tag, {
|
|
70
65
|
style: this.mergedStyle,
|
|
71
66
|
class: this.computedClass,
|
|
72
67
|
attrs: {
|
|
73
68
|
...this.customAttrs,
|
|
74
|
-
'data-theme': this.theme
|
|
69
|
+
'data-theme': this.theme,
|
|
70
|
+
'data-brand': this.brand
|
|
75
71
|
}
|
|
76
72
|
}, this.$slots.default)
|
|
77
73
|
},
|
|
@@ -85,12 +81,22 @@ export default {
|
|
|
85
81
|
},
|
|
86
82
|
size: {
|
|
87
83
|
type: String,
|
|
88
|
-
default: 'medium'
|
|
84
|
+
default: 'medium',
|
|
85
|
+
validator: (value) => {
|
|
86
|
+
return ['small', 'medium', 'large'].includes(value)
|
|
87
|
+
}
|
|
89
88
|
},
|
|
90
89
|
primaryColor: {
|
|
91
90
|
type: String,
|
|
92
91
|
default: '#1890ff'
|
|
93
92
|
},
|
|
93
|
+
brand: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: '',
|
|
96
|
+
validator: (value) => {
|
|
97
|
+
return ['', 'water', 'electricity', 'gas'].includes(value)
|
|
98
|
+
}
|
|
99
|
+
},
|
|
94
100
|
vars: {
|
|
95
101
|
type: Object,
|
|
96
102
|
default: () => ({})
|
|
@@ -118,12 +124,12 @@ export default {
|
|
|
118
124
|
onThemeChange: {
|
|
119
125
|
type: Function,
|
|
120
126
|
default: null,
|
|
121
|
-
description: '主题改变时的钩子函数,接收参数: { theme, size, primaryColor }'
|
|
127
|
+
description: '主题改变时的钩子函数,接收参数: { theme, size, primaryColor, brand }'
|
|
122
128
|
},
|
|
123
129
|
onStyleApplied: {
|
|
124
130
|
type: Function,
|
|
125
131
|
default: null,
|
|
126
|
-
description: '样式应用完成时的钩子函数,接收参数: { element, style, theme }'
|
|
132
|
+
description: '样式应用完成时的钩子函数,接收参数: { element, style, theme, brand }'
|
|
127
133
|
}
|
|
128
134
|
},
|
|
129
135
|
computed: {
|
|
@@ -133,13 +139,11 @@ export default {
|
|
|
133
139
|
if (this.primaryColor) {
|
|
134
140
|
const color = this.normalizeColor(this.primaryColor)
|
|
135
141
|
result['--xt-color-primary'] = color
|
|
136
|
-
// 浅色系列(与 css-variables.scss 保持一致)
|
|
137
142
|
result['--xt-color-primary-light-3'] = this.lightenColor(color, 30)
|
|
138
143
|
result['--xt-color-primary-light-5'] = this.lightenColor(color, 50)
|
|
139
144
|
result['--xt-color-primary-light-7'] = this.lightenColor(color, 70)
|
|
140
145
|
result['--xt-color-primary-light-8'] = this.lightenColor(color, 80)
|
|
141
146
|
result['--xt-color-primary-light-9'] = this.lightenColor(color, 90)
|
|
142
|
-
// 深色系列
|
|
143
147
|
result['--xt-color-primary-dark-2'] = this.darkenColor(color, 20)
|
|
144
148
|
}
|
|
145
149
|
|
|
@@ -154,18 +158,17 @@ export default {
|
|
|
154
158
|
|
|
155
159
|
if (this.theme === 'dark') {
|
|
156
160
|
if (this.injectBackground) {
|
|
157
|
-
result.backgroundColor = result['--xt-
|
|
161
|
+
result.backgroundColor = result['--xt-bg-color'] || '#141414'
|
|
158
162
|
}
|
|
159
163
|
if (this.injectColor) {
|
|
160
|
-
result.color = result['--xt-color-
|
|
164
|
+
result.color = result['--xt-text-color-primary'] || '#E5EAF3'
|
|
161
165
|
}
|
|
162
166
|
} else {
|
|
163
|
-
// 恢复默认主题颜色(light 主题)
|
|
164
167
|
if (this.injectBackground) {
|
|
165
|
-
result.backgroundColor = result['--xt-
|
|
168
|
+
result.backgroundColor = result['--xt-bg-color'] || '#ffffff'
|
|
166
169
|
}
|
|
167
170
|
if (this.injectColor) {
|
|
168
|
-
result.color = result['--xt-color-
|
|
171
|
+
result.color = result['--xt-text-color-primary'] || '#303133'
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
|
|
@@ -181,7 +184,7 @@ export default {
|
|
|
181
184
|
return classes
|
|
182
185
|
},
|
|
183
186
|
customAttrs() {
|
|
184
|
-
const props = ['theme', 'size', 'primaryColor', 'vars', 'tag', 'injectBackground', 'injectColor', 'proxyElement']
|
|
187
|
+
const props = ['theme', 'size', 'primaryColor', 'brand', 'vars', 'tag', 'injectBackground', 'injectColor', 'proxyElement']
|
|
185
188
|
const attrs = {}
|
|
186
189
|
|
|
187
190
|
for (const key in this.$attrs) {
|
|
@@ -203,6 +206,10 @@ export default {
|
|
|
203
206
|
this.clearProxyElementStyle()
|
|
204
207
|
},
|
|
205
208
|
methods: {
|
|
209
|
+
updateConfig() {
|
|
210
|
+
this.applyProxyElementStyle()
|
|
211
|
+
},
|
|
212
|
+
|
|
206
213
|
normalizeColor(color) {
|
|
207
214
|
if (!color) return '#1890ff'
|
|
208
215
|
|
|
@@ -250,8 +257,6 @@ export default {
|
|
|
250
257
|
const rgb = this.hexToRgb(hex)
|
|
251
258
|
if (!rgb) return hex
|
|
252
259
|
|
|
253
|
-
// 使用与 Element Plus 一致的算法:将颜色与白色按比例混合
|
|
254
|
-
// percent 表示混合白色的比例(0-100),即 (1 - percent/100) 是原色比例
|
|
255
260
|
const ratio = percent / 100
|
|
256
261
|
const r = Math.round(rgb.r * (1 - ratio) + 255 * ratio)
|
|
257
262
|
const g = Math.round(rgb.g * (1 - ratio) + 255 * ratio)
|
|
@@ -264,8 +269,6 @@ export default {
|
|
|
264
269
|
const rgb = this.hexToRgb(hex)
|
|
265
270
|
if (!rgb) return hex
|
|
266
271
|
|
|
267
|
-
// 使用按比例混合黑色的方式变暗
|
|
268
|
-
// percent 表示混合黑色的比例(0-100)
|
|
269
272
|
const ratio = percent / 100
|
|
270
273
|
const r = Math.max(0, Math.round(rgb.r * (1 - ratio)))
|
|
271
274
|
const g = Math.max(0, Math.round(rgb.g * (1 - ratio)))
|
|
@@ -305,36 +308,36 @@ export default {
|
|
|
305
308
|
|
|
306
309
|
const style = this.mergedStyle
|
|
307
310
|
const prevTheme = element.getAttribute('data-theme')
|
|
311
|
+
const prevBrand = element.getAttribute('data-brand')
|
|
308
312
|
|
|
309
|
-
// 应用样式到代理元素
|
|
310
313
|
for (const key in style) {
|
|
311
314
|
element.style.setProperty(key, style[key])
|
|
312
315
|
}
|
|
313
316
|
|
|
314
|
-
// 设置 data-theme 属性
|
|
315
317
|
element.setAttribute('data-theme', this.theme)
|
|
318
|
+
element.setAttribute('data-brand', this.brand)
|
|
316
319
|
|
|
317
|
-
|
|
318
|
-
EchartsUtil.changeAllTheme(this.theme, this.size, this.primaryColor)
|
|
320
|
+
EchartsUtil.changeAllTheme(this.theme, this.size, this.primaryColor, this.brand)
|
|
319
321
|
|
|
320
|
-
// 触发主题改变钩子(当主题实际发生变化时)
|
|
321
322
|
if (prevTheme !== this.theme && typeof this.onThemeChange === 'function') {
|
|
322
323
|
this.onThemeChange({
|
|
323
324
|
theme: this.theme,
|
|
324
325
|
size: this.size,
|
|
325
326
|
primaryColor: this.primaryColor,
|
|
326
|
-
|
|
327
|
+
brand: this.brand,
|
|
328
|
+
prevTheme: prevTheme,
|
|
329
|
+
prevBrand: prevBrand
|
|
327
330
|
})
|
|
328
331
|
}
|
|
329
332
|
|
|
330
|
-
// 触发样式应用完成钩子
|
|
331
333
|
if (typeof this.onStyleApplied === 'function') {
|
|
332
334
|
this.onStyleApplied({
|
|
333
335
|
element: element,
|
|
334
336
|
style: style,
|
|
335
337
|
theme: this.theme,
|
|
336
338
|
size: this.size,
|
|
337
|
-
primaryColor: this.primaryColor
|
|
339
|
+
primaryColor: this.primaryColor,
|
|
340
|
+
brand: this.brand
|
|
338
341
|
})
|
|
339
342
|
}
|
|
340
343
|
|
|
@@ -350,17 +353,16 @@ export default {
|
|
|
350
353
|
element.style.removeProperty(key)
|
|
351
354
|
}
|
|
352
355
|
|
|
353
|
-
// 移除 data-theme 属性
|
|
354
356
|
element.removeAttribute('data-theme')
|
|
357
|
+
element.removeAttribute('data-brand')
|
|
355
358
|
}
|
|
356
359
|
}
|
|
357
360
|
}
|
|
358
361
|
</script>
|
|
359
362
|
|
|
360
363
|
<style scoped>
|
|
361
|
-
/* 包裹容器样式 - 最小化影响布局 */
|
|
362
364
|
.xt-config-provider-wrapper {
|
|
363
365
|
width: 100%;
|
|
364
366
|
height: 100%;
|
|
365
367
|
}
|
|
366
|
-
</style>
|
|
368
|
+
</style>
|
|
@@ -1,12 +1 @@
|
|
|
1
1
|
@import '../../../styles/variables.scss';
|
|
2
|
-
|
|
3
|
-
.xt-config-provider {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.xt-config-provider--dark {
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.xt-config-provider--dark {
|
|
10
|
-
background-color: var(--xt-color-bg-primary, #0b141d);
|
|
11
|
-
color: var(--xt-color-text-primary, rgba(255, 255, 255, 0.95));
|
|
12
|
-
}
|
|
@@ -105,32 +105,4 @@
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
</script>
|
|
109
|
-
<style scoped>
|
|
110
|
-
.range-picker {
|
|
111
|
-
display: flex;
|
|
112
|
-
align-items: center;
|
|
113
|
-
flex-wrap: wrap;
|
|
114
|
-
gap: 8px;
|
|
115
|
-
width: 100%;
|
|
116
|
-
}
|
|
117
|
-
.range-picker .el-date-editor {
|
|
118
|
-
flex: 1;
|
|
119
|
-
min-width: 130px;
|
|
120
|
-
}
|
|
121
|
-
.split {
|
|
122
|
-
flex-shrink: 0;
|
|
123
|
-
padding: 0 4px;
|
|
124
|
-
}
|
|
125
|
-
/* 手机/窄侧边栏自动竖向排列 */
|
|
126
|
-
@media (max-width: 360px) {
|
|
127
|
-
.range-picker {
|
|
128
|
-
flex-direction: column;
|
|
129
|
-
align-items: stretch;
|
|
130
|
-
}
|
|
131
|
-
.split {
|
|
132
|
-
text-align: center;
|
|
133
|
-
margin: 4px 0;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
</style>
|
|
108
|
+
</script>
|