refactor(projects): 精简版+动态路由权限初步
This commit is contained in:
@ -1,31 +0,0 @@
|
||||
import { onMounted, onUnmounted } from 'vue';
|
||||
import { useAuthStore } from '@/store';
|
||||
|
||||
/** 添加用户权益变更的全局点击事件监听 */
|
||||
export function useAuthChangeEvent() {
|
||||
const { getIsAuthChange } = useAuthStore();
|
||||
|
||||
function eventHandler(event: MouseEvent) {
|
||||
const change = getIsAuthChange();
|
||||
if (change) {
|
||||
event.stopPropagation();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
function addAuthChangeListener() {
|
||||
document.addEventListener('click', eventHandler, { capture: true });
|
||||
}
|
||||
|
||||
function removeAuthChangeListener() {
|
||||
document.removeEventListener('click', eventHandler);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
addAuthChangeListener();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
removeAuthChangeListener();
|
||||
});
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
import { useAuthChangeEvent } from './auth';
|
||||
|
||||
export function useGlobalEvent() {
|
||||
/** 初始化全局监听事件 */
|
||||
function initGlobalEventListener() {
|
||||
useAuthChangeEvent();
|
||||
}
|
||||
|
||||
return {
|
||||
initGlobalEventListener
|
||||
};
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
export * from './global';
|
||||
Reference in New Issue
Block a user