mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2026-01-09 09:40:21 +08:00
init
This commit is contained in:
23
src/router/guards/tab-guard.js
Normal file
23
src/router/guards/tab-guard.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**********************************
|
||||
* @Author: Ronnie Zhang
|
||||
* @LastEditor: Ronnie Zhang
|
||||
* @LastEditTime: 2023/12/05 21:25:17
|
||||
* @Email: zclzone@outlook.com
|
||||
* Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top
|
||||
**********************************/
|
||||
|
||||
import { useTabStore } from '@/store'
|
||||
|
||||
export const EXCLUDE_TAB = ['/404', '/403', '/login', '/role-select']
|
||||
|
||||
export function createTabGuard(router) {
|
||||
router.afterEach((to) => {
|
||||
if (EXCLUDE_TAB.includes(to.path)) return
|
||||
const tabStore = useTabStore()
|
||||
const { name, fullPath: path } = to
|
||||
const title = to.meta?.title
|
||||
const icon = to.meta?.icon
|
||||
const keepAlive = to.meta?.keepAlive
|
||||
tabStore.addTab({ name, path, title, icon, keepAlive })
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user