From 9d901b4215323c97a00a068cd962f5c9c04dadfa Mon Sep 17 00:00:00 2001 From: doum <doum> Date: 星期四, 04 九月 2025 10:15:09 +0800 Subject: [PATCH] 前端 --- admin/src/components/base/BaseOpera.vue | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/admin/src/components/base/BaseOpera.vue b/admin/src/components/base/BaseOpera.vue index 4a364eb..86a2e02 100644 --- a/admin/src/components/base/BaseOpera.vue +++ b/admin/src/components/base/BaseOpera.vue @@ -1,4 +1,6 @@ <script> +import {mapState} from "vuex"; + export default { name: 'BaseOpera', data () { @@ -13,6 +15,9 @@ 'field.id': 'id' } } + }, + computed: { + ...mapState(['userInfo']), }, methods: { /** @@ -125,6 +130,29 @@ this.isWorking = false }) }) + }, + /** + * 鏄惁鍖呭惈鎸囧畾鏉冮檺 + * + * @param permissions 鐩爣鏉冮檺鏁扮粍 + * @returns {boolean} + */ + containPermissions (permissions) { + if (permissions == null) { + return true + } + if (this.userInfo == null) { + return false + } + if (this.userInfo.permissions == null || this.userInfo.permissions.length === 0) { + return false + } + for (const code of permissions) { + if (this.userInfo.permissions.findIndex(p => p === code) > -1) { + return true + } + } + return false } } } -- Gitblit v1.9.3