diff --git a/package.json b/package.json index 646dd75e9..5b99bccce 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "vuedraggable": "^2.16.0", "vuex": "^3.0.1", "wangeditor": "^3.1.1", + "webpack-theme-color-replacer": "^1.2.15", "xlsx": "^0.13.3" }, "devDependencies": { diff --git a/src/components/main/components/change-theme/index.vue b/src/components/main/components/change-theme/index.vue new file mode 100644 index 000000000..7baf656aa --- /dev/null +++ b/src/components/main/components/change-theme/index.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/src/components/main/main.vue b/src/components/main/main.vue index 710a52bb1..b2bb71625 100644 --- a/src/components/main/main.vue +++ b/src/components/main/main.vue @@ -16,6 +16,7 @@ + @@ -41,6 +42,7 @@ import TagsNav from './components/tags-nav' import User from './components/user' import ABackTop from './components/a-back-top' import Fullscreen from './components/fullscreen' +import ChangeTheme from './components/change-theme' import Language from './components/language' import ErrorStore from './components/error-store' import { mapMutations, mapActions, mapGetters } from 'vuex' @@ -57,6 +59,7 @@ export default { Language, TagsNav, Fullscreen, + ChangeTheme, ErrorStore, User, ABackTop diff --git a/vue.config.js b/vue.config.js index 5d6c1d405..36ac4f016 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,3 +1,6 @@ +const ThemeColorReplacer = require('webpack-theme-color-replacer') +const colorUtil = require('webpack-theme-color-replacer/forElementUI') + const path = require('path') const resolve = dir => { @@ -35,9 +38,22 @@ module.exports = { .set('_c', resolve('src/components')) }, // 设为false打包时不生成.map文件 - productionSourceMap: false + productionSourceMap: false, // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串 // devServer: { // proxy: 'localhost:3000' // } + + configureWebpack: { + plugins: [ + new ThemeColorReplacer({ + fileName: 'css/theme-colors-[contenthash:8].css', + matchColors: colorUtil.getElementUISeries('#2d8cf0').concat('#fff'), // 主色系列 + // 改变样式选择器,解决样式覆盖问题 + changeSelector (selector) { + return selector + } + }) + ] + } }