mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
fix(core): share page should have basename correctly set (#13256)
fix AF-2760 #### PR Dependency Tree * **PR #13256** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -14,7 +14,11 @@ import {
|
|||||||
EditorsService,
|
EditorsService,
|
||||||
} from '@affine/core/modules/editor';
|
} from '@affine/core/modules/editor';
|
||||||
import { PeekViewManagerModal } from '@affine/core/modules/peek-view';
|
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 {
|
import {
|
||||||
type Workspace,
|
type Workspace,
|
||||||
WorkspacesService,
|
WorkspacesService,
|
||||||
@@ -34,6 +38,17 @@ import { ShareFooter } from './share-footer';
|
|||||||
import { ShareHeader } from './share-header';
|
import { ShareHeader } from './share-header';
|
||||||
import * as styles from './share-page.css';
|
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 = ({
|
export const SharePage = ({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
docId,
|
docId,
|
||||||
@@ -187,6 +202,7 @@ const SharePageInner = ({
|
|||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const pageTitle = useLiveData(page?.title$);
|
const pageTitle = useLiveData(page?.title$);
|
||||||
const { jumpToPageBlock, openPage } = useNavigateHelper();
|
const { jumpToPageBlock, openPage } = useNavigateHelper();
|
||||||
|
useUpdateBasename(workspace);
|
||||||
|
|
||||||
const onEditorLoad = useCallback(
|
const onEditorLoad = useCallback(
|
||||||
(editorContainer: AffineEditorContainer) => {
|
(editorContainer: AffineEditorContainer) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user