1.子应用点击回退路径错乱
if (window.__MICRO_APP_ENVIRONMENT__) {
const realBaseRoute = window.__MICRO_APP_BASE_ROUTE__;
router.beforeEach(() => {
if (typeof window.history.state?.current === 'string') {
window.history.state.current = window.history.state.current.replace(
new RegExp(realBaseRoute, 'g'),
'',
);
}
});
router.afterEach(() => {
if (typeof window.history.state === 'object') {
window.history.state.current =
realBaseRoute + (window.history.state.current || '');
}
});
}
router.beforeEach(async (to, from, next) => {
if(to.path === from.path) {
next();
return;
}
if (from.fullPath.startsWith('/micro/')) {
if (window.history.state) {
window.history.state.current = from.fullPath;
}
}
if (!history?.state?.current) {
assign(history.state, {
current: from.fullPath });
}
next();
});