修复BUG:
1.角色管理没有分页问题; 2.自定义指令引用问题
This commit is contained in:
@@ -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);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
23
web/src/directive/sizeDirective.ts
Normal file
23
web/src/directive/sizeDirective.ts
Normal 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); // 停止监听
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user