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

feat: 优化菜单加载速度

parent 0e8f6915
...@@ -50,6 +50,7 @@ module.exports = { ...@@ -50,6 +50,7 @@ module.exports = {
}, },
}, },
'/Publish': { '/Publish': {
// target: 'http://192.168.10.150:8777',
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
...@@ -65,6 +66,17 @@ module.exports = { ...@@ -65,6 +66,17 @@ module.exports = {
'/Publish': '/Publish', '/Publish': '/Publish',
}, },
}, },
'/CityTemp': {
// target: 'http://192.168.10.150:8777',
target: 'https://panda-water.cn',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/CityTemp': '/CityTemp',
},
},
}, },
prod: { prod: {
'/CityInterface': { '/CityInterface': {
......
...@@ -25,7 +25,7 @@ import './vm'; ...@@ -25,7 +25,7 @@ import './vm';
import { actionCreators } from './containers/App/store'; import { actionCreators } from './containers/App/store';
import { initMicroApps } from './micro'; import { initMicroApps } from './micro';
import history from './utils/history'; import history from './utils/history';
import { isString } from './utils/utils'; import { isString, getToken } from './utils/utils';
import i18n from './utils/share'; import i18n from './utils/share';
import { appService } from './api'; import { appService } from './api';
import Login from './pages/user/login/login'; import Login from './pages/user/login/login';
...@@ -68,7 +68,7 @@ const initGlobalConfig = () => { ...@@ -68,7 +68,7 @@ const initGlobalConfig = () => {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
let config = createStoreage.get('globalConfig') || {}; let config = createStoreage.get('globalConfig') || {};
store.dispatch(actionCreators.updateComplexConfig({})); store.dispatch(actionCreators.updateComplexConfig({}));
if (!Cookies.get('token') || config.token == null) { if (!getToken() || config.token == null) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
createStoreage.remove(namespace); createStoreage.remove(namespace);
config = {}; config = {};
...@@ -82,7 +82,7 @@ const initGlobalConfig = () => { ...@@ -82,7 +82,7 @@ const initGlobalConfig = () => {
if (!createStoreage.get('globalConfig')) { if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage(namespace); window.createStoreage = new Storeage(namespace);
} }
if (!Cookies.get('token')) { if (!getToken()) {
localStorage.removeItem('loginSite'); localStorage.removeItem('loginSite');
} }
...@@ -119,12 +119,12 @@ const initGlobalConfig = () => { ...@@ -119,12 +119,12 @@ const initGlobalConfig = () => {
), ),
); );
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
if (Cookies.get('token')) { if (getToken()) {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Login( new Login(
{ {
global: Object.assign({}, data, { global: Object.assign({}, data, {
token: Cookies.get('token'), token: getToken(),
}), }),
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
updateConfig: data => updateConfig: data =>
...@@ -132,7 +132,7 @@ const initGlobalConfig = () => { ...@@ -132,7 +132,7 @@ const initGlobalConfig = () => {
}, },
() => { () => {
(async () => { (async () => {
(await (Cookies.get('token') && (await (getToken() &&
window.globalConfig && window.globalConfig &&
window.globalConfig.token)) && initMicroApps(loader, store); window.globalConfig.token)) && initMicroApps(loader, store);
})(); })();
......
...@@ -29,6 +29,7 @@ const MICRO_STATUS = { ...@@ -29,6 +29,7 @@ const MICRO_STATUS = {
}; };
export const initMicroApps = (loader, store) => { export const initMicroApps = (loader, store) => {
console.log(window.globalConfig);
const entrys = const entrys =
process.env.NODE_ENV !== 'production' ? micorConfig.dev : micorConfig.prod; process.env.NODE_ENV !== 'production' ? micorConfig.dev : micorConfig.prod;
...@@ -38,7 +39,8 @@ export const initMicroApps = (loader, store) => { ...@@ -38,7 +39,8 @@ export const initMicroApps = (loader, store) => {
item.props = { item.props = {
emitter: window.share.event, emitter: window.share.event,
baseRoot: item.name, baseRoot: item.name,
// eslint-disable-next-line no-undef // eslint-
// disable-next-line no-undef
globalConfig: createStoreage.get('globalConfig'), globalConfig: createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest, XMLHttpRequest: window.XMLHttpRequest,
}; };
......
...@@ -405,9 +405,11 @@ const Login = forwardRef((props, _ref) => { ...@@ -405,9 +405,11 @@ const Login = forwardRef((props, _ref) => {
: null); : null);
setSubmitting(true); setSubmitting(true);
props.updateCurrentIndex && props.updateCurrentIndex(-1);
action && action &&
action.events.on('loginSuccess', event => { action.events.on('loginSuccess', event => {
setSubmitting(false); setSubmitting(false);
props.updateCurrentIndex && props.updateCurrentIndex(0);
props.history.push(`/?client=${props.global.client}`); props.history.push(`/?client=${props.global.client}`);
window.share.event.emit('triggerMicro', props.global); window.share.event.emit('triggerMicro', props.global);
}); });
...@@ -652,6 +654,9 @@ const mapDispatchToProps = dispatch => ({ ...@@ -652,6 +654,9 @@ const mapDispatchToProps = dispatch => ({
updateLoginMode(mode) { updateLoginMode(mode) {
dispatch(actionCreators.changeLoginMode(mode)); dispatch(actionCreators.changeLoginMode(mode));
}, },
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -45,7 +45,8 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -45,7 +45,8 @@ const generRotes = (widgets, parent, level = 0) => {
return return
} }
(widgets).forEach((item, index) => { (widgets).forEach((item, index) => {
if (item.hasOwnProperty('widgets') && item.widgets !== null) {
if (item.hasOwnProperty('widgets') && item.widgets !== null && Array.isArray(item.widgets) && item.widgets.length > 0) {
const _level_ = level + 1; const _level_ = level + 1;
const path = `/civweb/${guid('web_console')}`; const path = `/civweb/${guid('web_console')}`;
const subKey = guid('panda'); const subKey = guid('panda');
...@@ -96,7 +97,7 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -96,7 +97,7 @@ const generRotes = (widgets, parent, level = 0) => {
alias: item.product || DEFAULT_APPLICATION, alias: item.product || DEFAULT_APPLICATION,
extData: { extData: {
...item, ...item,
icon: (item && item.icon.replace(/\s*/g, '')) || '', icon: (item && item.icon && item.icon !== null && item.icon.replace(/\s*/g, '')) || '',
}, },
parent, parent,
}; };
......
import pathRegexp from 'path-to-regexp'; import pathRegexp from 'path-to-regexp';
import { parse } from 'querystring'; import { parse } from 'querystring';
import Cookies from 'js-cookie';
import isProd from './env';
import pkg from '../../package.json'; import pkg from '../../package.json';
const { toString } = Object.prototype; const { toString } = Object.prototype;
/* eslint no-useless-escape:0 import/prefer-default-export:0 */ /* eslint no-useless-escape:0 import/prefer-default-export:0 */
...@@ -158,5 +159,18 @@ export const asyncAction = action => { ...@@ -158,5 +159,18 @@ export const asyncAction = action => {
wait.then(() => setTimeout(() => callback())); wait.then(() => setTimeout(() => callback()));
}; };
}; };
export const combineURLs = (baseURL, relativeURL) => {
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, ''): baseURL;
}
export function getAssetsURL(relativeURL) {
//CityTemp 后端约定的本地文件夹路径
if(!relativeURL) return;
return combineURLs(window.location.origin, relativeURL);
}
export function getToken() {
return Cookies.get('token');
};
export function setToken(token) {
Cookies.set(token)
}
export const closeTabAction = (history, returnUrl, callback) => {}; export const closeTabAction = (history, returnUrl, callback) => {};
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