Commit 61c5715d authored by 杨思琦's avatar 杨思琦

fix: 多用户菜单修复

parent 556890fa
Pipeline #67657 passed with stages
......@@ -42,11 +42,10 @@ const proxy = require('../../../../config/proxy');
const keywordStorage = new Storage(`__global_search_keywords__micro_${window.location.hostname}`);
const recentVisitedStorage = new Storage(`__global_recent_visited__micro_${window.location.hostname}`);
const recentProductStorage = new Storage(`__global__recent_product__micro_${window.location.hostname}`);
const currentProduct = new Store(
`__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams('client') ||
sessionStorage.getItem('client') ||
'city'}`,
);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams('client') ||
sessionStorage.getItem('client') ||
'city'}`;
sessionStorage.setItem(currentProduct, 0);
Cookies.set('loginMode', Cookies.get('loginMode') || 'pdw');
export const initialState = fromJS({
globalConfig: {},
......@@ -59,7 +58,7 @@ export const initialState = fromJS({
recentKeywords: keywordStorage.list || [],
recentVisited: recentVisitedStorage.list || [],
recentProducts: recentProductStorage.list || [],
currentMenuIndex: currentProduct.get('currentMenuIndex') || 0,
currentMenuIndex: Number(sessionStorage.getItem(currentProduct)) || 0,
currentMenu: null,
collapsed: true,
loginMode: Cookies.get('loginMode') || 'pdw',
......@@ -149,7 +148,7 @@ const appReducer = (state = initialState, action) => {
const parent = home.level >= 2 ? home.parent.parent : home.level >= 3 ? home.parent.parent.parent : home.parent;
if (parent) {
currentMenuIndex = generMenu.findIndex(item => item.name === parent.label);
currentProduct.set('currentMenuIndex', currentMenuIndex);
sessionStorage.setItem(currentProduct, currentMenuIndex)
store.set('updateMenuIndex', currentMenuIndex);
}
}
......@@ -205,9 +204,9 @@ const appReducer = (state = initialState, action) => {
recentVisited: [],
});
case GET_CURRENT_INDEX:
currentProduct.set('currentMenuIndex', action.data);
sessionStorage.setItem(currentProduct, action.data)
return state.merge({
currentMenuIndex: currentProduct.get('currentMenuIndex'),
currentMenuIndex: Number(sessionStorage.getItem(currentProduct)),
});
case SLIDER_MENU_MODE:
return state.merge({
......
......@@ -19,7 +19,6 @@ import { useHistory, useLocation } from '@wisdom-utils/runtime';
import { helpers, store, event } from '@wisdom-utils/utils';
import { Storeage as Store } from '@wisdom-utils/utils/lib/helpers';
import Loading from '../components/Loading';
import { waterMark } from '../utils/mark';
import layoutStyles from './BasicLayout.less';
import SecurityLayout from './SecurityLayout';
......@@ -245,11 +244,9 @@ const transformFloatMenu = (routes, homepage) => {
};
const Layout = props => {
const currentProduct = new Store(
`__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams('client') ||
sessionStorage.getItem('client') ||
'city'}`,
);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams('client') ||
sessionStorage.getItem('client') ||
'city'}`;
const menuState = sessionStorage.getItem('menuState') || 'open';
const [cityData, setCityData] = useState({});
const [siteLoading, setSiteLoading] = useState(false);
......@@ -419,7 +416,7 @@ const Layout = props => {
// onLoadingChange: (loading) => setMenuLoading(loading)
}}
logo={logo}
topMenuActiveKey={currentProduct.get('currentMenuIndex') || 0}
topMenuActiveKey={Number(sessionStorage.getItem(currentProduct)) || 0}
rightContentRender={() => <RightContent />}
onPageChange={() => {
// if(!props.global.token) {
......
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