Files
his/openhis-ui-vue3/.backup-ruoyi-392/permission.js
华佗 1d21661a78 feat: Spring Boot 3.5.14 全量升级 + 组件升级
核心升级:
- Spring Boot 2.7.18 → 3.5.14
- MyBatis Plus 3.5.5 → 3.5.16 (spring-boot3-starter)
- Springdoc 1.8.0 → 2.8.6 (OpenAPI 3)
- Flowable 6.8.0 → 7.1.0
- Druid 1.2.x → 1.2.28 (boot3-starter)
- kotlin-reflect 1.9.10 → 1.9.25

迁移适配:
- javax → jakarta 命名空间 (620+ 文件)
- Swagger 注解迁移到 OpenAPI 3 (@Tag/@Schema/@Operation/@Parameter)
- Spring Security 6.2 适配 (antMatchers→requestMatchers, EnableMethodSecurity)
- Druid 包名迁移 (boot→boot3)
- Redis 配置路径迁移 (spring.redis→spring.data.redis)
- Flyway 适配 (flyway-database-postgresql)
- Flowable 7.x 适配 (MULE_TASK_IMAGE 移除)

修复:
- spring-boot-maven-plugin 2.5.15→3.5.14 (SPI服务发现失效)
- mybatis-plus-boot-starter 3.5.5→3.5.16 (kotlin-reflect+fastjson2冲突)
- Flowable database-schema-update 启用自动建表

验证: 23/23 测试通过, 1374 API端点正常
2026-06-04 22:39:49 +08:00

103 lines
3.2 KiB
JavaScript
Executable File

import router from './router'
import {ElMessage} from 'element-plus'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import {getToken} from '@/utils/auth'
import {isHttp} from '@/utils/validate'
import {isRelogin} from '@/utils/request'
import useUserStore from '@/store/modules/user'
import useSettingsStore from '@/store/modules/settings'
import usePermissionStore from '@/store/modules/permission'
// 全局变量,用于控制公告弹窗只显示一次
let hasShownNoticePopup = false
NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/register'];
router.beforeEach((to, from, next) => {
NProgress.start()
if (getToken()) {
to.meta.title && useSettingsStore().setTitle(to.meta.title)
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
NProgress.done()
} else if (whiteList.indexOf(to.path) !== -1) {
next()
} else {
if (useUserStore().roles.length === 0) {
isRelogin.show = true
// 判断当前用户是否已拉取完user_info信息
useUserStore().getInfo().then(() => {
isRelogin.show = false
usePermissionStore().generateRoutes().then(accessRoutes => {
// 根据roles权限生成可访问的路由表
accessRoutes.forEach(route => {
if (!isHttp(route.path)) {
// 检查是否已经存在同名路由
if (!router.hasRoute(route.name)) {
router.addRoute(route) // 动态添加可访问路由表
}
}
})
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
})
}).catch(err => {
useUserStore().logOut().then(() => {
ElMessage.error(err)
next({ path: '/' })
})
})
} else {
next()
}
}
} else {
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
NProgress.done()
}
}
})
router.afterEach(() => {
NProgress.done()
// 登录成功后显示公告弹窗(仅限非登录页面且未显示过)
const token = getToken()
const isLoginPage = router.currentRoute.value.path === '/login'
if (token && !isLoginPage && !hasShownNoticePopup) {
// 延迟显示,确保页面完全加载
setTimeout(() => {
showNoticePopupGlobally()
hasShownNoticePopup = true
}, 1500)
}
})
// 全局函数:显示公告弹窗
function showNoticePopupGlobally() {
try {
// 通过多种方式尝试获取并显示公告弹窗
const layouts = document.querySelectorAll('.app-wrapper')
for (const layout of layouts) {
const noticePopupRef = layout.__vue_app__?.config.globalProperties.$refs?.noticePopupRef
if (noticePopupRef && noticePopupRef.showNotice) {
noticePopupRef.showNotice()
return
}
}
// 如果直接获取失败,尝试通过事件总线方式
window.dispatchEvent(new CustomEvent('show-notice-popup'))
} catch (error) {
console.error('显示公告弹窗失败:', error)
}
}