Files
qhmes/jeecgboot-vue3/src/qiankun/route.ts

46 lines
1.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// import { router } from "@/router";
// import { apps } from './apps';
//
// export const {registerQiankunRouter} = (function () {
//
// let registered = false;
//
// /**
// * 注册qiankun路由
// */
// function registerQiankunRouter() {
// if (!router) {
// // 如果路由对象不存在,递归调用,直到路由对象可用
// setTimeout(() => registerQiankunRouter(), 1);
// } else {
// registerQiankunRouterNow();
// }
// }
//
// function registerQiankunRouterNow() {
// if (registered) {
// return;
// }
// registered = true;
// const checkQiankunRoute = (path: string) => apps.some(app => path.startsWith('/' + app.name));
// // 添加路由守卫
// // 路由守卫判断是否是qiankun子应用路由
// router.beforeEach(async (to, from, next) => {
// const isQiankunRoute = checkQiankunRoute(to.path);
// if (isQiankunRoute) {
// // 如果是qiankun子应用路由设置meta属性
// to.meta.isQiankunRoute = true;
// } else {
// // 如果不是qiankun子应用路由清除meta属性
// delete to.meta.isQiankunRoute;
// }
// next();
// });
// }
//
//
// return {
// registerQiankunRouter,
// }
// })();