Skip to content

Commit 0dce4f8

Browse files
committed
fix: themeColor change #279
1 parent e9d8181 commit 0dce4f8

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

src/components/SettingDrawer/SettingDrawer.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ export default {
195195
setTimeout(() => {
196196
vm.visible = false
197197
}, 16)
198-
// 当主题色不是默认色时,才进行主题编译
199-
if (this.primaryColor !== config.primaryColor) {
200-
updateTheme(this.primaryColor)
201-
}
198+
updateTheme(this.primaryColor)
202199
if (this.colorWeak !== config.colorWeak) {
203200
updateColorWeak(this.colorWeak)
204201
}

src/components/SettingDrawer/themeColor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import client from 'webpack-theme-color-replacer/client'
22
import generate from '@ant-design/colors/lib/generate'
33

44
export default {
5-
primaryColor: '#1890ff',
5+
primaryColor: '#1890ff', // TODO 需要处理的暗坑
66
getAntdSerials (color) {
77
// 淡化(即less的tint)
88
const lightens = new Array(9).fill().map((t, i) => {
@@ -15,7 +15,7 @@ export default {
1515
changeColor (newColor) {
1616
var lastColor = this.lastColor || this.primaryColor
1717
var options = {
18-
cssUrl: '/css/theme-colors.css',
18+
cssUrl: '/css/theme-colors.css', // TODO 需要处理的暗坑
1919
oldColors: this.getAntdSerials(lastColor), // current colors array. The same as `matchColors`
2020
newColors: this.getAntdSerials(newColor) // new colors array, one-to-one corresponde with `oldColors`
2121
}

src/config/defaultSettings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* 项目默认配置项
3-
* primaryColor - 默认主题色
3+
* primaryColor - 默认主题色, 如果修改颜色不生效,请清理 localStorage
44
* navTheme - sidebar theme ['dark', 'light'] 两种主题
55
* colorWeak - 色盲模式
66
* layout - 整体布局方式 ['sidemenu', 'topmenu'] 两种布局
@@ -14,7 +14,7 @@
1414
*/
1515

1616
export default {
17-
primaryColor: '#1890FF', // primary color of ant design
17+
primaryColor: '#52C41A', // primary color of ant design
1818
navTheme: 'dark', // theme for nav menu
1919
layout: 'sidemenu', // nav menu position: sidemenu or topmenu
2020
contentWidth: 'Fixed', // layout of content: Fluid or Fixed, only works when layout is topmenu

vue.config.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,14 @@ function resolve (dir) {
99

1010
// vue.config.js
1111
module.exports = {
12-
/*
13-
Vue-cli3:
14-
Crashed when using Webpack `import()` #2463
15-
https://github.com/vuejs/vue-cli/issues/2463
16-
17-
*/
18-
/*
19-
pages: {
20-
index: {
21-
entry: 'src/main.js',
22-
chunks: ['chunk-vendors', 'chunk-common', 'index']
23-
}
24-
},
25-
*/
2612
configureWebpack: {
2713
plugins: [
2814
// Ignore all locale files of moment.js
2915
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
3016
// 生成仅包含颜色的替换样式(主题色等)
17+
// TODO 需要增加根据环境不开启主题需求
3118
new ThemeColorReplacer({
32-
fileName: 'css/theme-colors[hash].css',
19+
fileName: 'css/theme-colors.css', // TODO 需要处理的暗坑
3320
matchColors: getAntdSerials('#1890ff'), // 主色系列
3421
// 改变样式选择器,解决样式覆盖问题
3522
changeSelector (selector) {

0 commit comments

Comments
 (0)