fix: 修复修改主题颜色后提交保存页面刷新不生效问题

This commit is contained in:
“huailei000” 2022-07-07 12:51:45 +08:00 committed by 老广
parent fbda43b9dd
commit 24e716df5d
3 changed files with 9 additions and 10 deletions

View File

@ -9,7 +9,7 @@
<meta http-equiv="Cache" content="no-cache">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title><%= webpackConfig.name %></title>
<link rel="stylesheet" href="<%= BASE_URL %>theme/index.css">
<link rel="stylesheet" href="<%= BASE_URL %>theme/element-ui.css">
</head>
<body>
<noscript>

View File

@ -1,7 +1,7 @@
import defaultSettings from '@/settings'
import { getPublicSettings } from '@/api/settings'
import { writeNewStyle, getIndexStyle } from '@/utils/theme/index'
import { matchColor, defaultThemeColor } from '@/utils/theme/color'
import { defaultThemeColor } from '@/utils/theme/color'
const { showSettings, fixedHeader, sidebarLogo, tagsView } = defaultSettings
@ -22,9 +22,9 @@ const mutations = {
}
},
SET_PUBLIC_SETTINGS: (state, settings) => {
const color = settings.INTERFACE?.theme
const color = settings?.INTERFACE?.theme_info?.colors?.['--color-primary']
state.publicSettings = settings
state.themeColor = matchColor[color] || defaultThemeColor
state.themeColor = color || defaultThemeColor
if (settings['XPACK_ENABLED']) {
state.hasValidLicense = settings['XPACK_LICENSE_IS_VALID']
@ -60,8 +60,8 @@ const actions = {
// 动态修改Title
document.title = data['INTERFACE']['login_title']
}
commit('SET_PUBLIC_SETTINGS', data)
getIndexStyle().then(() => {
commit('SET_PUBLIC_SETTINGS', data)
writeNewStyle(state.themeColor)
})
resolve(response)

View File

@ -30,7 +30,6 @@ import { Page } from '@/layout/components'
import { IBox, UploadField } from '@/components'
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm'
import { getInterfaceInfo, updateInterface, restoreInterface } from '@/api/interface'
import { matchColor, defaultThemeColor } from '@/utils/theme/color'
export default {
name: 'InterfaceSettings',
@ -59,10 +58,10 @@ export default {
},
theme: {
on: {
change: ([value]) => {
const color = matchColor[value] || defaultThemeColor
this.$store.dispatch('settings/changeThemeStyle', color)
}
// change: ([value]) => {
// const color = matchColor[value] || defaultThemeColor
// this.$store.dispatch('settings/changeThemeStyle', color)
// }
}
},
login_image: {