mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-05 18:15:28 +08:00
v3.7.2 版本代码合并
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import type { App } from 'vue';
|
||||
|
||||
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';
|
||||
import { basicRoutes } from './routes';
|
||||
import {createRouter as createVueRouter, destroyRouter, router} from './router'
|
||||
|
||||
// 白名单应该包含基本静态路由
|
||||
const WHITE_NAME_LIST: string[] = [];
|
||||
@ -13,22 +13,26 @@ const getRouteNames = (array: any[]) =>
|
||||
});
|
||||
getRouteNames(basicRoutes);
|
||||
|
||||
// app router
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
|
||||
routes: basicRoutes as unknown as RouteRecordRaw[],
|
||||
strict: true,
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
});
|
||||
/**
|
||||
* 创建路由实例
|
||||
*/
|
||||
export function createRouter() {
|
||||
let router = createVueRouter({
|
||||
routes: basicRoutes as unknown as RouteRecordRaw[],
|
||||
strict: true,
|
||||
scrollBehavior: () => ({left: 0, top: 0}),
|
||||
})
|
||||
|
||||
// TODO 【QQYUN-4517】【表单设计器】记录分享路由守卫测试
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
//console.group('【QQYUN-4517】beforeEach');
|
||||
//console.warn('from', from);
|
||||
//console.warn('to', to);
|
||||
//console.groupEnd();
|
||||
next();
|
||||
});
|
||||
// TODO 【QQYUN-4517】【表单设计器】记录分享路由守卫测试
|
||||
// @ts-ignore
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
//console.group('【QQYUN-4517】beforeEach');
|
||||
//console.warn('from', from);
|
||||
//console.warn('to', to);
|
||||
//console.groupEnd();
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
// reset router
|
||||
export function resetRouter() {
|
||||
@ -44,3 +48,8 @@ export function resetRouter() {
|
||||
export function setupRouter(app: App<Element>) {
|
||||
app.use(router);
|
||||
}
|
||||
|
||||
export {
|
||||
router,
|
||||
destroyRouter,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user