2020-06-16 20:38:44 +08:00
|
|
|
const client = require('webpack-theme-color-replacer/client')
|
2020-07-09 17:42:59 +08:00
|
|
|
const {theme} = require('../config')
|
2020-07-09 22:42:07 +08:00
|
|
|
const {getMenuColors, getAntdColors, getThemeToggleColors, getFunctionalColors} = require('../utils/colors')
|
2020-07-09 17:42:59 +08:00
|
|
|
const {ANTD} = 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-09 17:42:59 +08:00
|
|
|
const _color = color || theme.color
|
|
|
|
|
const mode = $theme || theme.mode
|
|
|
|
|
const replaceColors = getThemeToggleColors(_color, mode)
|
2020-07-08 20:51:06 +08:00
|
|
|
const themeColors = [
|
|
|
|
|
...replaceColors.mainColors,
|
|
|
|
|
...replaceColors.subColors,
|
|
|
|
|
...replaceColors.menuColors,
|
|
|
|
|
...replaceColors.contentColors,
|
2020-07-09 22:42:07 +08:00
|
|
|
...replaceColors.rgbColors,
|
|
|
|
|
...replaceColors.functionalColors.success,
|
|
|
|
|
...replaceColors.functionalColors.warning,
|
|
|
|
|
...replaceColors.functionalColors.error,
|
2020-07-08 20:51:06 +08:00
|
|
|
]
|
|
|
|
|
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-09 17:42:59 +08:00
|
|
|
let _color = color || theme.color
|
|
|
|
|
const palettes = getAntdColors(_color, theme.mode)
|
|
|
|
|
const menuColors = getMenuColors(_color, theme.mode)
|
2020-07-09 22:42:07 +08:00
|
|
|
const {success, warning, error} = getFunctionalColors(theme.mode)
|
2020-07-08 20:51:06 +08:00
|
|
|
const primary = palettes[5]
|
2020-07-01 17:23:39 +08:00
|
|
|
return {
|
2020-07-08 20:51:06 +08:00
|
|
|
'primary-color': primary,
|
2020-07-08 23:35:58 +08:00
|
|
|
'primary-1': palettes[0],
|
|
|
|
|
'primary-2': palettes[1],
|
|
|
|
|
'primary-3': palettes[2],
|
|
|
|
|
'primary-4': palettes[3],
|
|
|
|
|
'primary-5': palettes[4],
|
|
|
|
|
'primary-6': palettes[5],
|
|
|
|
|
'primary-7': palettes[6],
|
|
|
|
|
'primary-8': palettes[7],
|
|
|
|
|
'primary-9': palettes[8],
|
|
|
|
|
'primary-10': palettes[9],
|
2020-07-08 20:51:06 +08:00
|
|
|
'info-color': primary,
|
2020-07-09 22:42:07 +08:00
|
|
|
'success-color': success[3],
|
|
|
|
|
'warning-color': warning[3],
|
|
|
|
|
'error-color': error[3],
|
2020-07-06 21:52:36 +08:00
|
|
|
'alert-info-bg-color': palettes[0],
|
2020-07-09 22:42:07 +08:00
|
|
|
'alert-info-border-color': palettes[2],
|
|
|
|
|
'alert-success-bg-color': success[0],
|
|
|
|
|
'alert-success-border-color': success[2],
|
|
|
|
|
'alert-warning-bg-color': warning[0],
|
|
|
|
|
'alert-warning-border-color': warning[2],
|
|
|
|
|
'alert-error-bg-color': error[0],
|
|
|
|
|
'alert-error-border-color': error[2],
|
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-09 17:42:59 +08:00
|
|
|
...ANTD.theme[theme.mode]
|
2020-07-01 17:23:39 +08:00
|
|
|
}
|
2020-06-16 18:41:07 +08:00
|
|
|
}
|
|
|
|
|
}
|