1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-11 03:20:24 +08:00

add frontend/vben from vben-admin-thin

This commit is contained in:
源文雨
2023-03-10 17:18:32 +08:00
parent 30cd57ef76
commit 2a0fdeae31
469 changed files with 42028 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/**
* Used to monitor routing changes to change the status of menus and tabs. There is no need to monitor the route, because the route status change is affected by the page rendering time, which will be slow
*/
import mitt from '/@/utils/mitt'
import type { RouteLocationNormalized } from 'vue-router'
import { getRawRoute } from '/@/utils'
const emitter = mitt()
const key = Symbol()
let lastChangeTab: RouteLocationNormalized
export function setRouteChange(lastChangeRoute: RouteLocationNormalized) {
const r = getRawRoute(lastChangeRoute)
emitter.emit(key, r)
lastChangeTab = r
}
export function listenerRouteChange(
callback: (route: RouteLocationNormalized) => void,
immediate = true,
) {
emitter.on(key, callback)
immediate && lastChangeTab && callback(lastChangeTab)
}
export function removeTabChangeListener() {
emitter.clear()
}