修复BUG:

1.角色管理没有分页问题;
2.自定义指令引用问题
This commit is contained in:
猿小天
2024-01-18 20:25:02 +08:00
parent e210b7dd17
commit 9bd79b9dc6
11 changed files with 222 additions and 499 deletions

View File

@@ -1,7 +1,6 @@
import type { App } from 'vue';
import { useUserInfo } from '/@/stores/userInfo';
import { judementSameArr } from '/@/utils/arrayOperation';
import {BtnPermissionStore} from "/@/stores/btnPermission";
/**
* 用户权限指令
* @directive 单个权限验证v-auth="xxx"
@@ -12,16 +11,16 @@ export function authDirective(app: App) {
// 单个权限验证v-auth="xxx"
app.directive('auth', {
mounted(el, binding) {
const stores = useUserInfo();
if (!stores.userInfos.authBtnList.some((v: string) => v === binding.value)) el.parentNode.removeChild(el);
const stores = BtnPermissionStore();
if (!stores.data.some((v: string) => v === binding.value)) el.parentNode.removeChild(el);
},
});
// 多个权限验证满足一个则显示v-auths="[xxx,xxx]"
app.directive('auths', {
mounted(el, binding) {
let flag = false;
const stores = useUserInfo();
stores.userInfos.authBtnList.map((val: string) => {
const stores = BtnPermissionStore();
stores.data.map((val: string) => {
binding.value.map((v: string) => {
if (val === v) flag = true;
});
@@ -32,8 +31,8 @@ export function authDirective(app: App) {
// 多个权限验证全部满足则显示v-auth-all="[xxx,xxx]"
app.directive('auth-all', {
mounted(el, binding) {
const stores = useUserInfo();
const flag = judementSameArr(binding.value, stores.userInfos.authBtnList);
const stores = BtnPermissionStore();
const flag = judementSameArr(binding.value, stores.data);
if (!flag) el.parentNode.removeChild(el);
},
});

View File

@@ -1,7 +1,7 @@
import type { App } from 'vue';
import { authDirective } from '/@/directive/authDirective';
import { wavesDirective, dragDirective } from '/@/directive/customDirective';
import {resizeObDirective} from '/@/directive/sizeDirective'
/**
* 导出指令方法v-xxx
* @methods authDirective 用户权限指令用法v-auth
@@ -15,4 +15,6 @@ export function directive(app: App) {
wavesDirective(app);
// 自定义拖动指令
dragDirective(app);
// 监听窗口大小变化
resizeObDirective(app)
}

View File

@@ -0,0 +1,23 @@
import {App} from "vue/dist/vue";
const map = new WeakMap()
const ob = new ResizeObserver((entries) => {
for(const entry of entries){
const handler = map.get(entry.target);
handler && handler({
width: entry.borderBoxSize[0].inlineSize,
height: entry.borderBoxSize[0].blockSize
});
}
});
export function resizeObDirective(app: App){
app.directive('resizeOb', {
mounted(el,binding) {
map.set(el,binding.value);
ob.observe(el); // 监听目标元素
},
unmounted(el) {
ob.unobserve(el); // 停止监听
},
})
}