diff --git a/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx index 9d00d98ec..857f3d6ac 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/share/share-page.tsx @@ -14,7 +14,11 @@ import { EditorsService, } from '@affine/core/modules/editor'; import { PeekViewManagerModal } from '@affine/core/modules/peek-view'; -import { ViewIcon, ViewTitle } from '@affine/core/modules/workbench'; +import { + ViewIcon, + ViewTitle, + WorkbenchService, +} from '@affine/core/modules/workbench'; import { type Workspace, WorkspacesService, @@ -34,6 +38,17 @@ import { ShareFooter } from './share-footer'; import { ShareHeader } from './share-header'; import * as styles from './share-page.css'; +const useUpdateBasename = (workspace: Workspace | null) => { + const location = useLocation(); + const basename = location.pathname.match(/\/workspace\/[^/]+/g)?.[0] ?? '/'; + useEffect(() => { + if (workspace) { + const workbench = workspace.scope.get(WorkbenchService).workbench; + workbench.updateBasename(basename); + } + }, [basename, workspace]); +}; + export const SharePage = ({ workspaceId, docId, @@ -187,6 +202,7 @@ const SharePageInner = ({ const t = useI18n(); const pageTitle = useLiveData(page?.title$); const { jumpToPageBlock, openPage } = useNavigateHelper(); + useUpdateBasename(workspace); const onEditorLoad = useCallback( (editorContainer: AffineEditorContainer) => {