diff --git a/shared/model/group.ts b/shared/model/group.ts index 2396f05f..9e16bf2f 100644 --- a/shared/model/group.ts +++ b/shared/model/group.ts @@ -28,6 +28,7 @@ export interface GroupInfo { owner: string; members: GroupMember[]; panels: GroupPanel[]; + pinnedPanelId?: string; // 被钉选的面板Id } /** diff --git a/shared/redux/slices/group.ts b/shared/redux/slices/group.ts index a0fd1e4e..7f5d9472 100644 --- a/shared/redux/slices/group.ts +++ b/shared/redux/slices/group.ts @@ -42,6 +42,39 @@ const groupSlice = createSlice({ const groupId = action.payload; delete state.groups[groupId]; }, + pinGroupPanel( + state, + action: PayloadAction<{ + groupId: string; + panelId: string; + }> + ) { + const { groupId, panelId } = action.payload; + + if (state.groups[groupId]) { + // NOTICE: updateGroup 只会去更新,不会去添加新的 + state.groups[groupId] = { + ...state.groups[groupId], + pinnedPanelId: panelId, + }; + } + }, + unpinGroupPanel( + state, + action: PayloadAction<{ + groupId: string; + }> + ) { + const { groupId } = action.payload; + + if (state.groups[groupId]) { + // NOTICE: updateGroup 只会去更新,不会去添加新的 + state.groups[groupId] = { + ...state.groups[groupId], + pinnedPanelId: undefined, + }; + } + }, }, }); diff --git a/web/plugins/com.msgbyte.webview/src/index.tsx b/web/plugins/com.msgbyte.webview/src/index.tsx index 72058c60..0776c20b 100644 --- a/web/plugins/com.msgbyte.webview/src/index.tsx +++ b/web/plugins/com.msgbyte.webview/src/index.tsx @@ -1,17 +1,18 @@ import React from 'react'; -import { regGroupPanel, useCurrentGroupPanelInfo } from '@capital/common'; +import { regGroupPanel } from '@capital/common'; import { Translate } from './translate'; +import _get from 'lodash/get'; const PLUGIN_NAME = 'com.msgbyte.webview'; -const GroupWebPanelRender = () => { - const groupPanelInfo = useCurrentGroupPanelInfo(); +const GroupWebPanelRender: React.FC<{ panelInfo: any }> = (props) => { + const panelInfo = props.panelInfo; - if (!groupPanelInfo) { + if (!panelInfo) { return
{Translate.notfound}
; } - const url = groupPanelInfo.meta?.url; + const url = _get(panelInfo, 'meta.url'); return (