Commit eb641324 authored by 邓晓峰's avatar 邓晓峰

fix: 修复多用户切换,用户信息错乱

parent fa23b26e
......@@ -79,6 +79,26 @@ module.exports = {
'/PandaCore': '/PandaCore',
},
},
'/PandaInformatization': {
target: proxyURL,
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/PandaInformatization': '/PandaInformatization',
},
},
'/PandaWorkFlow': {
target: proxyURL,
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/PandaWorkFlow': '/PandaWorkFlow',
},
},
'/CityTemp': {
// target: 'http://192.168.10.150:8777',
target: proxyURL,
......
......@@ -8,114 +8,33 @@ import 'antd/dist/antd.less';
import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions
import 'kit_utils/lib/format';
import 'sanitize.css/sanitize.css';
// import './locales/zh-CN';
// import './loader';
// import './vm';
import React from 'react';
import ReactDOM from 'react-dom';
import { event } from 'microser-data';
import _ from 'lodash';
import { Button, ConfigProvider, message, notification } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable';
import Immutable from 'immutable';
import { params, Storeage } from 'kit_utils';
import { Provider } from 'react-redux';
import { ConfigProvider} from 'antd';
import { Storeage } from 'kit_utils';
import { history } from '@wisdom-utils/runtime';
import ErrorBoundary from './components/ErrorBoundary';
// import themePluginConfig from '../config/themePluginConfig';
import { appService } from './api';
// import { updateTheme } from './common/helpers/settingColor';
import Container from './components/Container';
import configureStore from './configureStore';
import App from './containers/App';
import { actionCreators } from './containers/App/store';
import { LocaleContainer } from './locales/locale';
import { initMicroApps } from './micro';
// import { initMicroApps } from './micro';
import { initGlobalConfig } from './initConfig'
import './utils/event';
import store from './stores'
// import Cookies from 'js-cookie';
// eslint-disable-next-line no-restricted-globals
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
// eslint-disable-next-line no-underscore-dangle
const initialState = Immutable.Map();
const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById('root');
ConfigProvider.config({
prefixCls: 'panda-console-base'
});
const render = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<LocaleContainer>
<ConfigProvider prefixCls="panda-console-base">
<ErrorBoundary>
<Container>
<App />
</Container>
</ErrorBoundary>
</ConfigProvider>
</LocaleContainer>
</ConnectedRouter>
</Provider>,
MOUNT_NODE,
);
};
// updateTheme('#ff9600');
const loader = (appContent, loading) => render({ appContent, loading });
const initLocale = () => {
localStorage.setItem('umi_locale', 'zh-CN');
};
const PRODUCT_NAME = ['civ_water', 'civ_monitor'];
const initSensorType = () => {
let filterProduct =
(window.globalConfig && window.globalConfig.products) || [];
filterProduct = filterProduct.filter(item =>
PRODUCT_NAME.includes(item.PackageName),
);
if (filterProduct.length > 0) {
appService.getSensorType().then(res => {
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, {
sensorType: res.data,
}),
),
);
});
}
};
// const PRODUCT_NAME = ['civ_water', 'civ_monitor'];
const initIsMock = () => {
appService
.sysConfiguration({
moduleName: '是否mock数据',
})
.then(res => {
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, {
isMock: res.data === '是',
}),
),
);
});
};
initGlobalConfig(loader, store, render);
initGlobalConfig();
initLocale();
window.share && window.share.event && window.share.event.on('triggerMicro', () => {
initMicroApps(loader, store);
});
const unlisten = history.listen(location => {
if(location.pathname.indexOf('/civbase/user/login') > -1) {
initGlobalConfig(loader, store, render);
initGlobalConfig();
}
})
......
......@@ -76,6 +76,7 @@ export const initialState = fromJS({
const appReducer = (state = initialState, action) => {
switch (action.type) {
case GET_CONFIG:
debugger
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-underscore-dangle
window.__INITIAL_STATE__ = Object.assign(
......
......@@ -3,16 +3,19 @@ import { initMicroApps } from './micro';
import { params, Storeage } from 'kit_utils';
import { actionCreators } from './containers/App/store';
import { getToken, isString } from './utils/utils';
import loader, { render } from './render';
import store from './stores';
import Login from './pages/user/login/login';
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
export const initGlobalConfig = (loader, store, render) => {
export const initGlobalConfig = () => {
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-undef
createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
window.globalConfig = {};
let config = createStoreage.get('globalConfig') || {};
window.__INITIAL_STATE__ = {};
let config = window.globalConfig || {};
//createStoreage.get('globalConfig') || {};
store.dispatch(actionCreators.updateComplexConfig({}));
if (!getToken() || config.token == null) {
// eslint-disable-next-line no-undef
......@@ -32,8 +35,8 @@ export const initGlobalConfig = (loader, store, render) => {
localStorage.removeItem('loginSite');
}
if (config.token !== null && Object.keys(config).length > 0) {
store.dispatch(actionCreators.getConfig(config));
if (window.globalConfig.token !== null && Object.keys(window.globalConfig).length > 0) {
store.dispatch(actionCreators.getConfig(window.globalConfig));
// render({ appContent: '', loading: true });
initMicroApps(loader, store);
if (config.isNewYear) {
......
......@@ -9,12 +9,14 @@ import {
setDefaultMountApp,
start,
} from 'qiankun';
import { store as microStore } from 'microser-data';
import micorConfig, { genActiveRule } from '../config/micor';
import pkg from '../package.json';
import { actionCreators } from './containers/App/store';
import { FILTER_FOLER_REG } from './utils/constants';
import loader from './render';
import store from './stores';
// eslint-disable-next-line no-undef
const Logger = logger('micro');
const MICRO_STATUS = {
......@@ -32,12 +34,15 @@ const MICRO_STATUS = {
LOAD_ERROR: 'LOAD_ERROR',
};
export const initMicroApps = (loader, store) => {
export const initMicroApps = () => {
debugger
/* eslint-disable */
const config = createStoreage.get('globalConfig');
const config = window.globalConfig || {};
//createStoreage.get('globalConfig');
const application = config && config.products || [];
let products = [];
application && Array.isArray(application) && application.length > 0 && application.map(item => {
if(item.PackageName === 'report') {
products.push({
......@@ -77,7 +82,8 @@ export const initMicroApps = (loader, store) => {
baseRoot: item.name,
// eslint-
// disable-next-line no-undef
globalConfig: createStoreage.get('globalConfig'),
globalConfig: config,
//createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest,
};
return item;
......@@ -103,6 +109,8 @@ export const initMicroApps = (loader, store) => {
app => {
window.share.event.removeAllListeners('changeRoute');
Logger.info(`[LifeCycle] after unmount %c%s ${app.name}`);
window.globalConfig = {}
createStoreage.remove(`__PANDA_STORE__${location.hostname}`)
},
],
afterUnmount: [app => {}],
......@@ -111,12 +119,19 @@ export const initMicroApps = (loader, store) => {
const globalStore = store.getState().toJS();
const { setGlobalState } = initGlobalState({
// eslint-disable-next-line no-undef
globalConfig: createStoreage.get('globalConfig'),
globalConfig: window.globalConfig,
//createStoreage.get('globalConfig'),
global: globalStore.global
});
setGlobalState({
// eslint-disable-next-line no-undef
globalConfig: createStoreage.get('globalConfig'),
globalConfig: window.globalConfig,
//createStoreage.get('globalConfig'),
});
microStore.set("props:globalConfig", {
globalConfig: window.globalConfig,
global: globalStore.global
});
start({
sandbox: {
......
......@@ -601,7 +601,7 @@ class Login {
generateType: params.getParams('generateType') || ''
})
.then(response => {
debugger
self.globalConfig.layout = 'blank';
if (response && response.token) {
......@@ -645,7 +645,7 @@ class Login {
expires: date,
path: '/',
})
debugger
// self.globalConfig.Industry = industry;
self.updateConfig && self.updateConfig(self.globalConfig);
const loginSite = {};
......
......@@ -17,6 +17,7 @@ import styles from '../style.less';
import useRenderQcode from '../js/useRenderQcode';
import Account from '../js/useAccount';
import IotComponent from '../js/useIOTComponent';
import { initMicroApps } from '../../../../micro';
const Login = forwardRef((props, _ref) => {
const videoRef = useRef();
const loginRef = useRef();
......@@ -62,7 +63,9 @@ const Login = forwardRef((props, _ref) => {
setSubmitting(false);
props.updateCurrentIndex && props.updateCurrentIndex(0);
props.history.push(`/?client=${props.global.client}`);
window.share.event.emit('triggerMicro', props.global);
// debugger
// window.share.event.emit('triggerMicro', props.global);
initMicroApps();
});
action && action.events.on('loginError', event => {
setVisible(false);
......@@ -78,7 +81,8 @@ const Login = forwardRef((props, _ref) => {
action &&
action.events.on('loginSuccess', event => {
props.history.push(`/?client=${props.global.client}`);
window.share.event.emit('triggerMicro', props.global);
// window.share.event.emit('triggerMicro', props.global);
initMicroApps();
});
action &&
action.events.on('loginError', event => {
......
......@@ -24,6 +24,7 @@ import UnSelected from '@/assets/oa/login/unselected.jpg'
import LoginAction from '../login';
import { actionCreators } from '@/containers/App/store';
import Cookies from 'js-cookie';
import { initMicroApps } from '../../../../micro';
const Logger = logger('login');
// 、登录页
class InfoLogin extends React.Component{
......@@ -108,7 +109,8 @@ changeQrCode=(item)=>{
action && action.events.on('loginSuccess', event => {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
this.props.history.push(`/?client=${this.props.global.client}`);
window.share.event.emit('triggerMicro', this.props.global);
// window.share.event.emit('triggerMicro', this.props.global);
initMicroApps();
});
action && action.events.on('loginError', event => {
......
......@@ -20,6 +20,7 @@ import LoginAction from '../login';
import { actionCreators } from '@/containers/App/store';
import Cookies from 'js-cookie';
import QRCode from 'qrcode.react';
import { initMicroApps } from '../../../../micro';
const Logger = logger('login');
// 、登录页
class InfoLogin extends React.Component {
......@@ -139,7 +140,8 @@ class InfoLogin extends React.Component {
action && action.events.on('loginSuccess', event => {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
this.props.history.push(`/?client=${this.props.global.client}`);
window.share.event.emit('triggerMicro', this.props.global);
// window.share.event.emit('triggerMicro', this.props.global);
initMicroApps();
});
action && action.events.on('loginError', event => {
......
import React from 'react';
import ReactDOM from 'react-dom';
import store from './stores'
import { history } from '@wisdom-utils/runtime';
import { Provider } from 'react-redux';
import { ConfigProvider } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable';
import ErrorBoundary from './components/ErrorBoundary';
import Container from './components/Container';
import { LocaleContainer } from './locales/locale';
import App from './containers/App';
const MOUNT_NODE = document.getElementById('root');
export const render = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<LocaleContainer>
<ConfigProvider prefixCls="panda-console-base">
<ErrorBoundary>
<Container>
<App />
</Container>
</ErrorBoundary>
</ConfigProvider>
</LocaleContainer>
</ConnectedRouter>
</Provider>,
MOUNT_NODE,
);
};
// updateTheme('#ff9600');
const loader = (appContent, loading) => render({ appContent, loading });
export default loader;
\ No newline at end of file
import { history } from '@wisdom-utils/runtime';
import Immutable from 'immutable';
const initialState = Immutable.Map();
import configureStore from './configureStore';
const store = configureStore(initialState, history);
export default store;
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