Commit 3a39c1b5 authored by 邓晓峰's avatar 邓晓峰

fix: 修复首页加载逻辑

parent e83f482c
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
// }, // },
{ {
name: 'civ_pandawork', name: 'civ_pandawork',
entry: `//${window.location.hostname}:8081/civ_pandawork`, entry: `//${window.location.hostname}:8080/civ_pandawork`,
container: '#micro-container', container: '#micro-container',
activeRule: '/civbase/civ_pandawork', activeRule: '/civbase/civ_pandawork',
}, },
......
...@@ -7,6 +7,7 @@ import { Storage } from '@wisdom-utils/utils'; ...@@ -7,6 +7,7 @@ import { Storage } from '@wisdom-utils/utils';
import pkg from '../../../../package.json'; import pkg from '../../../../package.json';
import defaultSetting from '../../../../config/defaultSetting'; import defaultSetting from '../../../../config/defaultSetting';
import generRoutes, { generFlatRoutes } from '../../../utils/routes'; import generRoutes, { generFlatRoutes } from '../../../utils/routes';
import { transformWidgets } from '../../../utils/routes';
import { import {
CLEAR_RCENT_KEYWORD, CLEAR_RCENT_KEYWORD,
COMPLEX_CONFIG, COMPLEX_CONFIG,
...@@ -105,6 +106,7 @@ const appReducer = (state = initialState, action) => { ...@@ -105,6 +106,7 @@ const appReducer = (state = initialState, action) => {
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);
const generMenu = generRoutes(config.widgets || [], null, 0, modulePkg); const generMenu = generRoutes(config.widgets || [], null, 0, modulePkg);
let flatMenu = []; let flatMenu = [];
if(generMenu) { if(generMenu) {
......
...@@ -543,7 +543,7 @@ const BasicLayout = props => { ...@@ -543,7 +543,7 @@ const BasicLayout = props => {
<div className={layoutStyles.splitLine}></div> <div className={layoutStyles.splitLine}></div>
<ul className={classNames(layoutStyles.menu, 'menu-vertical')}> <ul className={classNames(layoutStyles.menu, 'menu-vertical')}>
{ {
currentRoutes && (currentRoutes.routes || []).map((item, index) => { currentRoutes && (currentRoutes.routes || []).filter(item => !item.hideInMenu).map((item, index) => {
return ( return (
<React.Fragment key={index}> <React.Fragment key={index}>
<li key={index} className={classNames(layoutStyles['menu-item'], { [layoutStyles['active']]: index === selectIndex })} onClick={() => handlerSecond(item, index)}> <li key={index} className={classNames(layoutStyles['menu-item'], { [layoutStyles['active']]: index === selectIndex })} onClick={() => handlerSecond(item, index)}>
......
...@@ -17,6 +17,7 @@ import { actionCreators } from './containers/App/store'; ...@@ -17,6 +17,7 @@ import { actionCreators } from './containers/App/store';
import { FILTER_FOLER_REG } from './utils/constants'; import { FILTER_FOLER_REG } from './utils/constants';
import loader from './render'; import loader from './render';
import store from './stores'; import store from './stores';
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const Logger = logger('micro'); const Logger = logger('micro');
const MICRO_STATUS = { const MICRO_STATUS = {
...@@ -72,7 +73,7 @@ export const initMicroApps = () => { ...@@ -72,7 +73,7 @@ export const initMicroApps = () => {
process.env.NODE_ENV !== 'production' ? process.env.NODE_ENV !== 'production' ?
micorConfig.dev : micorConfig.dev :
products; products;
registerMicroApps( registerMicroApps(
entrys.map(item => { entrys.map(item => {
item.loader = loader; item.loader = loader;
...@@ -221,12 +222,12 @@ export const defaultApp = () => { ...@@ -221,12 +222,12 @@ export const defaultApp = () => {
// setDefaultMountApp(`/${pkg.name.toLocaleLowerCase()}/${basePath}${homepage}`); // setDefaultMountApp(`/${pkg.name.toLocaleLowerCase()}/${basePath}${homepage}`);
// createStoreage.set('init_web4', true) // createStoreage.set('init_web4', true)
// } // }
setDefaultMountApp(`/civbase/${config.homepage.replace(/^\//, '')}`);
if(/civweb4/.test(config.homepage)) { // if(/civweb4/.test(config.homepage)) {
setDefaultMountApp(`/civbase/${config.homepage.replace(/^\//, '')}`); // setDefaultMountApp(`/civbase/${config.homepage.replace(/^\//, '')}`);
} else { // } else {
setDefaultMountApp(`/civbase/${config.home.path.replace(/^\//, '')}`); // setDefaultMountApp(`/civbase/${config.home.path.replace(/^\//, '')}`);
} // }
//setDefaultMountApp(`/civbase/${config.homepage.replace(/^\//, '')}`); //setDefaultMountApp(`/civbase/${config.homepage.replace(/^\//, '')}`);
if(config.homepage.indexOf('civweb4') > -1) createStoreage.set('init_web4', true); if(config.homepage.indexOf('civweb4') > -1) createStoreage.set('init_web4', true);
} }
......
...@@ -36,6 +36,7 @@ const getURL = url => { ...@@ -36,6 +36,7 @@ const getURL = url => {
}; };
const generRotes = (widgets, parent, level = 0) => { const generRotes = (widgets, parent, level = 0) => {
const ret = []; const ret = [];
if(!widgets || widgets.length === 0){ if(!widgets || widgets.length === 0){
return return
...@@ -117,6 +118,29 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -117,6 +118,29 @@ const generRotes = (widgets, parent, level = 0) => {
}); });
return ret; return ret;
}; };
export const transformWidgets = (widgets) => {
if(!widgets || widgets.length === 0) {
return []
}
return widgets.map(item => {
const widgets = item.widgets;
const homepage = window.globalConfig.homepage;
const homePageConvertArray = homepage.split("/");
const findIndex = widgets && widgets.findIndex(item => item.label === '系统菜单组');
if(findIndex === -1) {
widgets.push({
label: "系统菜单组",
icon: '',
product: homePageConvertArray[0],
shortName: "首页",
url: homePageConvertArray.slice(1, homePageConvertArray.length).join("/")
});
item.widgets = widgets;
}
return item;
});
}
export function simpleNormalizeChildren(children) { export function simpleNormalizeChildren(children) {
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
if (Array.isArray(children[i])) { if (Array.isArray(children[i])) {
......
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