@mc-markets/ui 1.0.0 → 1.0.2
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 +441 -329
- package/USAGE.md +383 -0
- package/dist/index-36fc8778.js +5 -0
- package/dist/index.js +2 -23
- package/dist/packages/components/Dialog/index.vue.d.ts +4 -4
- package/dist/packages/index.d.ts +154 -19
- package/dist/packages/styles/theme-config.d.ts +83 -0
- package/dist/src/utils/theme.d.ts +66 -0
- package/dist/style.css +1 -1
- package/package.json +35 -42
- package/packages/styles/css-variables.css +197 -0
- package/packages/styles/theme-config.ts +261 -0
- package/packages/styles/variables.scss +70 -0
- package/dist/packages/components/Grid/components/GridItem.vue.d.ts +0 -37
- package/dist/packages/components/Grid/index.vue.d.ts +0 -31
- package/dist/packages/components/Grid/interface/index.d.ts +0 -5
- package/dist/packages/components/Icon/index.vue.d.ts +0 -2
- package/dist/packages/components/SearchBar/index.vue.d.ts +0 -42
- package/dist/packages/components/SearchForm/components/SearchFormItem.vue.d.ts +0 -24
- package/dist/packages/components/SearchForm/index.vue.d.ts +0 -3019
- package/dist/packages/components/proForm/components/FormItem.vue.d.ts +0 -46
- package/dist/packages/components/proForm/components/interface/index.d.ts +0 -66
- package/dist/packages/components/proForm/index.vue.d.ts +0 -230
- package/dist/packages/components/proTable/components/ColSetting.vue.d.ts +0 -8
- package/dist/packages/components/proTable/components/Pagination.vue.d.ts +0 -17
- package/dist/packages/components/proTable/components/TableColumn.vue.d.ts +0 -6
- package/dist/packages/components/proTable/interface/index.d.ts +0 -66
- package/dist/packages/hooks/interface/index.d.ts +0 -28
- package/dist/packages/hooks/useSelection.d.ts +0 -16
- package/dist/packages/hooks/useTable.d.ts +0 -54
- package/dist/packages/utils/common.d.ts +0 -13
- package/dist/packages/utils/composables/useGlobalProperties.d.ts +0 -1
- package/dist/packages/utils/dayjs.d.ts +0 -2
- package/dist/packages/utils/directive.d.ts +0 -2
- package/dist/packages/utils/eventBus.d.ts +0 -2
- package/dist/packages/utils/index.d.ts +0 -152
- package/dist/packages/utils/is/index.d.ts +0 -72
- package/dist/packages/utils/validate.d.ts +0 -112
- package/dist/src/api/index.d.ts +0 -24
- package/dist/src/api/interface/index.d.ts +0 -34
- package/dist/src/api/test.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mc-markets/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "chenyu",
|
|
7
|
-
"description": "
|
|
7
|
+
"description": "Element Plus 完整导出包,提供所有组件、指令和服务",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
@@ -15,12 +15,26 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts"
|
|
16
16
|
},
|
|
17
17
|
"./style": "./dist/style.css",
|
|
18
|
-
"./
|
|
19
|
-
"./
|
|
18
|
+
"./styles": "./dist/style.css",
|
|
19
|
+
"./css-variables": "./packages/styles/css-variables.css",
|
|
20
|
+
"./scss-variables": "./packages/styles/variables.scss",
|
|
21
|
+
"./theme-config": "./packages/styles/theme-config.ts",
|
|
22
|
+
"./element-plus": {
|
|
23
|
+
"import": "./node_modules/element-plus/dist/index.full.mjs",
|
|
24
|
+
"require": "./node_modules/element-plus/dist/index.full.js",
|
|
25
|
+
"types": "./node_modules/element-plus/dist/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./element-plus/style": "./node_modules/element-plus/dist/index.css",
|
|
28
|
+
"./element-plus/styles": "./node_modules/element-plus/dist/index.css",
|
|
29
|
+
"./locales": "./dist/locales/index.js",
|
|
30
|
+
"./themes": "./dist/themes/index.js"
|
|
20
31
|
},
|
|
21
32
|
"files": [
|
|
22
33
|
"dist",
|
|
23
|
-
"
|
|
34
|
+
"packages/styles",
|
|
35
|
+
"README.md",
|
|
36
|
+
"USAGE.md",
|
|
37
|
+
"node_modules/element-plus/dist"
|
|
24
38
|
],
|
|
25
39
|
"keywords": [
|
|
26
40
|
"vue3",
|
|
@@ -28,12 +42,9 @@
|
|
|
28
42
|
"ui",
|
|
29
43
|
"component",
|
|
30
44
|
"element-plus",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"grid",
|
|
35
|
-
"icon",
|
|
36
|
-
"dialog"
|
|
45
|
+
"element-ui",
|
|
46
|
+
"ui-library",
|
|
47
|
+
"components"
|
|
37
48
|
],
|
|
38
49
|
"license": "MIT",
|
|
39
50
|
"scripts": {
|
|
@@ -46,37 +57,19 @@
|
|
|
46
57
|
"test": "vitest",
|
|
47
58
|
"test:coverage": "vitest --coverage",
|
|
48
59
|
"prepublishOnly": "npm run build",
|
|
49
|
-
"publish:lib": "node publish.js"
|
|
60
|
+
"publish:lib": "node publish.js",
|
|
61
|
+
"demo": "npm run dev",
|
|
62
|
+
"demo:build": "npm run build",
|
|
63
|
+
"demo:preview": "npm run preview"
|
|
50
64
|
},
|
|
51
65
|
"dependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"axios": "^1.3.5",
|
|
56
|
-
"commitizen": "^4.3.0",
|
|
57
|
-
"dayjs": "^1.11.7",
|
|
58
|
-
"element-plus": "^2.8.3",
|
|
59
|
-
"eruda": "^3.0.0",
|
|
60
|
-
"eslint-config-prettier": "^8.8.0",
|
|
61
|
-
"hotkeys-js": "^3.10.2",
|
|
62
|
-
"lodash-es": "^4.17.21",
|
|
63
|
-
"mitt": "^3.0.0",
|
|
64
|
-
"mockjs": "^1.1.0",
|
|
65
|
-
"npm": "^9.6.6",
|
|
66
|
-
"nprogress": "^0.2.0",
|
|
67
|
-
"path-browserify": "^1.0.1",
|
|
68
|
-
"path-to-regexp": "^6.2.1",
|
|
69
|
-
"pinia": "^2.0.34",
|
|
70
|
-
"pinia-plugin-persist": "^1.0.0",
|
|
71
|
-
"pinia-plugin-persistedstate": "^3.1.0",
|
|
72
|
-
"qs": "^6.11.1",
|
|
73
|
-
"vconsole": "^3.15.0",
|
|
74
|
-
"vue": "^3.2.47",
|
|
75
|
-
"vue-router": "^4.1.6"
|
|
66
|
+
"@vueuse/core": "^10.5.0",
|
|
67
|
+
"element-plus": "^2.8.0",
|
|
68
|
+
"vue": "^3.3.0"
|
|
76
69
|
},
|
|
77
70
|
"peerDependencies": {
|
|
78
|
-
"
|
|
79
|
-
"
|
|
71
|
+
"element-plus": "^2.8.0",
|
|
72
|
+
"vue": "^3.3.0"
|
|
80
73
|
},
|
|
81
74
|
"peerDependenciesMeta": {
|
|
82
75
|
"element-plus": {
|
|
@@ -89,12 +82,12 @@
|
|
|
89
82
|
},
|
|
90
83
|
"repository": {
|
|
91
84
|
"type": "git",
|
|
92
|
-
"url": "https://gitee.com/daboluoxigua/npm-
|
|
85
|
+
"url": "https://gitee.com/daboluoxigua/npm-mc-markets-ui.git"
|
|
93
86
|
},
|
|
94
87
|
"bugs": {
|
|
95
|
-
"url": "https://gitee.com/daboluoxigua/npm-
|
|
88
|
+
"url": "https://gitee.com/daboluoxigua/npm-mc-markets-ui/issues"
|
|
96
89
|
},
|
|
97
|
-
"homepage": "https://gitee.com/daboluoxigua/npm-
|
|
90
|
+
"homepage": "https://gitee.com/daboluoxigua/npm-mc-markets-ui#readme",
|
|
98
91
|
"publishConfig": {
|
|
99
92
|
"access": "public"
|
|
100
93
|
},
|
|
@@ -133,7 +126,7 @@
|
|
|
133
126
|
"svgo": "^3.0.2",
|
|
134
127
|
"terser": "^5.16.9",
|
|
135
128
|
"typescript": "^5.0.4",
|
|
136
|
-
"unplugin-auto-import": "^0.15.
|
|
129
|
+
"unplugin-auto-import": "^0.15.3",
|
|
137
130
|
"unplugin-vue-components": "^0.24.1",
|
|
138
131
|
"vite": "^4.2.1",
|
|
139
132
|
"vite-plugin-banner": "^0.7.0",
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mc-markets/ui - Element Plus CSS 变量配置
|
|
3
|
+
*
|
|
4
|
+
* 基于 Element Plus 官方主题定制指南
|
|
5
|
+
* @see https://element-plus.org/zh-CN/guide/theming.html
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
:root {
|
|
9
|
+
/* 主色调 */
|
|
10
|
+
--el-color-primary: #409eff;
|
|
11
|
+
--el-color-primary-light-3: #79bbff;
|
|
12
|
+
--el-color-primary-light-5: #a0cfff;
|
|
13
|
+
--el-color-primary-light-7: #c6e2ff;
|
|
14
|
+
--el-color-primary-light-8: #d9ecff;
|
|
15
|
+
--el-color-primary-light-9: #ecf5ff;
|
|
16
|
+
--el-color-primary-dark-2: #337ecc;
|
|
17
|
+
|
|
18
|
+
/* 成功色 */
|
|
19
|
+
--el-color-success: #67c23a;
|
|
20
|
+
--el-color-success-light-3: #95d475;
|
|
21
|
+
--el-color-success-light-5: #b3e19d;
|
|
22
|
+
--el-color-success-light-7: #d1edc4;
|
|
23
|
+
--el-color-success-light-8: #e1f3d8;
|
|
24
|
+
--el-color-success-light-9: #f0f9ff;
|
|
25
|
+
--el-color-success-dark-2: #529b2e;
|
|
26
|
+
|
|
27
|
+
/* 警告色 */
|
|
28
|
+
--el-color-warning: #e6a23c;
|
|
29
|
+
--el-color-warning-light-3: #eebe77;
|
|
30
|
+
--el-color-warning-light-5: #f3d19e;
|
|
31
|
+
--el-color-warning-light-7: #f8e3c5;
|
|
32
|
+
--el-color-warning-light-8: #faecd8;
|
|
33
|
+
--el-color-warning-light-9: #fdf6ec;
|
|
34
|
+
--el-color-warning-dark-2: #b88230;
|
|
35
|
+
|
|
36
|
+
/* 危险色 */
|
|
37
|
+
--el-color-danger: #f56c6c;
|
|
38
|
+
--el-color-danger-light-3: #f89898;
|
|
39
|
+
--el-color-danger-light-5: #fab6b6;
|
|
40
|
+
--el-color-danger-light-7: #fcd3d3;
|
|
41
|
+
--el-color-danger-light-8: #fde2e2;
|
|
42
|
+
--el-color-danger-light-9: #fef0f0;
|
|
43
|
+
--el-color-danger-dark-2: #c45656;
|
|
44
|
+
|
|
45
|
+
/* 错误色 */
|
|
46
|
+
--el-color-error: #f56c6c;
|
|
47
|
+
--el-color-error-light-3: #f89898;
|
|
48
|
+
--el-color-error-light-5: #fab6b6;
|
|
49
|
+
--el-color-error-light-7: #fcd3d3;
|
|
50
|
+
--el-color-error-light-8: #fde2e2;
|
|
51
|
+
--el-color-error-light-9: #fef0f0;
|
|
52
|
+
--el-color-error-dark-2: #c45656;
|
|
53
|
+
|
|
54
|
+
/* 信息色 */
|
|
55
|
+
--el-color-info: #909399;
|
|
56
|
+
--el-color-info-light-3: #b1b3b8;
|
|
57
|
+
--el-color-info-light-5: #c8c9cc;
|
|
58
|
+
--el-color-info-light-7: #dedfe0;
|
|
59
|
+
--el-color-info-light-8: #e9e9eb;
|
|
60
|
+
--el-color-info-light-9: #f4f4f5;
|
|
61
|
+
--el-color-info-dark-2: #73767a;
|
|
62
|
+
|
|
63
|
+
/* 文本颜色 */
|
|
64
|
+
--el-text-color-primary: #303133;
|
|
65
|
+
--el-text-color-regular: #606266;
|
|
66
|
+
--el-text-color-secondary: #909399;
|
|
67
|
+
--el-text-color-placeholder: #a8abb2;
|
|
68
|
+
--el-text-color-disabled: #c0c4cc;
|
|
69
|
+
|
|
70
|
+
/* 边框颜色 */
|
|
71
|
+
--el-border-color: #dcdfe6;
|
|
72
|
+
--el-border-color-light: #e4e7ed;
|
|
73
|
+
--el-border-color-lighter: #ebeef5;
|
|
74
|
+
--el-border-color-extra-light: #f2f6fc;
|
|
75
|
+
--el-border-color-dark: #d4d7de;
|
|
76
|
+
--el-border-color-darker: #cdd0d6;
|
|
77
|
+
|
|
78
|
+
/* 填充颜色 */
|
|
79
|
+
--el-fill-color: #f0f2f5;
|
|
80
|
+
--el-fill-color-light: #f5f7fa;
|
|
81
|
+
--el-fill-color-lighter: #fafafa;
|
|
82
|
+
--el-fill-color-extra-light: #fafcff;
|
|
83
|
+
--el-fill-color-dark: #ebedf0;
|
|
84
|
+
--el-fill-color-darker: #e6e8eb;
|
|
85
|
+
--el-fill-color-blank: #ffffff;
|
|
86
|
+
|
|
87
|
+
/* 背景颜色 */
|
|
88
|
+
--el-bg-color: #ffffff;
|
|
89
|
+
--el-bg-color-page: #f2f3f5;
|
|
90
|
+
--el-bg-color-overlay: #ffffff;
|
|
91
|
+
|
|
92
|
+
/* 字体大小 */
|
|
93
|
+
--el-font-size-extra-large: 20px;
|
|
94
|
+
--el-font-size-large: 18px;
|
|
95
|
+
--el-font-size-medium: 16px;
|
|
96
|
+
--el-font-size-base: 14px;
|
|
97
|
+
--el-font-size-small: 13px;
|
|
98
|
+
--el-font-size-extra-small: 12px;
|
|
99
|
+
|
|
100
|
+
/* 圆角 */
|
|
101
|
+
--el-border-radius-base: 4px;
|
|
102
|
+
--el-border-radius-small: 2px;
|
|
103
|
+
--el-border-radius-round: 20px;
|
|
104
|
+
--el-border-radius-circle: 100%;
|
|
105
|
+
|
|
106
|
+
/* 阴影 */
|
|
107
|
+
--el-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
|
|
108
|
+
--el-box-shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
109
|
+
--el-box-shadow-lighter: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
|
|
110
|
+
--el-box-shadow-dark: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.12);
|
|
111
|
+
|
|
112
|
+
/* 间距 */
|
|
113
|
+
--el-spacing-base: 20px;
|
|
114
|
+
--el-spacing-small: 10px;
|
|
115
|
+
--el-spacing-large: 30px;
|
|
116
|
+
|
|
117
|
+
/* 动画时长 */
|
|
118
|
+
--el-transition-duration: 0.3s;
|
|
119
|
+
--el-transition-duration-fast: 0.2s;
|
|
120
|
+
--el-transition-duration-slow: 0.5s;
|
|
121
|
+
|
|
122
|
+
/* 动画函数 */
|
|
123
|
+
--el-transition-function-ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
124
|
+
--el-transition-function-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
|
125
|
+
--el-transition-function-ease-in: cubic-bezier(0.755, 0.05, 0.855, 0.06);
|
|
126
|
+
|
|
127
|
+
/* z-index */
|
|
128
|
+
--el-z-index-normal: 1;
|
|
129
|
+
--el-z-index-top: 1000;
|
|
130
|
+
--el-z-index-popper: 2000;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* 暗色主题 */
|
|
134
|
+
.dark {
|
|
135
|
+
--el-color-primary: #409eff;
|
|
136
|
+
--el-color-success: #67c23a;
|
|
137
|
+
--el-color-warning: #e6a23c;
|
|
138
|
+
--el-color-danger: #f56c6c;
|
|
139
|
+
--el-color-error: #f56c6c;
|
|
140
|
+
--el-color-info: #909399;
|
|
141
|
+
|
|
142
|
+
--el-text-color-primary: #e5eaf3;
|
|
143
|
+
--el-text-color-regular: #cfd3dc;
|
|
144
|
+
--el-text-color-secondary: #a3a6ad;
|
|
145
|
+
--el-text-color-placeholder: #8d9095;
|
|
146
|
+
--el-text-color-disabled: #6c6e72;
|
|
147
|
+
|
|
148
|
+
--el-border-color: #4c4d4f;
|
|
149
|
+
--el-border-color-light: #414243;
|
|
150
|
+
--el-border-color-lighter: #363637;
|
|
151
|
+
--el-border-color-extra-light: #2b2b2c;
|
|
152
|
+
--el-border-color-dark: #58585b;
|
|
153
|
+
--el-border-color-darker: #636466;
|
|
154
|
+
|
|
155
|
+
--el-fill-color: #262727;
|
|
156
|
+
--el-fill-color-light: #1d1d1d;
|
|
157
|
+
--el-fill-color-lighter: #171717;
|
|
158
|
+
--el-fill-color-extra-light: #111111;
|
|
159
|
+
--el-fill-color-dark: #2b2b2c;
|
|
160
|
+
--el-fill-color-darker: #363637;
|
|
161
|
+
--el-fill-color-blank: #141414;
|
|
162
|
+
|
|
163
|
+
--el-bg-color: #141414;
|
|
164
|
+
--el-bg-color-page: #0a0a0a;
|
|
165
|
+
--el-bg-color-overlay: #1d1e1f;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* 自定义主题类 */
|
|
169
|
+
.mc-markets-theme-blue {
|
|
170
|
+
--el-color-primary: #1890ff;
|
|
171
|
+
--el-color-primary-light-3: #40a9ff;
|
|
172
|
+
--el-color-primary-light-5: #69c0ff;
|
|
173
|
+
--el-color-primary-light-7: #91d5ff;
|
|
174
|
+
--el-color-primary-light-8: #bae7ff;
|
|
175
|
+
--el-color-primary-light-9: #e6f7ff;
|
|
176
|
+
--el-color-primary-dark-2: #096dd9;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.mc-markets-theme-green {
|
|
180
|
+
--el-color-primary: #52c41a;
|
|
181
|
+
--el-color-primary-light-3: #73d13d;
|
|
182
|
+
--el-color-primary-light-5: #95de64;
|
|
183
|
+
--el-color-primary-light-7: #b7eb8f;
|
|
184
|
+
--el-color-primary-light-8: #d9f7be;
|
|
185
|
+
--el-color-primary-light-9: #f6ffed;
|
|
186
|
+
--el-color-primary-dark-2: #389e0d;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.mc-markets-theme-purple {
|
|
190
|
+
--el-color-primary: #722ed1;
|
|
191
|
+
--el-color-primary-light-3: #9254de;
|
|
192
|
+
--el-color-primary-light-5: #b37feb;
|
|
193
|
+
--el-color-primary-light-7: #d3adf7;
|
|
194
|
+
--el-color-primary-light-8: #efdbff;
|
|
195
|
+
--el-color-primary-light-9: #f9f0ff;
|
|
196
|
+
--el-color-primary-dark-2: #531dab;
|
|
197
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mc-markets/ui - 主题配置工具
|
|
3
|
+
*
|
|
4
|
+
* 基于 Element Plus 官方主题定制指南
|
|
5
|
+
* @see https://element-plus.org/zh-CN/guide/theming.html
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface ThemeConfig {
|
|
9
|
+
/** 主题名称 */
|
|
10
|
+
name?: string
|
|
11
|
+
/** 是否暗色主题 */
|
|
12
|
+
dark?: boolean
|
|
13
|
+
/** 自定义CSS变量 */
|
|
14
|
+
cssVars?: Record<string, string>
|
|
15
|
+
/** 自定义类名 */
|
|
16
|
+
customClass?: string
|
|
17
|
+
/** 主色调 */
|
|
18
|
+
primaryColor?: string
|
|
19
|
+
/** 成功色 */
|
|
20
|
+
successColor?: string
|
|
21
|
+
/** 警告色 */
|
|
22
|
+
warningColor?: string
|
|
23
|
+
/** 危险色 */
|
|
24
|
+
dangerColor?: string
|
|
25
|
+
/** 信息色 */
|
|
26
|
+
infoColor?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class ThemeConfigManager {
|
|
30
|
+
private static instance: ThemeConfigManager
|
|
31
|
+
private currentTheme: ThemeConfig = { name: 'default', dark: false }
|
|
32
|
+
|
|
33
|
+
static getInstance(): ThemeConfigManager {
|
|
34
|
+
if (!ThemeConfigManager.instance) {
|
|
35
|
+
ThemeConfigManager.instance = new ThemeConfigManager()
|
|
36
|
+
}
|
|
37
|
+
return ThemeConfigManager.instance
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** 设置主题 */
|
|
41
|
+
setTheme(theme: ThemeConfig): void {
|
|
42
|
+
this.currentTheme = { ...this.currentTheme, ...theme }
|
|
43
|
+
this.applyTheme()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 获取当前主题 */
|
|
47
|
+
getTheme(): ThemeConfig {
|
|
48
|
+
return { ...this.currentTheme }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 切换暗色主题 */
|
|
52
|
+
toggleDark(): void {
|
|
53
|
+
this.currentTheme.dark = !this.currentTheme.dark
|
|
54
|
+
this.applyTheme()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 设置主色调 */
|
|
58
|
+
setPrimaryColor(color: string): void {
|
|
59
|
+
this.setCssVar('--el-color-primary', color)
|
|
60
|
+
this.generateColorPalette(color, 'primary')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 设置成功色 */
|
|
64
|
+
setSuccessColor(color: string): void {
|
|
65
|
+
this.setCssVar('--el-color-success', color)
|
|
66
|
+
this.generateColorPalette(color, 'success')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 设置警告色 */
|
|
70
|
+
setWarningColor(color: string): void {
|
|
71
|
+
this.setCssVar('--el-color-warning', color)
|
|
72
|
+
this.generateColorPalette(color, 'warning')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 设置危险色 */
|
|
76
|
+
setDangerColor(color: string): void {
|
|
77
|
+
this.setCssVar('--el-color-danger', color)
|
|
78
|
+
this.generateColorPalette(color, 'danger')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** 设置信息色 */
|
|
82
|
+
setInfoColor(color: string): void {
|
|
83
|
+
this.setCssVar('--el-color-info', color)
|
|
84
|
+
this.generateColorPalette(color, 'info')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** 设置CSS变量 */
|
|
88
|
+
setCssVar(name: string, value: string): void {
|
|
89
|
+
const root = document.documentElement
|
|
90
|
+
root.style.setProperty(name, value)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** 获取CSS变量 */
|
|
94
|
+
getCssVar(name: string): string {
|
|
95
|
+
const root = document.documentElement
|
|
96
|
+
return getComputedStyle(root).getPropertyValue(name).trim()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** 生成颜色调色板 */
|
|
100
|
+
private generateColorPalette(color: string, type: 'primary' | 'success' | 'warning' | 'danger' | 'info'): void {
|
|
101
|
+
const root = document.documentElement
|
|
102
|
+
const baseColor = this.hexToRgb(color)
|
|
103
|
+
|
|
104
|
+
if (!baseColor) return
|
|
105
|
+
|
|
106
|
+
// 生成不同亮度的颜色
|
|
107
|
+
const lightColors = this.generateLightColors(baseColor)
|
|
108
|
+
const darkColors = this.generateDarkColors(baseColor)
|
|
109
|
+
|
|
110
|
+
// 设置CSS变量
|
|
111
|
+
root.style.setProperty(`--el-color-${type}`, color)
|
|
112
|
+
root.style.setProperty(`--el-color-${type}-light-3`, lightColors[3])
|
|
113
|
+
root.style.setProperty(`--el-color-${type}-light-5`, lightColors[5])
|
|
114
|
+
root.style.setProperty(`--el-color-${type}-light-7`, lightColors[7])
|
|
115
|
+
root.style.setProperty(`--el-color-${type}-light-8`, lightColors[8])
|
|
116
|
+
root.style.setProperty(`--el-color-${type}-light-9`, lightColors[9])
|
|
117
|
+
root.style.setProperty(`--el-color-${type}-dark-2`, darkColors[2])
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** 应用主题 */
|
|
121
|
+
private applyTheme(): void {
|
|
122
|
+
const root = document.documentElement
|
|
123
|
+
|
|
124
|
+
// 应用暗色主题
|
|
125
|
+
if (this.currentTheme.dark) {
|
|
126
|
+
root.classList.add('dark')
|
|
127
|
+
} else {
|
|
128
|
+
root.classList.remove('dark')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 应用自定义类名
|
|
132
|
+
if (this.currentTheme.customClass) {
|
|
133
|
+
root.classList.add(this.currentTheme.customClass)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 应用自定义CSS变量
|
|
137
|
+
if (this.currentTheme.cssVars) {
|
|
138
|
+
Object.entries(this.currentTheme.cssVars).forEach(([key, value]) => {
|
|
139
|
+
root.style.setProperty(key, value)
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 应用预设颜色
|
|
144
|
+
if (this.currentTheme.primaryColor) {
|
|
145
|
+
this.setPrimaryColor(this.currentTheme.primaryColor)
|
|
146
|
+
}
|
|
147
|
+
if (this.currentTheme.successColor) {
|
|
148
|
+
this.setSuccessColor(this.currentTheme.successColor)
|
|
149
|
+
}
|
|
150
|
+
if (this.currentTheme.warningColor) {
|
|
151
|
+
this.setWarningColor(this.currentTheme.warningColor)
|
|
152
|
+
}
|
|
153
|
+
if (this.currentTheme.dangerColor) {
|
|
154
|
+
this.setDangerColor(this.currentTheme.dangerColor)
|
|
155
|
+
}
|
|
156
|
+
if (this.currentTheme.infoColor) {
|
|
157
|
+
this.setInfoColor(this.currentTheme.infoColor)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** 十六进制颜色转RGB */
|
|
162
|
+
private hexToRgb(hex: string): { r: number; g: number; b: number } | null {
|
|
163
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
|
|
164
|
+
return result ? {
|
|
165
|
+
r: parseInt(result[1], 16),
|
|
166
|
+
g: parseInt(result[2], 16),
|
|
167
|
+
b: parseInt(result[3], 16)
|
|
168
|
+
} : null
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** RGB转十六进制 */
|
|
172
|
+
private rgbToHex(r: number, g: number, b: number): string {
|
|
173
|
+
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** 生成浅色变体 */
|
|
177
|
+
private generateLightColors(rgb: { r: number; g: number; b: number }): Record<number, string> {
|
|
178
|
+
const colors: Record<number, string> = {}
|
|
179
|
+
|
|
180
|
+
for (let i = 1; i <= 9; i++) {
|
|
181
|
+
const factor = (10 - i) / 10
|
|
182
|
+
const r = Math.round(255 - (255 - rgb.r) * factor)
|
|
183
|
+
const g = Math.round(255 - (255 - rgb.g) * factor)
|
|
184
|
+
const b = Math.round(255 - (255 - rgb.b) * factor)
|
|
185
|
+
colors[i] = this.rgbToHex(r, g, b)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return colors
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** 生成深色变体 */
|
|
192
|
+
private generateDarkColors(rgb: { r: number; g: number; b: number }): Record<number, string> {
|
|
193
|
+
const colors: Record<number, string> = {}
|
|
194
|
+
|
|
195
|
+
for (let i = 1; i <= 2; i++) {
|
|
196
|
+
const factor = i / 10
|
|
197
|
+
const r = Math.round(rgb.r * (1 - factor))
|
|
198
|
+
const g = Math.round(rgb.g * (1 - factor))
|
|
199
|
+
const b = Math.round(rgb.b * (1 - factor))
|
|
200
|
+
colors[i] = this.rgbToHex(r, g, b)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return colors
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** 重置主题 */
|
|
207
|
+
resetTheme(): void {
|
|
208
|
+
const root = document.documentElement
|
|
209
|
+
root.className = ''
|
|
210
|
+
root.style.cssText = ''
|
|
211
|
+
this.currentTheme = { name: 'default', dark: false }
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** 导出主题配置 */
|
|
215
|
+
exportTheme(): string {
|
|
216
|
+
const root = document.documentElement
|
|
217
|
+
const computedStyle = getComputedStyle(root)
|
|
218
|
+
const cssVars: Record<string, string> = {}
|
|
219
|
+
|
|
220
|
+
// 获取所有CSS变量
|
|
221
|
+
for (let i = 0; i < computedStyle.length; i++) {
|
|
222
|
+
const property = computedStyle[i]
|
|
223
|
+
if (property.startsWith('--el-')) {
|
|
224
|
+
cssVars[property] = computedStyle.getPropertyValue(property).trim()
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return JSON.stringify({
|
|
229
|
+
...this.currentTheme,
|
|
230
|
+
cssVars
|
|
231
|
+
}, null, 2)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** 导入主题配置 */
|
|
235
|
+
importTheme(config: string): void {
|
|
236
|
+
try {
|
|
237
|
+
const themeConfig = JSON.parse(config)
|
|
238
|
+
this.setTheme(themeConfig)
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.error('导入主题配置失败:', error)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 导出主题管理器实例
|
|
246
|
+
export const themeConfigManager = ThemeConfigManager.getInstance()
|
|
247
|
+
|
|
248
|
+
// 导出便捷方法
|
|
249
|
+
export const setTheme = (theme: ThemeConfig) => themeConfigManager.setTheme(theme)
|
|
250
|
+
export const getTheme = () => themeConfigManager.getTheme()
|
|
251
|
+
export const toggleDark = () => themeConfigManager.toggleDark()
|
|
252
|
+
export const setPrimaryColor = (color: string) => themeConfigManager.setPrimaryColor(color)
|
|
253
|
+
export const setSuccessColor = (color: string) => themeConfigManager.setSuccessColor(color)
|
|
254
|
+
export const setWarningColor = (color: string) => themeConfigManager.setWarningColor(color)
|
|
255
|
+
export const setDangerColor = (color: string) => themeConfigManager.setDangerColor(color)
|
|
256
|
+
export const setInfoColor = (color: string) => themeConfigManager.setInfoColor(color)
|
|
257
|
+
export const setCssVar = (name: string, value: string) => themeConfigManager.setCssVar(name, value)
|
|
258
|
+
export const getCssVar = (name: string) => themeConfigManager.getCssVar(name)
|
|
259
|
+
export const resetTheme = () => themeConfigManager.resetTheme()
|
|
260
|
+
export const exportTheme = () => themeConfigManager.exportTheme()
|
|
261
|
+
export const importTheme = (config: string) => themeConfigManager.importTheme(config)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mc-markets/ui - Element Plus 主题变量配置
|
|
3
|
+
*
|
|
4
|
+
* 基于 Element Plus 官方主题定制指南
|
|
5
|
+
* @see https://element-plus.org/zh-CN/guide/theming.html
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// 导入 Element Plus 的 SCSS 变量
|
|
9
|
+
@forward 'element-plus/theme-chalk/src/common/var.scss' with (
|
|
10
|
+
// 自定义颜色变量
|
|
11
|
+
$colors: (
|
|
12
|
+
'primary': (
|
|
13
|
+
'base': #409eff, // 主色
|
|
14
|
+
),
|
|
15
|
+
'success': (
|
|
16
|
+
'base': #67c23a, // 成功色
|
|
17
|
+
),
|
|
18
|
+
'warning': (
|
|
19
|
+
'base': #e6a23c, // 警告色
|
|
20
|
+
),
|
|
21
|
+
'danger': (
|
|
22
|
+
'base': #f56c6c, // 危险色
|
|
23
|
+
),
|
|
24
|
+
'error': (
|
|
25
|
+
'base': #f56c6c, // 错误色
|
|
26
|
+
),
|
|
27
|
+
'info': (
|
|
28
|
+
'base': #909399, // 信息色
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
|
|
32
|
+
// 自定义字体大小
|
|
33
|
+
$font-size: (
|
|
34
|
+
'extra-large': 20px,
|
|
35
|
+
'large': 18px,
|
|
36
|
+
'medium': 16px,
|
|
37
|
+
'base': 14px,
|
|
38
|
+
'small': 13px,
|
|
39
|
+
'extra-small': 12px,
|
|
40
|
+
),
|
|
41
|
+
|
|
42
|
+
// 自定义圆角
|
|
43
|
+
$border-radius: (
|
|
44
|
+
'base': 4px,
|
|
45
|
+
'small': 2px,
|
|
46
|
+
'round': 20px,
|
|
47
|
+
'circle': 100%,
|
|
48
|
+
),
|
|
49
|
+
|
|
50
|
+
// 自定义阴影
|
|
51
|
+
$box-shadow: (
|
|
52
|
+
'base': (
|
|
53
|
+
0 2px 4px rgba(0, 0, 0, 0.12),
|
|
54
|
+
0 0 6px rgba(0, 0, 0, 0.04)
|
|
55
|
+
),
|
|
56
|
+
'light': (
|
|
57
|
+
0 2px 12px 0 rgba(0, 0, 0, 0.1)
|
|
58
|
+
),
|
|
59
|
+
'lighter': (
|
|
60
|
+
0 2px 12px 0 rgba(0, 0, 0, 0.06)
|
|
61
|
+
),
|
|
62
|
+
'dark': (
|
|
63
|
+
0 2px 4px rgba(0, 0, 0, 0.12),
|
|
64
|
+
0 0 6px rgba(0, 0, 0, 0.12)
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// 导入所有 Element Plus 样式
|
|
70
|
+
@use "element-plus/theme-chalk/src/index.scss" as *;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Responsive } from '../interface/index';
|
|
2
|
-
type Props = {
|
|
3
|
-
offset?: number;
|
|
4
|
-
span?: number;
|
|
5
|
-
suffix?: boolean;
|
|
6
|
-
xs?: Responsive;
|
|
7
|
-
sm?: Responsive;
|
|
8
|
-
md?: Responsive;
|
|
9
|
-
lg?: Responsive;
|
|
10
|
-
xl?: Responsive;
|
|
11
|
-
};
|
|
12
|
-
declare function __VLS_template(): {
|
|
13
|
-
attrs: Partial<{}>;
|
|
14
|
-
slots: {
|
|
15
|
-
default?(_: {}): any;
|
|
16
|
-
};
|
|
17
|
-
refs: {};
|
|
18
|
-
rootEl: HTMLDivElement;
|
|
19
|
-
};
|
|
20
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
21
|
-
declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
22
|
-
xs: Responsive;
|
|
23
|
-
sm: Responsive;
|
|
24
|
-
md: Responsive;
|
|
25
|
-
lg: Responsive;
|
|
26
|
-
xl: Responsive;
|
|
27
|
-
offset: number;
|
|
28
|
-
span: number;
|
|
29
|
-
suffix: boolean;
|
|
30
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
31
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
32
|
-
export default _default;
|
|
33
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
34
|
-
new (): {
|
|
35
|
-
$slots: S;
|
|
36
|
-
};
|
|
37
|
-
};
|