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,86 +1,86 @@
|
|
|
1
|
-
@import './theme/index.scss';
|
|
2
|
-
|
|
3
|
-
// SCSS 变量导出给 JavaScript 使用
|
|
4
|
-
:export {
|
|
5
|
-
// ===========================
|
|
6
|
-
// 主色调系列
|
|
7
|
-
// ===========================
|
|
8
|
-
xtColorPrimary: #{$xt-color-primary}; // 主颜色 - Element UI 标准蓝色
|
|
9
|
-
xtColorSuccess: #{$xt-color-success}; // 成功色 - Element UI 标准绿色
|
|
10
|
-
xtColorWarning: #{$xt-color-warning}; // 警告色 - Element UI 标准橙色
|
|
11
|
-
xtColorDanger: #{$xt-color-danger}; // 危险色 - Element UI 标准红色
|
|
12
|
-
xtColorInfo: #{$xt-color-info}; // 信息色 - Element UI 标准灰色
|
|
13
|
-
|
|
14
|
-
// 主色调浅色系列
|
|
15
|
-
xtColorPrimaryLight3: #{$xt-color-primary-light-3}; // 主色浅色 30%
|
|
16
|
-
xtColorPrimaryLight5: #{$xt-color-primary-light-5}; // 主色浅色 50%
|
|
17
|
-
xtColorPrimaryLight7: #{$xt-color-primary-light-7}; // 主色浅色 70%
|
|
18
|
-
xtColorPrimaryLight8: #{$xt-color-primary-light-8}; // 主色浅色 80%
|
|
19
|
-
xtColorPrimaryLight9: #{$xt-color-primary-light-9}; // 主色浅色 90%
|
|
20
|
-
|
|
21
|
-
// ===========================
|
|
22
|
-
// 文字颜色
|
|
23
|
-
// ===========================
|
|
24
|
-
xtColorTextPrimary: #{$xt-color-text-primary}; // 主要文字颜色 - 最深
|
|
25
|
-
xtColorTextRegular: #{$xt-color-text-regular}; // 常规文字颜色 - 中等
|
|
26
|
-
xtColorTextSecondary: #{$xt-color-text-secondary}; // 次要文字颜色 - 较浅
|
|
27
|
-
xtColorTextPlaceholder: #{$xt-color-text-placeholder}; // 占位符文字颜色
|
|
28
|
-
xtColorTextDisabled: #{$xt-color-text-disabled}; // 禁用状态文字颜色
|
|
29
|
-
|
|
30
|
-
// ===========================
|
|
31
|
-
// 背景颜色
|
|
32
|
-
// ===========================
|
|
33
|
-
xtColorBgPrimary: #{$xt-color-bg-primary}; // 主背景色 - 白色
|
|
34
|
-
xtColorBgSecondary: #{$xt-color-bg-secondary}; // 次要背景色 - 浅灰
|
|
35
|
-
xtColorBgHover: #{$xt-color-bg-hover}; // 悬停背景色
|
|
36
|
-
xtColorBgContainer: #{$xt-color-bg-container}; // 容器背景色
|
|
37
|
-
xtColorBgOverlay: #{$xt-color-bg-overlay}; // 浮层背景色
|
|
38
|
-
|
|
39
|
-
// ===========================
|
|
40
|
-
// 边框颜色
|
|
41
|
-
// ===========================
|
|
42
|
-
xtColorBorder: #{$xt-color-border}; // 边框颜色 - 标准
|
|
43
|
-
xtColorBorderLight: #{$xt-color-border-light}; // 边框浅色
|
|
44
|
-
xtColorBorderLighter: #{$xt-color-border-lighter}; // 边框更浅色
|
|
45
|
-
xtColorBorderExtraLight: #{$xt-color-border-extra-light}; // 边框极浅色
|
|
46
|
-
|
|
47
|
-
// ===========================
|
|
48
|
-
// 字体大小
|
|
49
|
-
// ===========================
|
|
50
|
-
xtFontSizeExtraLarge: #{$xt-font-size-extra-large}; // 特大字体
|
|
51
|
-
xtFontSizeLarge: #{$xt-font-size-large}; // 大字体
|
|
52
|
-
xtFontSizeMedium: #{$xt-font-size-medium}; // 中等字体
|
|
53
|
-
xtFontSizeBase: #{$xt-font-size-base}; // 基准字体
|
|
54
|
-
xtFontSizeSmall: #{$xt-font-size-small}; // 小字体
|
|
55
|
-
xtFontSizeExtraSmall: #{$xt-font-size-extra-small}; // 特小字体
|
|
56
|
-
|
|
57
|
-
// ===========================
|
|
58
|
-
// 间距
|
|
59
|
-
// ===========================
|
|
60
|
-
xtSpacingXs: #{$xt-spacing-xs}; // 最小间距
|
|
61
|
-
xtSpacingSm: #{$xt-spacing-sm}; // 小间距
|
|
62
|
-
xtSpacingMd: #{$xt-spacing-md}; // 中间距
|
|
63
|
-
xtSpacingLg: #{$xt-spacing-lg}; // 大间距
|
|
64
|
-
xtSpacingXl: #{$xt-spacing-xl}; // 特大间距
|
|
65
|
-
|
|
66
|
-
// ===========================
|
|
67
|
-
// 圆角
|
|
68
|
-
// ===========================
|
|
69
|
-
xtBorderRadiusBase: #{$xt-border-radius-base}; // 基准圆角
|
|
70
|
-
xtBorderRadiusSmall: #{$xt-border-radius-small}; // 小圆角
|
|
71
|
-
xtBorderRadiusRound: #{$xt-border-radius-round}; // 圆角(胶囊状)
|
|
72
|
-
xtBorderRadiusCircle: #{$xt-border-radius-circle}; // 圆形
|
|
73
|
-
|
|
74
|
-
// ===========================
|
|
75
|
-
// 阴影
|
|
76
|
-
// ===========================
|
|
77
|
-
xtShadowSm: #{$xt-shadow-sm}; // 小阴影
|
|
78
|
-
xtShadowMd: #{$xt-shadow-md}; // 中等阴影
|
|
79
|
-
xtShadowLg: #{$xt-shadow-lg}; // 大阴影
|
|
80
|
-
|
|
81
|
-
// ===========================
|
|
82
|
-
// 过渡动画
|
|
83
|
-
// ===========================
|
|
84
|
-
xtTransitionDuration: #{$xt-transition-duration}; // 默认过渡时长
|
|
85
|
-
xtTransitionDurationFast: #{$xt-transition-duration-fast}; // 快速过渡时长
|
|
1
|
+
@import './theme/index.scss';
|
|
2
|
+
|
|
3
|
+
// SCSS 变量导出给 JavaScript 使用
|
|
4
|
+
:export {
|
|
5
|
+
// ===========================
|
|
6
|
+
// 主色调系列
|
|
7
|
+
// ===========================
|
|
8
|
+
xtColorPrimary: #{$xt-color-primary}; // 主颜色 - Element UI 标准蓝色
|
|
9
|
+
xtColorSuccess: #{$xt-color-success}; // 成功色 - Element UI 标准绿色
|
|
10
|
+
xtColorWarning: #{$xt-color-warning}; // 警告色 - Element UI 标准橙色
|
|
11
|
+
xtColorDanger: #{$xt-color-danger}; // 危险色 - Element UI 标准红色
|
|
12
|
+
xtColorInfo: #{$xt-color-info}; // 信息色 - Element UI 标准灰色
|
|
13
|
+
|
|
14
|
+
// 主色调浅色系列
|
|
15
|
+
xtColorPrimaryLight3: #{$xt-color-primary-light-3}; // 主色浅色 30%
|
|
16
|
+
xtColorPrimaryLight5: #{$xt-color-primary-light-5}; // 主色浅色 50%
|
|
17
|
+
xtColorPrimaryLight7: #{$xt-color-primary-light-7}; // 主色浅色 70%
|
|
18
|
+
xtColorPrimaryLight8: #{$xt-color-primary-light-8}; // 主色浅色 80%
|
|
19
|
+
xtColorPrimaryLight9: #{$xt-color-primary-light-9}; // 主色浅色 90%
|
|
20
|
+
|
|
21
|
+
// ===========================
|
|
22
|
+
// 文字颜色
|
|
23
|
+
// ===========================
|
|
24
|
+
xtColorTextPrimary: #{$xt-color-text-primary}; // 主要文字颜色 - 最深
|
|
25
|
+
xtColorTextRegular: #{$xt-color-text-regular}; // 常规文字颜色 - 中等
|
|
26
|
+
xtColorTextSecondary: #{$xt-color-text-secondary}; // 次要文字颜色 - 较浅
|
|
27
|
+
xtColorTextPlaceholder: #{$xt-color-text-placeholder}; // 占位符文字颜色
|
|
28
|
+
xtColorTextDisabled: #{$xt-color-text-disabled}; // 禁用状态文字颜色
|
|
29
|
+
|
|
30
|
+
// ===========================
|
|
31
|
+
// 背景颜色
|
|
32
|
+
// ===========================
|
|
33
|
+
xtColorBgPrimary: #{$xt-color-bg-primary}; // 主背景色 - 白色
|
|
34
|
+
xtColorBgSecondary: #{$xt-color-bg-secondary}; // 次要背景色 - 浅灰
|
|
35
|
+
xtColorBgHover: #{$xt-color-bg-hover}; // 悬停背景色
|
|
36
|
+
xtColorBgContainer: #{$xt-color-bg-container}; // 容器背景色
|
|
37
|
+
xtColorBgOverlay: #{$xt-color-bg-overlay}; // 浮层背景色
|
|
38
|
+
|
|
39
|
+
// ===========================
|
|
40
|
+
// 边框颜色
|
|
41
|
+
// ===========================
|
|
42
|
+
xtColorBorder: #{$xt-color-border}; // 边框颜色 - 标准
|
|
43
|
+
xtColorBorderLight: #{$xt-color-border-light}; // 边框浅色
|
|
44
|
+
xtColorBorderLighter: #{$xt-color-border-lighter}; // 边框更浅色
|
|
45
|
+
xtColorBorderExtraLight: #{$xt-color-border-extra-light}; // 边框极浅色
|
|
46
|
+
|
|
47
|
+
// ===========================
|
|
48
|
+
// 字体大小
|
|
49
|
+
// ===========================
|
|
50
|
+
xtFontSizeExtraLarge: #{$xt-font-size-extra-large}; // 特大字体
|
|
51
|
+
xtFontSizeLarge: #{$xt-font-size-large}; // 大字体
|
|
52
|
+
xtFontSizeMedium: #{$xt-font-size-medium}; // 中等字体
|
|
53
|
+
xtFontSizeBase: #{$xt-font-size-base}; // 基准字体
|
|
54
|
+
xtFontSizeSmall: #{$xt-font-size-small}; // 小字体
|
|
55
|
+
xtFontSizeExtraSmall: #{$xt-font-size-extra-small}; // 特小字体
|
|
56
|
+
|
|
57
|
+
// ===========================
|
|
58
|
+
// 间距
|
|
59
|
+
// ===========================
|
|
60
|
+
xtSpacingXs: #{$xt-spacing-xs}; // 最小间距
|
|
61
|
+
xtSpacingSm: #{$xt-spacing-sm}; // 小间距
|
|
62
|
+
xtSpacingMd: #{$xt-spacing-md}; // 中间距
|
|
63
|
+
xtSpacingLg: #{$xt-spacing-lg}; // 大间距
|
|
64
|
+
xtSpacingXl: #{$xt-spacing-xl}; // 特大间距
|
|
65
|
+
|
|
66
|
+
// ===========================
|
|
67
|
+
// 圆角
|
|
68
|
+
// ===========================
|
|
69
|
+
xtBorderRadiusBase: #{$xt-border-radius-base}; // 基准圆角
|
|
70
|
+
xtBorderRadiusSmall: #{$xt-border-radius-small}; // 小圆角
|
|
71
|
+
xtBorderRadiusRound: #{$xt-border-radius-round}; // 圆角(胶囊状)
|
|
72
|
+
xtBorderRadiusCircle: #{$xt-border-radius-circle}; // 圆形
|
|
73
|
+
|
|
74
|
+
// ===========================
|
|
75
|
+
// 阴影
|
|
76
|
+
// ===========================
|
|
77
|
+
xtShadowSm: #{$xt-shadow-sm}; // 小阴影
|
|
78
|
+
xtShadowMd: #{$xt-shadow-md}; // 中等阴影
|
|
79
|
+
xtShadowLg: #{$xt-shadow-lg}; // 大阴影
|
|
80
|
+
|
|
81
|
+
// ===========================
|
|
82
|
+
// 过渡动画
|
|
83
|
+
// ===========================
|
|
84
|
+
xtTransitionDuration: #{$xt-transition-duration}; // 默认过渡时长
|
|
85
|
+
xtTransitionDurationFast: #{$xt-transition-duration-fast}; // 快速过渡时长
|
|
86
86
|
}
|
package/src/utils/index.js
CHANGED
|
@@ -1,202 +1,191 @@
|
|
|
1
|
-
import EchartsUtil from '../components/ex-chart/utils'
|
|
2
|
-
|
|
3
|
-
const defaultConfig = {
|
|
4
|
-
theme: 'white',
|
|
5
|
-
size: 'medium',
|
|
6
|
-
primaryColor: '#1890ff'
|
|
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
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
setTheme,
|
|
193
|
-
setSize,
|
|
194
|
-
setPrimaryColor,
|
|
195
|
-
getConfig,
|
|
196
|
-
setConfig,
|
|
197
|
-
getTheme,
|
|
198
|
-
getSize,
|
|
199
|
-
getPrimaryColor,
|
|
200
|
-
resetConfig,
|
|
201
|
-
onConfigChange
|
|
202
|
-
}
|
|
1
|
+
import EchartsUtil from '../components/ex-chart/utils'
|
|
2
|
+
|
|
3
|
+
const defaultConfig = {
|
|
4
|
+
theme: 'white',
|
|
5
|
+
size: 'medium',
|
|
6
|
+
primaryColor: '#1890ff'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let currentConfig = { ...defaultConfig }
|
|
10
|
+
|
|
11
|
+
const configChangeListeners = []
|
|
12
|
+
|
|
13
|
+
const emitConfigChange = function(key, value) {
|
|
14
|
+
configChangeListeners.forEach(listener => {
|
|
15
|
+
listener(key, value)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const getConfig = function() {
|
|
20
|
+
return { ...currentConfig }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const setConfig = function(config) {
|
|
24
|
+
if (typeof config !== 'object' || config === null) {
|
|
25
|
+
console.warn('[XtElementUI] setConfig 必须传入对象参数')
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (config.theme !== undefined) {
|
|
30
|
+
setTheme(config.theme)
|
|
31
|
+
}
|
|
32
|
+
if (config.size !== undefined) {
|
|
33
|
+
setSize(config.size)
|
|
34
|
+
}
|
|
35
|
+
if (config.primaryColor !== undefined) {
|
|
36
|
+
setPrimaryColor(config.primaryColor)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isBrowser() {
|
|
41
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const setTheme = function(theme) {
|
|
45
|
+
const validThemes = ['white', 'dark']
|
|
46
|
+
if (!validThemes.includes(theme)) {
|
|
47
|
+
console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
currentConfig.theme = theme
|
|
52
|
+
|
|
53
|
+
if (isBrowser()) {
|
|
54
|
+
const root = document.documentElement
|
|
55
|
+
|
|
56
|
+
if (theme === 'dark') {
|
|
57
|
+
root.setAttribute('data-theme', 'dark')
|
|
58
|
+
} else {
|
|
59
|
+
root.setAttribute('data-theme', theme)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
EchartsUtil.changeAllTheme(currentConfig.theme, currentConfig.size)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
emitConfigChange('theme', theme)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const setSize = function(size) {
|
|
69
|
+
const validSizes = ['small', 'medium', 'large']
|
|
70
|
+
if (!validSizes.includes(size)) {
|
|
71
|
+
console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
currentConfig.size = size
|
|
76
|
+
|
|
77
|
+
if (isBrowser()) {
|
|
78
|
+
document.documentElement.setAttribute('data-size', size)
|
|
79
|
+
EchartsUtil.changeAllTheme(currentConfig.theme, currentConfig.size)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
emitConfigChange('size', size)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 将十六进制颜色转换为 RGB 对象
|
|
86
|
+
function hexToRgb(hex) {
|
|
87
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
|
|
88
|
+
return result ? {
|
|
89
|
+
r: parseInt(result[1], 16),
|
|
90
|
+
g: parseInt(result[2], 16),
|
|
91
|
+
b: parseInt(result[3], 16)
|
|
92
|
+
} : null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 将 RGB 对象转换为十六进制颜色
|
|
96
|
+
function rgbToHex(r, g, b) {
|
|
97
|
+
return '#' + [r, g, b].map(x => {
|
|
98
|
+
const hex = x.toString(16)
|
|
99
|
+
return hex.length === 1 ? '0' + hex : hex
|
|
100
|
+
}).join('')
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 计算浅色系列(混合白色)
|
|
104
|
+
function lightenColor(hex, percent) {
|
|
105
|
+
const rgb = hexToRgb(hex)
|
|
106
|
+
if (!rgb) return hex
|
|
107
|
+
|
|
108
|
+
const amount = Math.round(2.55 * percent)
|
|
109
|
+
const r = Math.min(255, rgb.r + amount)
|
|
110
|
+
const g = Math.min(255, rgb.g + amount)
|
|
111
|
+
const b = Math.min(255, rgb.b + amount)
|
|
112
|
+
|
|
113
|
+
return rgbToHex(r, g, b)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const setPrimaryColor = function(color) {
|
|
117
|
+
const colorRegex = /^#[0-9A-Fa-f]{3}$|^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{8}$/
|
|
118
|
+
if (!colorRegex.test(color)) {
|
|
119
|
+
console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let validColor = color
|
|
124
|
+
if (color.length === 4) {
|
|
125
|
+
validColor = '#' + color[1] + color[1] + color[2] + color[2] + color[3] + color[3]
|
|
126
|
+
} else if (color.length === 9) {
|
|
127
|
+
validColor = color.substring(0, 7)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
currentConfig.primaryColor = validColor
|
|
131
|
+
|
|
132
|
+
if (isBrowser()) {
|
|
133
|
+
document.documentElement.style.setProperty('--xt-color-primary', validColor)
|
|
134
|
+
|
|
135
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-3', lightenColor(validColor, 30))
|
|
136
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-5', lightenColor(validColor, 50))
|
|
137
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-7', lightenColor(validColor, 70))
|
|
138
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-8', lightenColor(validColor, 80))
|
|
139
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-9', lightenColor(validColor, 90))
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
emitConfigChange('primaryColor', validColor)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 获取当前主题
|
|
146
|
+
export const getTheme = function() {
|
|
147
|
+
return currentConfig.theme
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 获取当前字体大小
|
|
151
|
+
export const getSize = function() {
|
|
152
|
+
return currentConfig.size
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 获取当前主色调
|
|
156
|
+
export const getPrimaryColor = function() {
|
|
157
|
+
return currentConfig.primaryColor
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 重置为默认配置
|
|
161
|
+
export const resetConfig = function() {
|
|
162
|
+
setConfig(defaultConfig)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 监听配置变更
|
|
166
|
+
export const onConfigChange = function(listener) {
|
|
167
|
+
if (typeof listener === 'function') {
|
|
168
|
+
configChangeListeners.push(listener)
|
|
169
|
+
return function() {
|
|
170
|
+
const index = configChangeListeners.indexOf(listener)
|
|
171
|
+
if (index > -1) {
|
|
172
|
+
configChangeListeners.splice(index, 1)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
console.warn('[XtElementUI] onConfigChange 必须传入函数')
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default {
|
|
181
|
+
setTheme,
|
|
182
|
+
setSize,
|
|
183
|
+
setPrimaryColor,
|
|
184
|
+
getConfig,
|
|
185
|
+
setConfig,
|
|
186
|
+
getTheme,
|
|
187
|
+
getSize,
|
|
188
|
+
getPrimaryColor,
|
|
189
|
+
resetConfig,
|
|
190
|
+
onConfigChange
|
|
191
|
+
}
|