mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
fix(electron): share page in electron issues (#8703)
fix AF-1592 fix AF-1612
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { AffineErrorBoundary } from '@affine/core/components/affine/affine-error-boundary';
|
||||
import { AffineErrorComponent } from '@affine/core/components/affine/affine-error-boundary/affine-error-fallback';
|
||||
import { PageNotFound } from '@affine/core/desktop/pages/404';
|
||||
import { MobileWorkbenchRoot } from '@affine/core/desktop/pages/workspace/workbench-root';
|
||||
import { workbenchRoutes } from '@affine/core/mobile/workbench-router';
|
||||
import {
|
||||
useLiveData,
|
||||
@@ -23,6 +22,7 @@ import {
|
||||
} from 'react-router-dom';
|
||||
|
||||
import { WorkspaceLayout } from './layout';
|
||||
import { MobileWorkbenchRoot } from './workbench-root';
|
||||
|
||||
type Route = { Component: React.ComponentType };
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
useBindWorkbenchToBrowserRouter,
|
||||
WorkbenchService,
|
||||
} from '@affine/core/modules/workbench';
|
||||
import { ViewRoot } from '@affine/core/modules/workbench/view/view-root';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { useEffect } from 'react';
|
||||
import { type RouteObject, useLocation } from 'react-router-dom';
|
||||
|
||||
export const MobileWorkbenchRoot = ({ routes }: { routes: RouteObject[] }) => {
|
||||
const workbench = useService(WorkbenchService).workbench;
|
||||
|
||||
// for debugging
|
||||
(window as any).workbench = workbench;
|
||||
|
||||
const views = useLiveData(workbench.views$);
|
||||
|
||||
const location = useLocation();
|
||||
const basename = location.pathname.match(/\/workspace\/[^/]+/g)?.[0] ?? '/';
|
||||
|
||||
useBindWorkbenchToBrowserRouter(workbench, basename);
|
||||
|
||||
useEffect(() => {
|
||||
workbench.updateBasename(basename);
|
||||
}, [basename, workbench]);
|
||||
|
||||
return <ViewRoot routes={routes} view={views[0]} />;
|
||||
};
|
||||
Reference in New Issue
Block a user