Zlpt_Portal/src/utils/directive/authBtn.ts

27 lines
655 B
TypeScript
Raw Normal View History

2023-12-09 22:29:54 +08:00
import { ElMessage } from "element-plus"
import { useStore } from 'store/main'
import router from "@/router"
export default function (app: any) {
app.directive("authBtn", {
mounted(el: any, binding: any, vnode: any) {
console.log("binding", binding.value)
const store = useStore()
if (!store.token) {
el.addEventListener("click", () => {
ElMessage({
type: "warning",
message: '暂无权限66'
})
setTimeout(() => {
router.push('/login')
}, 300);
})
}else{
el.addEventListener("click", binding.value())
}
}
})
}