fix: the problem that changing the theme color does not work because of cache reasons 🌟

修复: 缓存原因导致主题色更换不生效的问题;
master
iczer 4 years ago
parent ec771b15aa
commit 8034f474d6
  1. 4
      src/utils/themeUtil.js
  2. 2
      vue.config.js

@ -18,7 +18,9 @@ module.exports = {
changeThemeColor (newColor) { changeThemeColor (newColor) {
let lastColor = this.lastColor || this.primaryColor let lastColor = this.lastColor || this.primaryColor
let options = { 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), oldColors: this.getThemeColors(lastColor),
newColors: this.getThemeColors(newColor) newColors: this.getThemeColors(newColor)
} }

@ -14,7 +14,7 @@ module.exports = {
config.entry.app = ["babel-polyfill", "whatwg-fetch", "./src/main.js"]; config.entry.app = ["babel-polyfill", "whatwg-fetch", "./src/main.js"];
config.plugins.push( config.plugins.push(
new ThemeColorReplacer({ new ThemeColorReplacer({
fileName: 'css/theme-colors.css', fileName: 'css/theme-colors-[contenthash:8].css',
matchColors: getThemeColors(themeColor), matchColors: getThemeColors(themeColor),
changeSelector changeSelector
}) })

Loading…
Cancel
Save