From edd97ae73b784f03ee46fab10b81d64d04c888e3 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Thu, 17 Jul 2025 22:01:38 +0800 Subject: [PATCH] fix(core): share page should have basename correctly set (#13256) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix AF-2760 #### PR Dependency Tree * **PR #13256** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **New Features** * Improved synchronization of workspace information with the URL path, ensuring the displayed workspace name stays up-to-date when navigating within the workspace share page. --- .../pages/workspace/share/share-page.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) => {