2020-06-16 20:38:44 +08:00
|
|
|
const client = require('webpack-theme-color-replacer/client')
|
2020-07-06 21:52:36 +08:00
|
|
|
const {theme, themeColor} = require('../config')
|
2020-07-08 20:51:06 +08:00
|
|
|
const {getMenuColors, getAntdColors, getThemeToggleColors} = require('../utils/colors')
|
|
|
|
|
const {theme: themeCfg} = require('../config/default')
|
2020-06-16 18:41:07 +08:00
|
|
|
|
2020-06-16 20:38:44 +08:00
|
|
|
module.exports = {
|
2020-07-06 21:52:36 +08:00
|
|
|
getThemeColors(color, $theme) {
|
2020-07-08 20:51:06 +08:00
|
|
|
const _color = color || themeColor
|
|
|
|
|
const _theme = $theme || theme
|
|
|
|
|
const replaceColors = getThemeToggleColors(_color, _theme)
|
|
|
|
|
const themeColors = [
|
|
|
|
|
...replaceColors.mainColors,
|
|
|
|
|
...replaceColors.subColors,
|
|
|
|
|
...replaceColors.menuColors,
|
|
|
|
|
...replaceColors.contentColors,
|
|
|
|
|
...replaceColors.rgbColors
|
|
|
|
|
]
|
|
|
|
|
return themeColors
|
2020-06-16 20:38:44 +08:00
|
|
|
},
|
2020-07-06 21:52:36 +08:00
|
|
|
changeThemeColor (newColor, $theme) {
|
2020-07-08 20:51:06 +08:00
|
|
|
let promise = client.changer.changeColor({newColors: this.getThemeColors(newColor, $theme)})
|
2020-06-16 18:41:07 +08:00
|
|
|
return promise
|
2020-06-23 18:57:00 +08:00
|
|
|
},
|
2020-07-01 17:23:39 +08:00
|
|
|
modifyVars(color) {
|
2020-07-08 20:51:06 +08:00
|
|
|
let _color = color || themeColor
|
|
|
|
|
const palettes = getAntdColors(_color, theme)
|
|
|
|
|
const menuColors = getMenuColors(_color, theme)
|
|
|
|
|
const primary = palettes[5]
|
2020-07-01 17:23:39 +08:00
|
|
|
return {
|
2020-07-08 20:51:06 +08:00
|
|
|
'primary-color': primary,
|
|
|
|
|
'info-color': primary,
|
2020-07-06 21:52:36 +08:00
|
|
|
'alert-info-bg-color': palettes[0],
|
|
|
|
|
'alert-info-border-color': palettes[3],
|
2020-07-08 20:51:06 +08:00
|
|
|
'processing-color': primary,
|
|
|
|
|
'menu-dark-submenu-bg': menuColors[0],
|
|
|
|
|
'layout-header-background': menuColors[1],
|
|
|
|
|
'layout-trigger-background': menuColors[2],
|
2020-07-06 21:52:36 +08:00
|
|
|
...themeCfg[theme]
|
2020-07-01 17:23:39 +08:00
|
|
|
}
|
2020-06-16 18:41:07 +08:00
|
|
|
}
|
|
|
|
|
}
|