diff --git a/mayfly_go_web/src/components/auth/auth.ts b/mayfly_go_web/src/components/auth/auth.ts index 30df92d4..263b1006 100644 --- a/mayfly_go_web/src/components/auth/auth.ts +++ b/mayfly_go_web/src/components/auth/auth.ts @@ -6,6 +6,9 @@ import { useUserInfo } from '@/store/userInfo'; * @returns */ export function hasPerm(code: string) { + if (!code) { + return true; + } return useUserInfo().userInfo.permissions.some((v: any) => v === code); } diff --git a/mayfly_go_web/src/components/contextmenu/index.ts b/mayfly_go_web/src/components/contextmenu/index.ts new file mode 100644 index 00000000..4b7f3f85 --- /dev/null +++ b/mayfly_go_web/src/components/contextmenu/index.ts @@ -0,0 +1,55 @@ +export class ContextmenuItem { + clickId: any; + + txt: string; + + icon: string; + + affix: boolean; + + permission: string; + + /** + * 是否隐藏回调函数 + */ + hideFunc: (data: any) => boolean; + + onClickFunc: (data: any) => void; + + constructor(clickId: any, txt: string) { + this.clickId = clickId; + this.txt = txt; + } + + withIcon(icon: string) { + this.icon = icon; + return this; + } + + withPermission(permission: string) { + this.permission = permission; + return this; + } + + withHideFunc(func: (data: any) => boolean) { + this.hideFunc = func; + return this; + } + + withOnClick(func: (data: any) => void) { + this.onClickFunc = func; + return this; + } + + /** + * 是否隐藏 + * @param data 点击数据项 + * @returns + */ + isHide(data: any) { + if (this.hideFunc) { + return this.hideFunc(data); + } + return false; + } +} diff --git a/mayfly_go_web/src/components/contextmenu/index.vue b/mayfly_go_web/src/components/contextmenu/index.vue index 2d6400fa..0d0e3322 100644 --- a/mayfly_go_web/src/components/contextmenu/index.vue +++ b/mayfly_go_web/src/components/contextmenu/index.vue @@ -7,17 +7,18 @@ data-popper-placement="bottom" :style="`top: ${dropdowns.y + 5}px;left: ${dropdowns.x}px;`" :key="Math.random()" - v-show="state.isShow" + v-show="state.isShow && !allHide" >
-