Răsfoiți Sursa

fix: themeColor change #279

Sendya 5 ani în urmă
părinte
comite
0dce4f8c13

+ 1 - 4
src/components/SettingDrawer/SettingDrawer.vue

@@ -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)
     }

+ 2 - 2
src/components/SettingDrawer/themeColor.js

@@ -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) => {
@@ -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`
     }

+ 2 - 2
src/config/defaultSettings.js

@@ -1,6 +1,6 @@
 /**
  * 项目默认配置项
- * primaryColor - 默认主题色
+ * primaryColor - 默认主题色, 如果修改颜色不生效,请清理 localStorage
  * navTheme - sidebar theme ['dark', 'light'] 两种主题
  * colorWeak - 色盲模式
  * layout - 整体布局方式 ['sidemenu', 'topmenu'] 两种布局
@@ -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

+ 2 - 15
vue.config.js

@@ -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) {