-
+
diff --git a/src/theme/default/color.less b/src/theme/default/color.less
new file mode 100644
index 0000000..102c682
--- /dev/null
+++ b/src/theme/default/color.less
@@ -0,0 +1,4 @@
+@import "../theme";
+@primary-color: @primary;
+@processing-color: @primary;
+@link-color: @primary;
diff --git a/src/theme/default/index.less b/src/theme/default/index.less
new file mode 100644
index 0000000..885594f
--- /dev/null
+++ b/src/theme/default/index.less
@@ -0,0 +1 @@
+@import "color";
diff --git a/src/theme/index.less b/src/theme/index.less
new file mode 100644
index 0000000..85ceaf4
--- /dev/null
+++ b/src/theme/index.less
@@ -0,0 +1,2 @@
+@import '~ant-design-vue/dist/antd.less';
+@import "default/index";
diff --git a/src/theme/theme.less b/src/theme/theme.less
new file mode 100644
index 0000000..33b715c
--- /dev/null
+++ b/src/theme/theme.less
@@ -0,0 +1 @@
+@primary: #1890ff;
diff --git a/src/utils/themeUtil.js b/src/utils/themeUtil.js
new file mode 100644
index 0000000..dda691b
--- /dev/null
+++ b/src/utils/themeUtil.js
@@ -0,0 +1,17 @@
+import client from 'webpack-theme-color-replacer/client'
+import generate from '@ant-design/colors/lib/generate'
+
+export default {
+ primaryColor: '#1890ff',
+ changeThemeColor (newColor) {
+ let lastColor = this.lastColor || this.primaryColor
+ let options = {
+ cssUrl: '/css/theme-colors.css',
+ oldColors: generate(lastColor),
+ newColors: generate(newColor)
+ }
+ let promise = client.changer.changeColor(options)
+ this.lastColor = lastColor
+ return promise
+ }
+}
diff --git a/vue.config.js b/vue.config.js
index b28d227..d333db6 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,12 +1,38 @@
+// let path = require('path')
+const ThemeColorReplacer = require('webpack-theme-color-replacer')
+const generate = require('@ant-design/colors/lib/generate').default
+
module.exports = {
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
+ // patterns: [path.resolve(__dirname, "./src/theme/theme.less")]
patterns: []
}
},
configureWebpack: config => {
config.entry.app = ["babel-polyfill", "whatwg-fetch", "./src/main.js"];
+ config.plugins.push(
+ new ThemeColorReplacer({
+ fileName: 'css/theme-colors.css',
+ matchColors: generate('#1890ff')
+ })
+ )
+ },
+ css: {
+ loaderOptions: {
+ less: {
+ lessOptions: {
+ modifyVars: {
+ // 'link-color': '#ff4d85',
+ // 'processing-color': '#ff4d85',
+ // 'primary-color': '#ff4d85',
+ // 'primary': '#1890ff',
+ },
+ javascriptEnabled: true
+ }
+ }
+ }
},
publicPath: './',
outputDir: 'dist',
diff --git a/yarn.lock b/yarn.lock
index 25cfd33..7bf4020 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9,6 +9,13 @@
dependencies:
tinycolor2 "^1.4.1"
+"@ant-design/colors@^4.0.0":
+ version "4.0.0"
+ resolved "https://registry.npm.taobao.org/@ant-design/colors/download/@ant-design/colors-4.0.0.tgz#bcc1183b1fdfd1587d4e655035b3fc47bf3a4ab6"
+ integrity sha1-vMEYOx/f0Vh9TmVQNbP8R786SrY=
+ dependencies:
+ tinycolor2 "^1.4.1"
+
"@ant-design/icons-vue@^2.0.0":
version "2.0.0"
resolved "https://registry.npm.taobao.org/@ant-design/icons-vue/download/@ant-design/icons-vue-2.0.0.tgz#0357f5010a404e9f34a87a4b41b2a08df691dbce"
@@ -9384,7 +9391,7 @@ webpack-merge@^4.2.2:
dependencies:
lodash "^4.17.15"
-webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3:
+webpack-sources@*, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3:
version "1.4.3"
resolved "https://registry.npm.taobao.org/webpack-sources/download/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"
integrity sha1-7t2OwLko+/HL/plOItLYkPMwqTM=
@@ -9392,6 +9399,13 @@ webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-
source-list-map "^2.0.0"
source-map "~0.6.1"
+webpack-theme-color-replacer@^1.3.12:
+ version "1.3.12"
+ resolved "https://registry.npm.taobao.org/webpack-theme-color-replacer/download/webpack-theme-color-replacer-1.3.12.tgz#0593a3149310c0e5b6b85afeccd61925b1b8e86b"
+ integrity sha1-BZOjFJMQwOW2uFr+zNYZJbG46Gs=
+ dependencies:
+ webpack-sources "*"
+
webpack@^4.0.0:
version "4.43.0"
resolved "https://registry.npm.taobao.org/webpack/download/webpack-4.43.0.tgz#c48547b11d563224c561dad1172c8aa0b8a678e6"