Merge pull request #77 from ice-lab/fix-plugin-icestark

fix: get appLeave from layout
This commit is contained in:
chenbin92 2020-03-03 16:18:41 +08:00 committed by GitHub
commit 139040d94a
1 changed files with 13 additions and 17 deletions

View File

@ -75,11 +75,10 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
modifyRoutes(removeRootLayout); modifyRoutes(removeRootLayout);
} }
const frameworkRouter = (routes) => () => { const frameworkRouter = (routes) => () => {
const [appInfo, setAppInfo] = useState({ const [appPathname, setAppPathname] = useState('');
pathname: '', const [appEnter, setAppEnter] = useState({});
appEnter: {}, const [appLeave, setAppLeave] = useState({});
appLeave: {}
});
const [apps, setApps] = useState(null); const [apps, setApps] = useState(null);
const routerProps = { const routerProps = {
type, type,
@ -98,26 +97,23 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
}, []); }, []);
function handleRouteChange(pathname) { function handleRouteChange(pathname) {
setAppInfo({ setAppPathname(pathname);
...appInfo,
pathname,
});
} }
function handleAppLeave(config) { function handleAppLeave(config) {
setAppInfo({ setAppLeave(config);
...appInfo,
appLeave: config,
});
} }
function handleAppEnter(config) { function handleAppEnter(config) {
setAppInfo({ setAppEnter(config);
...appInfo,
appEnter: config,
});
} }
const appInfo = {
pathname: appPathname,
appEnter,
appLeave,
};
return ( return (
<BasicLayout {...appInfo}> <BasicLayout {...appInfo}>
{apps && ( {apps && (