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

View File

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

View File

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