diff --git a/web/src/components/modals/CreateGroup.tsx b/web/src/components/modals/CreateGroup.tsx index ab4a9839..cee7457f 100644 --- a/web/src/components/modals/CreateGroup.tsx +++ b/web/src/components/modals/CreateGroup.tsx @@ -12,6 +12,7 @@ import type { GroupPanel } from 'tailchat-shared'; import { Avatar } from '../Avatar'; import { closeModal, ModalWrapper } from '../Modal'; import { Slides, SlidesRef } from '../Slides'; +import { useHistory, useLocation } from 'react-router'; const panelTemplate: { key: string; @@ -76,6 +77,7 @@ export const ModalCreateGroup: React.FC = React.memo(() => { const [panels, setPanels] = useState([]); const [name, setName] = useState(''); const dispatch = useAppDispatch(); + const history = useHistory(); const handleSelectTemplate = useCallback((panels: GroupPanel[]) => { setPanels(panels); @@ -90,9 +92,10 @@ export const ModalCreateGroup: React.FC = React.memo(() => { const data = await createGroup(name, panels); dispatch(groupActions.appendGroups([data])); + history.push(`/main/group/${data._id}`); // 创建完成后跳转到新建的群组 closeModal(); - }, [name, panels]); + }, [name, panels, location]); return (