Skip to content

Commit

Permalink
fix: themeColor change vueComponent#279
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Jun 3, 2019
1 parent e9d8181 commit 0dce4f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/components/SettingDrawer/SettingDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ export default {
setTimeout(() => {
vm.visible = false
}, 16)
// 当主题色不是默认色时,才进行主题编译
if (this.primaryColor !== config.primaryColor) {
updateTheme(this.primaryColor)
}
updateTheme(this.primaryColor)
if (this.colorWeak !== config.colorWeak) {
updateColorWeak(this.colorWeak)
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/SettingDrawer/themeColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import client from 'webpack-theme-color-replacer/client'
import generate from '@ant-design/colors/lib/generate'

export default {
primaryColor: '#1890ff',
primaryColor: '#1890ff', // TODO 需要处理的暗坑
getAntdSerials (color) {
// 淡化(即less的tint)
const lightens = new Array(9).fill().map((t, i) => {
Expand All @@ -15,7 +15,7 @@ export default {
changeColor (newColor) {
var lastColor = this.lastColor || this.primaryColor
var options = {
cssUrl: '/css/theme-colors.css',
cssUrl: '/css/theme-colors.css', // TODO 需要处理的暗坑
oldColors: this.getAntdSerials(lastColor), // current colors array. The same as `matchColors`
newColors: this.getAntdSerials(newColor) // new colors array, one-to-one corresponde with `oldColors`
}
Expand Down
4 changes: 2 additions & 2 deletions src/config/defaultSettings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* 项目默认配置项
* primaryColor - 默认主题色
* primaryColor - 默认主题色, 如果修改颜色不生效,请清理 localStorage
* navTheme - sidebar theme ['dark', 'light'] 两种主题
* colorWeak - 色盲模式
* layout - 整体布局方式 ['sidemenu', 'topmenu'] 两种布局
Expand All @@ -14,7 +14,7 @@
*/

export default {
primaryColor: '#1890FF', // primary color of ant design
primaryColor: '#52C41A', // primary color of ant design
navTheme: 'dark', // theme for nav menu
layout: 'sidemenu', // nav menu position: sidemenu or topmenu
contentWidth: 'Fixed', // layout of content: Fluid or Fixed, only works when layout is topmenu
Expand Down
17 changes: 2 additions & 15 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,14 @@ function resolve (dir) {

// vue.config.js
module.exports = {
/*
Vue-cli3:
Crashed when using Webpack `import()` #2463
https://github.com/vuejs/vue-cli/issues/2463
*/
/*
pages: {
index: {
entry: 'src/main.js',
chunks: ['chunk-vendors', 'chunk-common', 'index']
}
},
*/
configureWebpack: {
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// 生成仅包含颜色的替换样式(主题色等)
// TODO 需要增加根据环境不开启主题需求
new ThemeColorReplacer({
fileName: 'css/theme-colors[hash].css',
fileName: 'css/theme-colors.css', // TODO 需要处理的暗坑
matchColors: getAntdSerials('#1890ff'), // 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector (selector) {
Expand Down

0 comments on commit 0dce4f8

Please sign in to comment.