diff --git a/client/shared/i18n/langs/en-US/translation.json b/client/shared/i18n/langs/en-US/translation.json index 51bef816..57339813 100644 --- a/client/shared/i18n/langs/en-US/translation.json +++ b/client/shared/i18n/langs/en-US/translation.json @@ -298,6 +298,7 @@ "kb7a57f24": "Plugin Registry Service", "kb8021af2": "Disable create converse from group", "kb8185132": "Or", + "kb86bd9c9": "View Panel", "kb8ec7062": "Email verification passed", "kb96b79c5": "Allow management of invitation links", "kbc76781d": "No permission to send messages, please contact the group owner", @@ -319,6 +320,7 @@ "kc6e50666": "Color Scheme", "kc6f6df4": "Do you want to uninstall the plugin", "kc74e5f62": "Search for members", + "kc77e00c7": "Allow members to view the panel", "kc7cc96c8": "From", "kc9283683": "Are you sure you want to delete the panel [{{name}}]", "kc9bd3ad6": "Reset to default permissions", @@ -367,6 +369,7 @@ "ke00c5a2f": "An open source IM for everyone", "ke0131e71": "Recommended aspect: 16:9 | Recommended size: 1280x720", "ke0161a83": "Reset to default address", + "ke03e2010": "No panel access", "ke040edce": "No rendering method of this type found", "ke071c620": "Allow members to manage users, such as banning, removing users, etc.", "ke17b2c87": "Do not upload pictures that violate local laws and regulations", diff --git a/client/shared/i18n/langs/zh-CN/translation.json b/client/shared/i18n/langs/zh-CN/translation.json index 045354f8..c9123eea 100644 --- a/client/shared/i18n/langs/zh-CN/translation.json +++ b/client/shared/i18n/langs/zh-CN/translation.json @@ -298,6 +298,7 @@ "kb7a57f24": "插件中心服务", "kb8021af2": "禁止在群组发起私信", "kb8185132": "或", + "kb86bd9c9": "查看面板", "kb8ec7062": "邮箱验证通过", "kb96b79c5": "允许管理邀请链接", "kbc76781d": "没有发送消息的权限, 请联系群组所有者", @@ -319,6 +320,7 @@ "kc6e50666": "配色方案", "kc6f6df4": "是否要卸载插件", "kc74e5f62": "搜索成员", + "kc77e00c7": "允许成员查看面板", "kc7cc96c8": "来自", "kc9283683": "确定要删除面板 【{{name}}】 么", "kc9bd3ad6": "重置为默认权限", @@ -367,6 +369,7 @@ "ke00c5a2f": "属于所有人的开源聊天工具", "ke0131e71": "建议比例: 16:9 | 建议大小: 1280x720", "ke0161a83": "重置为默认地址", + "ke03e2010": "没有面板访问权限", "ke040edce": "没有找到该类型的渲染方式", "ke071c620": "允许成员管理用户,如禁言、移除用户等操作", "ke17b2c87": "请勿上传违反当地法律法规的图片", diff --git a/client/shared/utils/role-helper.ts b/client/shared/utils/role-helper.ts index 40492529..54caa3b8 100644 --- a/client/shared/utils/role-helper.ts +++ b/client/shared/utils/role-helper.ts @@ -45,6 +45,7 @@ export const PERMISSION = { * 非插件的权限点都叫core */ core: { + viewPanel: 'core.viewPanel', message: 'core.message', invite: 'core.invite', unlimitedInvite: 'core.unlimitedInvite', @@ -60,6 +61,13 @@ export const PERMISSION = { }; export const getPermissionList = (): PermissionItemType[] => [ + { + key: PERMISSION.core.viewPanel, + title: t('查看面板'), + desc: t('允许成员查看面板'), + default: true, + panel: true, + }, { key: PERMISSION.core.message, title: t('发送消息'), diff --git a/client/web/src/routes/Main/Content/Group/Panel.tsx b/client/web/src/routes/Main/Content/Group/Panel.tsx index 0db5e5b1..49acb8cc 100644 --- a/client/web/src/routes/Main/Content/Group/Panel.tsx +++ b/client/web/src/routes/Main/Content/Group/Panel.tsx @@ -8,9 +8,11 @@ import React, { useEffect, useMemo } from 'react'; import { GroupInfoContextProvider, GroupPanelType, + PERMISSION, t, useGroupInfo, useGroupPanelInfo, + useHasGroupPanelPermission, } from 'tailchat-shared'; import { useGroupPanelParams } from './utils'; @@ -47,6 +49,9 @@ export const GroupPanelRender: React.FC = React.memo( [groupId, panelId] ); useRecordGroupPanel(groupId, panelId); + const [viewPanelPermission] = useHasGroupPanelPermission(groupId, panelId, [ + PERMISSION.core.viewPanel, + ]); if (groupInfo === null) { return ( @@ -62,6 +67,10 @@ export const GroupPanelRender: React.FC = React.memo( return ; } + if (!viewPanelPermission) { + return ; + } + if (panelInfo.type === GroupPanelType.TEXT) { return ( diff --git a/client/web/src/routes/Main/Content/Group/SidebarItem.tsx b/client/web/src/routes/Main/Content/Group/SidebarItem.tsx index 37121be9..36bab6a1 100644 --- a/client/web/src/routes/Main/Content/Group/SidebarItem.tsx +++ b/client/web/src/routes/Main/Content/Group/SidebarItem.tsx @@ -4,11 +4,13 @@ import { GroupPanel, GroupPanelType, isValidStr, + PERMISSION, showToasts, t, useAppDispatch, useConverseAck, useGroupInfo, + useHasGroupPanelPermission, useUserNotifyMute, } from 'tailchat-shared'; import { GroupPanelItem } from '@/components/GroupPanelItem'; @@ -44,11 +46,18 @@ export const SidebarItem: React.FC<{ panel.pluginPanelName ?? '' ); const { checkIsMuted, toggleMute } = useUserNotifyMute(); + const [viewPanelPermission] = useHasGroupPanelPermission(groupId, panelId, [ + PERMISSION.core.viewPanel, + ]); if (!groupInfo) { return ; } + if (!viewPanelPermission) { + return null; + } + const isPinned = isValidStr(groupInfo.pinnedPanelId) && groupInfo.pinnedPanelId === panelId;