From 8034f474d625271d3f72d95772b84da70d2ddedc Mon Sep 17 00:00:00 2001 From: iczer <1126263215@qq.com> Date: Tue, 30 Jun 2020 21:04:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20the=20problem=20that=20changing=20the=20?= =?UTF-8?q?theme=20color=20does=20not=20work=20because=20of=20cache=20reas?= =?UTF-8?q?ons=20:star2:=20=E4=BF=AE=E5=A4=8D:=20=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0=E5=AF=BC=E8=87=B4=E4=B8=BB=E9=A2=98=E8=89=B2?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/themeUtil.js | 4 +++- vue.config.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/themeUtil.js b/src/utils/themeUtil.js index a08aa06..b3b2f3d 100644 --- a/src/utils/themeUtil.js +++ b/src/utils/themeUtil.js @@ -18,7 +18,9 @@ module.exports = { changeThemeColor (newColor) { let lastColor = this.lastColor || this.primaryColor let options = { - cssUrl: '/css/theme-colors.css', + changeUrl (cssUrl) { + return `/${cssUrl}` // while router is not `hash` mode, it needs absolute path + }, oldColors: this.getThemeColors(lastColor), newColors: this.getThemeColors(newColor) } diff --git a/vue.config.js b/vue.config.js index 14691e2..4d1c9c8 100644 --- a/vue.config.js +++ b/vue.config.js @@ -14,7 +14,7 @@ module.exports = { config.entry.app = ["babel-polyfill", "whatwg-fetch", "./src/main.js"]; config.plugins.push( new ThemeColorReplacer({ - fileName: 'css/theme-colors.css', + fileName: 'css/theme-colors-[contenthash:8].css', matchColors: getThemeColors(themeColor), changeSelector })