mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-05 19:40:30 +08:00
fix(core): give page reference correct link (#6587)
This commit is contained in:
@@ -8,7 +8,6 @@ import { Workbench } from '../entities/workbench';
|
|||||||
|
|
||||||
export const WorkbenchLink = ({
|
export const WorkbenchLink = ({
|
||||||
to,
|
to,
|
||||||
children,
|
|
||||||
onClick,
|
onClick,
|
||||||
...other
|
...other
|
||||||
}: React.PropsWithChildren<
|
}: React.PropsWithChildren<
|
||||||
@@ -17,6 +16,9 @@ export const WorkbenchLink = ({
|
|||||||
const workbench = useService(Workbench);
|
const workbench = useService(Workbench);
|
||||||
const { appSettings } = useAppSettingHelper();
|
const { appSettings } = useAppSettingHelper();
|
||||||
const basename = useLiveData(workbench.basename$);
|
const basename = useLiveData(workbench.basename$);
|
||||||
|
const link =
|
||||||
|
basename +
|
||||||
|
(typeof to === 'string' ? to : `${to.pathname}${to.search}${to.hash}`);
|
||||||
const handleClick = useCallback(
|
const handleClick = useCallback(
|
||||||
(event: React.MouseEvent<HTMLAnchorElement>) => {
|
(event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -29,21 +31,16 @@ export const WorkbenchLink = ({
|
|||||||
if (appSettings.enableMultiView && environment.isDesktop) {
|
if (appSettings.enableMultiView && environment.isDesktop) {
|
||||||
workbench.open(to, { at: 'beside' });
|
workbench.open(to, { at: 'beside' });
|
||||||
} else if (!environment.isDesktop) {
|
} else if (!environment.isDesktop) {
|
||||||
const href =
|
popupWindow(link);
|
||||||
typeof to === 'string'
|
|
||||||
? to
|
|
||||||
: `${to.pathname}${to.search}${to.hash}`;
|
|
||||||
popupWindow(basename + href);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workbench.open(to);
|
workbench.open(to);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[appSettings.enableMultiView, basename, onClick, to, workbench]
|
[appSettings.enableMultiView, link, onClick, to, workbench]
|
||||||
);
|
|
||||||
return (
|
|
||||||
<a {...other} href="#" onClick={handleClick}>
|
|
||||||
{children}
|
|
||||||
</a>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// eslint suspicious runtime error
|
||||||
|
// eslint-disable-next-line react/no-danger-with-children
|
||||||
|
return <a {...other} href={link} onClick={handleClick} />;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user