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

feat: 优化菜单加载速度

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