perf: 优化主题配置文件对象写法

This commit is contained in:
“huailei000”
2022-07-06 14:32:29 +08:00
committed by 老广
parent bc253c26b9
commit 000c8da6ae
9 changed files with 19 additions and 21 deletions

View File

@@ -11,17 +11,14 @@
color: light-2; color: light-2;
} }
.el-select-dropdown__item.hover, .el-select-dropdown__item:hover {
background-color: primary;
color: white!important;
}
.el-pagination.is-background .el-pager li:not(.disabled):hover { .el-pagination.is-background .el-pager li:not(.disabled):hover {
color: white; color: white;
background-color: primary; background-color: primary;
} }
.el-pagination.is-background .btn-next, .el-pagination.is-background .btn-prev, .el-pagination.is-background .el-pager li { .el-pagination.is-background .btn-next,
.el-pagination.is-background .btn-prev,
.el-pagination.is-background .el-pager li {
margin: 0 5px; margin: 0 5px;
background-color: white; background-color: white;
color: #606266; color: #606266;
@@ -311,7 +308,9 @@ td .el-button.el-button--mini {
border-bottom: 1px solid #e7e7e7 !important; border-bottom: 1px solid #e7e7e7 !important;
} }
.el-table .cell, .el-table--border td:first-child .cell, .el-table--border th:first-child .cell { .el-table .cell,
.el-table--border td:first-child .cell,
.el-table--border th:first-child .cell {
padding-left: 10px; padding-left: 10px;
padding-right: 14px; padding-right: 14px;
} }

View File

@@ -1,6 +0,0 @@
@import "./variables";

View File

@@ -1,7 +1,7 @@
/* 参考根目录下的 element-variables */ /* 参考根目录下的 element-variables */
/* 切记此处不修改配置以element-variables为准可适当增加自定义配置 */ /* 切记此处不修改配置以element-variables为准可适当增加自定义配置 */
/* 如果要修改element-variables请执行npm run build_theme更新主题 */ /* 如果要修改element-variables请执行npm run build_theme更新主题 */
@import "./element-variables.scss"; @import "../../public/theme/element-variables.scss";
:export { :export {
name: "scss"; name: "scss";

View File

@@ -15,7 +15,8 @@ export const matchColor = {
export function generateColors(primary) { export function generateColors(primary) {
const colors = {} const colors = {}
const otherColor = themeOptions[primary] || defaultThemeConfigValue || {} const themeConfig = _.findKey(themeOptions, ['--color-primary', primary])
const otherColor = themeOptions[themeConfig] || defaultThemeConfigValue
Object.keys(formula).forEach((key) => { Object.keys(formula).forEach((key) => {
let value let value
@@ -72,7 +73,8 @@ export function mix(color_1, color_2, weight) {
} }
export function changeSidebarColor(primary) { export function changeSidebarColor(primary) {
const colors = themeOptions[primary] || defaultThemeConfigValue || {} const themeConfig = _.findKey(themeOptions, ['--color-primary', primary])
const colors = themeOptions[themeConfig] || defaultThemeConfigValue || {}
const elementStyle = document.documentElement.style const elementStyle = document.documentElement.style
for (const key in colors) { for (const key in colors) {
@@ -84,6 +86,5 @@ export function changeSidebarColor(primary) {
elementStyle.setProperty('--submenu-bg', mix('000000', changeColor, 20)) elementStyle.setProperty('--submenu-bg', mix('000000', changeColor, 20))
elementStyle.setProperty('--submenu-hover', mix('000000', changeColor, 30)) elementStyle.setProperty('--submenu-hover', mix('000000', changeColor, 30))
} }
elementStyle.setProperty('--color-primary', primary)
} }
} }

View File

@@ -1,5 +1,6 @@
const config = { const config = {
'#bd1a2d': { chinese_red: {
'--color-primary': '#bd1a2d',
'--color-success': '#E98737', '--color-success': '#E98737',
'--color-info': '#f06f06', '--color-info': '#f06f06',
'--color-warning': '#f82ed3', '--color-warning': '#f82ed3',

View File

@@ -1,5 +1,6 @@
const config = { const config = {
'#0576b9': { deep_black: {
'--color-primary': '#0576b9',
'--color-success': '#2cb57e', '--color-success': '#2cb57e',
'--color-info': '#47bce8', '--color-info': '#47bce8',
'--color-warning': '#f5bd58', '--color-warning': '#f5bd58',

View File

@@ -1,5 +1,6 @@
const config = { const config = {
'#1ab394': { default: {
'--color-primary': '#1ab394',
'--color-success': '#1c84c6', '--color-success': '#1c84c6',
'--color-info': '#23c6c8', '--color-info': '#23c6c8',
'--color-warning': '#f8ac59', '--color-warning': '#f8ac59',

View File

@@ -1,5 +1,6 @@
const config = { const config = {
'#174779': { tech_blue: {
'--color-primary': '#174779',
'--color-success': '#174779', '--color-success': '#174779',
'--color-info': '#17a2b8', '--color-info': '#17a2b8',
'--color-warning': '#ffc107', '--color-warning': '#ffc107',