Commit bfebd780 authored by 崔佳豪's avatar 崔佳豪

fix: 站点切换支持改变主题

parent 82fa49ff
Pipeline #54946 passed with stages
...@@ -376,7 +376,22 @@ class Login { ...@@ -376,7 +376,22 @@ class Login {
self.globalConfig.shortcutIcon = mainConf.shortcutIcon; self.globalConfig.shortcutIcon = mainConf.shortcutIcon;
if (mainConf && mainConf.hasOwnProperty('topMenu')) if (mainConf && mainConf.hasOwnProperty('topMenu'))
self.globalConfig.topMenu = mainConf.topMenu; self.globalConfig.topMenu = mainConf.topMenu;
if (mainConf && mainConf.navTheme) self.globalConfig.navTheme = mainConf.navTheme; // 云平台统一navTheme if (mainConf && mainConf.navTheme && self.globalConfig.CloudStyle !== '否') self.globalConfig.navTheme = mainConf.navTheme; // 云平台统一navTheme
// 云平台切换站点 应用站点自己主题配置
if (config.CloudStyle === '否') {
self.globalConfig.variableTheme = {
primaryColor: config.primaryColor,
navTheme: config.navTheme,
headerPrimaryColor: config.headerPrimaryColor,
}
} else {
self.globalConfig.variableTheme = {
primaryColor: mainConf.primaryColor,
navTheme: mainConf.navTheme,
headerPrimaryColor: mainConf.headerPrimaryColor,
}
}
// if (mainConf.productType) // if (mainConf.productType)
// self.globalConfig.productType = mainConf.productType; // self.globalConfig.productType = mainConf.productType;
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
......
...@@ -230,46 +230,33 @@ export const AppInitState = () => { ...@@ -230,46 +230,33 @@ export const AppInitState = () => {
) return false ) return false
return true return true
} }
/** store.subscribe((function() {
* @param {Object} theme let preVariableTheme = store.getState().toJS().global?.globalConfig?.variableTheme;
* primaryColor: return function() {
* navTheme: "dark" or "light" // if (!preVariableTheme)
* headerPrimaryColor: const variableTheme = store.getState().toJS().global?.globalConfig?.variableTheme;
*/ if(!hasThemeChanged(preVariableTheme, variableTheme)) return false
window.share && window.share.event && window.share.event.on('update:theme', function(theme) { const {
if(!theme || !hasThemeChanged(window.globalConfig.variableTheme, theme)) return; primaryColor: prePrimaryColor,
navTheme: preNavTheme,
const preVariableTheme = window.globalConfig.variableTheme ?? {}; headerPrimaryColor: preHeaderPrimaryColor,
const { } = (preVariableTheme || {});
primaryColor: prePrimaryColor, const { primaryColor, headerPrimaryColor } = variableTheme;
navTheme: preNavTheme, if (primaryColor && primaryColor !== prePrimaryColor) {
headerPrimaryColor: preHeaderPrimaryColor, ConfigProvider.config({
} = preVariableTheme; prefixCls: customPrefixCls,
const { primaryColor, navTheme, headerPrimaryColor } = theme; theme: {
primaryColor,
if (primaryColor && primaryColor !== prePrimaryColor) { }
ConfigProvider.config({ });
prefixCls: customPrefixCls, }
theme: { if (headerPrimaryColor && headerPrimaryColor !== preHeaderPrimaryColor) {
primaryColor, registerTheme(customPrefixCls, {
} 'header-bg-color': headerPrimaryColor,
}); });
} }
if (navTheme && navTheme !== preNavTheme) {
// do nothing
}
if (headerPrimaryColor && headerPrimaryColor !== preHeaderPrimaryColor) {
registerTheme(customPrefixCls, {
'header-bg-color': headerPrimaryColor,
});
} }
})())
// updage global config
const variableTheme = Object.assign({}, preVariableTheme, theme);
store.dispatch(actionCreators.getConfig(Object.assign({}, window.globalConfig, {
variableTheme: variableTheme,
})));
})
}; };
initLocale(); initLocale();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment