From e9f255ca3ce3e1faa294c722baca784577b87216 Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Fri, 31 Mar 2023 18:02:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/consts.ts | 2 ++ src/views/init-home/data/RoleData.ts | 30 ++++++++++++++++ src/views/init-home/data/baseMenu.ts | 47 +++++++++++++++++++++++++ src/views/system/Menu/Setting/index.vue | 3 +- src/views/system/Menu/index.vue | 4 +-- 5 files changed, 83 insertions(+), 3 deletions(-) diff --git a/src/utils/consts.ts b/src/utils/consts.ts index d04577ed..621b311b 100644 --- a/src/utils/consts.ts +++ b/src/utils/consts.ts @@ -47,3 +47,5 @@ export const SystemConst = { VERSION_CODE: 'version_code', AMAP_KEY : 'amap_key', } + +export const USER_CENTER_MENU_CODE = 'account-center' diff --git a/src/views/init-home/data/RoleData.ts b/src/views/init-home/data/RoleData.ts index 9729255d..56ad7175 100644 --- a/src/views/init-home/data/RoleData.ts +++ b/src/views/init-home/data/RoleData.ts @@ -1,3 +1,4 @@ +import USER_CENTER_MENU_DATA from './baseMenu' /** * 内置角色数据 */ @@ -9,6 +10,33 @@ export enum ROLEKEYS { export type roleKeysType = keyof typeof ROLEKEYS; +export const ROLE_USER_CENTER = { + ...USER_CENTER_MENU_DATA, + buttons: [ + { + id: 'passwd-update', + name: '密码修改', + enabled: true, + granted: true + }, + { + id: 'info-update', + name: '基本信息修改', + enabled: true, + granted: true + }, + { + id: 'message', + name: '消息订阅', + enabled: true, + granted: true + } + ], + assetAccesses: [], + granted: true, + owner: 'iot' +} + export const RoleData = { [ROLEKEYS.device]: { name: '设备接入岗', @@ -217,6 +245,7 @@ export default { createTime: 1659344075524, granted: true, }, + ROLE_USER_CENTER ], [ROLEKEYS.link]: [ { @@ -958,5 +987,6 @@ export default { accessDescription: '此菜单不支持数据权限控制', granted: true, }, + ROLE_USER_CENTER ], }; diff --git a/src/views/init-home/data/baseMenu.ts b/src/views/init-home/data/baseMenu.ts index f02c1674..83541bcb 100644 --- a/src/views/init-home/data/baseMenu.ts +++ b/src/views/init-home/data/baseMenu.ts @@ -1,3 +1,44 @@ +import { USER_CENTER_MENU_CODE } from '@/utils/consts' + +export const USER_CENTER_MENU_DATA = { + id: '19a1f2c763e1231f1e1', + accessSupport: { value: 'unsupported', label: '不支持'}, + supportDataAccess: false, + code: USER_CENTER_MENU_CODE, + buttons: [ + { + id: 'passwd-update', + name: '密码修改', + permissions: [ + { + permission: 'user', + action: ['update-self-pwd'] + } + ] + }, + { + id: 'info-update', + name: '基本信息修改', + permissions: [ + { + permission: 'user', + action: ['update-self-info'] + } + ] + }, + { + id: 'message', + name: '消息订阅', + permissions: [ + { + permission: 'alarm-config', + action: ['query'] + } + ] + } + ] +} + export default [ // 物联网 { @@ -4015,6 +4056,10 @@ export default [ permission: 'network-card', actions: ['save'], }, + { + permission: 'device-instance', + actions: ['query'], + }, ], }, { @@ -4219,4 +4264,6 @@ export default [ }, ], }, + // 用户中心 + USER_CENTER_MENU_DATA ]; diff --git a/src/views/system/Menu/Setting/index.vue b/src/views/system/Menu/Setting/index.vue index 68535772..cdb0d11c 100644 --- a/src/views/system/Menu/Setting/index.vue +++ b/src/views/system/Menu/Setting/index.vue @@ -73,6 +73,7 @@ import BaseMenu from '@/views/init-home/data/baseMenu'; import type { AntTreeNodeDropEvent } from 'ant-design-vue/es/tree'; import { cloneDeep } from 'lodash'; import { onlyMessage } from '@/utils/comm'; +import { USER_CENTER_MENU_CODE } from '@/utils/consts' const selectedKeys: any = ref([]); const treeData = ref([]); @@ -185,7 +186,7 @@ onMounted(() => { ); getMenuTree_api(params).then((resp: any) => { if (resp.status == 200) { - systemMenu.value = resp.result; + systemMenu.value = resp.result?.filter((item: { code: string }) => item.code !== USER_CENTER_MENU_CODE); //初始化菜单 const baseMenuData = developArrToMap(baseMenu.value); const systemMenuData = developArrToMap(systemMenu.value, true); diff --git a/src/views/system/Menu/index.vue b/src/views/system/Menu/index.vue index 3d7cf206..e7edd234 100644 --- a/src/views/system/Menu/index.vue +++ b/src/views/system/Menu/index.vue @@ -84,7 +84,7 @@ import { getMenuTree_api, delMenuInfo_api } from '@/api/system/menu'; import { message } from 'jetlinks-ui-components'; import dayjs from 'dayjs'; import { useUserInfo } from '@/store/userInfo'; - +import { USER_CENTER_MENU_CODE } from '@/utils/consts' const admin = useUserInfo().userInfos?.type.id === 'admin'; const permission = 'system/Menu'; @@ -206,7 +206,7 @@ const table = reactive({ return { code: resp.message, result: { - data: resp.result, + data: resp.result?.filter((item: { code: string }) => item.code !== USER_CENTER_MENU_CODE), pageIndex: resp.pageIndex, pageSize: resp.pageSize, total: resp.total,