mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-03 20:35:29 +08:00
v3.7.2 版本代码合并
This commit is contained in:
@ -9,7 +9,7 @@ import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic';
|
||||
|
||||
import { RootRoute } from '/@/router/routes';
|
||||
|
||||
import { isOAuth2AppEnv } from '/@/views/sys/login/useLogin';
|
||||
import {isOAuth2AppEnv, isOAuth2DingAppEnv} from '/@/views/sys/login/useLogin';
|
||||
import { OAUTH2_THIRD_LOGIN_TENANT_ID } from "/@/enums/cacheEnum";
|
||||
import { setAuthCache } from "/@/utils/auth";
|
||||
import { PAGE_NOT_FOUND_NAME_404 } from '/@/router/constant';
|
||||
@ -159,7 +159,13 @@ export function createPermissionGuard(router: Router) {
|
||||
//==============================【首次登录并且是企业微信或者钉钉的情况下才会调用】==================
|
||||
//判断是免登录页面,如果页面包含/tenantId/,那么就直接前往主页
|
||||
if(isOAuth2AppEnv() && to.path.indexOf("/tenantId/") != -1){
|
||||
next(userStore.getUserInfo.homePath || PageEnum.BASE_HOME);
|
||||
//update-begin---author:wangshuai---date:2024-11-08---for:【TV360X-2958】钉钉登录后打开了敲敲云,换其他账号登录后,再打开敲敲云显示的是原来账号的应用---
|
||||
if (isOAuth2DingAppEnv()) {
|
||||
next(OAUTH2_LOGIN_PAGE_PATH);
|
||||
} else {
|
||||
next(userStore.getUserInfo.homePath || PageEnum.BASE_HOME);
|
||||
}
|
||||
//update-end---author:wangshuai---date:2024-11-08---for:【TV360X-2958】钉钉登录后打开了敲敲云,换其他账号登录后,再打开敲敲云显示的是原来账号的应用---
|
||||
return;
|
||||
}
|
||||
//==============================【首次登录并且是企业微信或者钉钉的情况下才会调用】==================
|
||||
|
||||
@ -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,
|
||||
}
|
||||
|
||||
40
jeecgboot-vue3/src/router/router.ts
Normal file
40
jeecgboot-vue3/src/router/router.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 路由实例存储文件,请勿轻易添加其他代码,防止出现 HMR 或其他问题
|
||||
*/
|
||||
import type {Router, RouterHistory} from 'vue-router';
|
||||
import {createRouter as createVueRouter, createWebHistory, RouterOptions} from 'vue-router';
|
||||
|
||||
export let router: Router = null as unknown as Router;
|
||||
|
||||
export function setRouter(r: Router) {
|
||||
router = r
|
||||
}
|
||||
|
||||
let webHistory: Nullable<RouterHistory> = null;
|
||||
|
||||
/**
|
||||
* 创建路由
|
||||
* @param options 参数
|
||||
*/
|
||||
export function createRouter(options: Partial<RouterOptions>) {
|
||||
webHistory = createWebHistory(import.meta.env.VITE_PUBLIC_PATH);
|
||||
// app router
|
||||
let router = createVueRouter({
|
||||
history: webHistory,
|
||||
routes: [],
|
||||
...options,
|
||||
});
|
||||
|
||||
setRouter(router)
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
// 销毁路由
|
||||
export function destroyRouter() {
|
||||
setRouter(null as unknown as Router);
|
||||
if (webHistory) {
|
||||
webHistory.destroy();
|
||||
}
|
||||
webHistory = null
|
||||
}
|
||||
Reference in New Issue
Block a user