Commit d06e4b62 authored by 徐乐's avatar 徐乐

feat: 修改

parent 00db07f4
...@@ -42,9 +42,7 @@ const proxy = require('../../../../config/proxy'); ...@@ -42,9 +42,7 @@ const proxy = require('../../../../config/proxy');
const keywordStorage = new Storage(`__global_search_keywords__micro_${window.location.hostname}`); const keywordStorage = new Storage(`__global_search_keywords__micro_${window.location.hostname}`);
const recentVisitedStorage = new Storage(`__global_recent_visited__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 recentProductStorage = new Storage(`__global__recent_product__micro_${window.location.hostname}`);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams('client') || const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${sessionStorage.getItem('client') || params.getParams('client') || 'city'}`;
sessionStorage.getItem('client') ||
'city'}`;
sessionStorage.setItem(currentProduct, 0); sessionStorage.setItem(currentProduct, 0);
Cookies.set('loginMode', Cookies.get('loginMode') || 'pdw'); Cookies.set('loginMode', Cookies.get('loginMode') || 'pdw');
export const initialState = fromJS({ export const initialState = fromJS({
...@@ -102,27 +100,27 @@ const appReducer = (state = initialState, action) => { ...@@ -102,27 +100,27 @@ const appReducer = (state = initialState, action) => {
const { homepage } = window.globalConfig; const { homepage } = window.globalConfig;
const modulePkg = {}; const modulePkg = {};
window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => { window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => {
modulePkg[item.PackageName] = item; modulePkg[item.PackageName] = item;
}); });
config.widgets =transformWidgets(config.widgets); config.widgets = transformWidgets(config.widgets);
// const pickMenus = memoized(() => ) // const pickMenus = memoized(() => )
const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg); const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg);
let flatMenu = []; let flatMenu = [];
if (generMenu) { if (generMenu) {
const flat = state.toJS(); const flat = state.toJS();
const data =_.uniqBy(generFlatRoutes(generMenu || [], null, null, modulePkg), 'path'); const data = _.uniqBy(generFlatRoutes(generMenu || [], null, null, modulePkg), 'path');
if(_.isEqualWith(flat.flatMenu, data, (value, other) => { if (_.isEqualWith(flat.flatMenu, data, (value, other) => {
if(value.path === other.path) { if (value.path === other.path) {
return true return true
} }
})) { })) {
flatMenu = data flatMenu = data
} else { } else {
flatMenu = flat.flatMenu flatMenu = flat.flatMenu
} }
const index = flatMenu.findIndex(item => item.name === '首页'); const index = flatMenu.findIndex(item => item.name === '首页');
if(index === -1) { if (index === -1) {
flatMenu.push({ flatMenu.push({
path: `/${homepage}`, path: `/${homepage}`,
href: `/${homepage}`, href: `/${homepage}`,
...@@ -141,7 +139,7 @@ const appReducer = (state = initialState, action) => { ...@@ -141,7 +139,7 @@ const appReducer = (state = initialState, action) => {
return currentPath === decodeURI(homepage); return currentPath === decodeURI(homepage);
}); });
let currentMenuIndex = 0; let currentMenuIndex = 0;
if (home) { if (home) {
...@@ -204,9 +202,10 @@ const appReducer = (state = initialState, action) => { ...@@ -204,9 +202,10 @@ const appReducer = (state = initialState, action) => {
recentVisited: [], recentVisited: [],
}); });
case GET_CURRENT_INDEX: case GET_CURRENT_INDEX:
sessionStorage.setItem(currentProduct, action.data) const currentProductNew = `__global__recent_productIndex__micro_${window.location.hostname}_${sessionStorage.getItem('client') || window.globalConfig?.client || 'city'}`;
sessionStorage.setItem(currentProductNew, action.data)
return state.merge({ return state.merge({
currentMenuIndex: Number(sessionStorage.getItem(currentProduct)), currentMenuIndex: Number(sessionStorage.getItem(currentProductNew)),
}); });
case SLIDER_MENU_MODE: case SLIDER_MENU_MODE:
return state.merge({ return state.merge({
......
...@@ -514,6 +514,16 @@ const Layout = props => { ...@@ -514,6 +514,16 @@ const Layout = props => {
} }
} else { } else {
let cli = val.url?.indexOf('client=') >= 0 ? val.url.split('client=')[1] : ''; let cli = val.url?.indexOf('client=') >= 0 ? val.url.split('client=')[1] : '';
Cookies.set('client', cli, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', cli);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${window.globalConfig?.client ?? 'city'}`;
sessionStorage.removeItem(currentProduct);
const currentProductNew = `__global__recent_productIndex__micro_${window.location.hostname}_${cli || 'city'}`;
sessionStorage.setItem(currentProductNew, 0);
setIntegrationLoading(true); setIntegrationLoading(true);
const config = props.global; const config = props.global;
config.uiwidgets = []; config.uiwidgets = [];
...@@ -523,7 +533,7 @@ const Layout = props => { ...@@ -523,7 +533,7 @@ const Layout = props => {
config.client = cli; config.client = cli;
} }
props.instance && props.instance.updateConfig(config); props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, val.type, cli); loginAction && loginAction.getUserInfoAndConfig('', true, val.type);
// props.history.push(`/?client=${cli}`); // props.history.push(`/?client=${cli}`);
// props.updateCurrentIndex(0); // props.updateCurrentIndex(0);
// defaultApp(); // defaultApp();
......
...@@ -8,6 +8,7 @@ import { useDocumentTitle } from '@ant-design/pro-utils'; ...@@ -8,6 +8,7 @@ import { useDocumentTitle } from '@ant-design/pro-utils';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import LoginAction from '@/pages/user/login/login'; import LoginAction from '@/pages/user/login/login';
import Cookies from 'js-cookie';
import { defaultApp } from '@/micro'; import { defaultApp } from '@/micro';
import { appService } from '@/api'; import { appService } from '@/api';
import { SERVICE_INTERFACE_SUCCESS_CODE } from '@/constants'; import { SERVICE_INTERFACE_SUCCESS_CODE } from '@/constants';
...@@ -24,6 +25,7 @@ const Integration = props => { ...@@ -24,6 +25,7 @@ const Integration = props => {
const [client, setClient] = useState(''); const [client, setClient] = useState('');
//子站跳转
const handlePage = (item, loginAction) => { const handlePage = (item, loginAction) => {
let count = 1; let count = 1;
setPercentBottom(-40 + Math.ceil(Math.random() * 8 * count)); setPercentBottom(-40 + Math.ceil(Math.random() * 8 * count));
...@@ -61,6 +63,17 @@ const Integration = props => { ...@@ -61,6 +63,17 @@ const Integration = props => {
} }
} else { } else {
let cli = item.url?.indexOf('client=') >= 0 ? item.url.split('client=')[1] : ''; let cli = item.url?.indexOf('client=') >= 0 ? item.url.split('client=')[1] : '';
Cookies.set('client', cli, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', cli);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${window.globalConfig?.client ?? 'city'}`;
sessionStorage.removeItem(currentProduct);
const currentProductNew = `__global__recent_productIndex__micro_${window.location.hostname}_${cli || 'city'}`;
sessionStorage.setItem(currentProductNew, 0);
setClient(cli); setClient(cli);
setCurrentType(item.name); setCurrentType(item.name);
...@@ -72,7 +85,7 @@ const Integration = props => { ...@@ -72,7 +85,7 @@ const Integration = props => {
config.client = cli config.client = cli
} }
// props.instance && props.instance.updateConfig(config); props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, item.type, cli); loginAction && loginAction.getUserInfoAndConfig('', true, item.type, cli);
} }
}; };
......
...@@ -930,19 +930,11 @@ class Login { ...@@ -930,19 +930,11 @@ class Login {
}); });
} }
getUserInfoAndConfig(failCallback, flag, industry, client) { getUserInfoAndConfig(failCallback, flag, industry) {
const { token: tk } = this.globalConfig; const { token: tk } = this.globalConfig;
const token = tk || Cookies.get('token'); const token = tk || Cookies.get('token');
const site = Cookies.get('site'); const site = Cookies.get('site');
const self = this; const self = this;
if (client) {
self.globalConfig.client = client;
Cookies.set('client', client, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', client);
}
/* eslint-disable */ /* eslint-disable */
let _industrySite = null; let _industrySite = null;
......
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