fix: 修复在处理当前页面的完整路径时url的跳转行为

pull/70/head
moonrailgun 2 years ago
parent 2590242bd8
commit ca486ed6b0

@ -7,11 +7,16 @@ export const UrlTag: React.FC<TagProps> = React.memo((props) => {
const text = node.content.join(''); const text = node.content.join('');
const url = node.attrs.url ?? text; const url = node.attrs.url ?? text;
if (url.startsWith('/') || url.startsWith(window.location.origin)) { if (url.startsWith('/')) {
// 内部地址,使用 react-router 进行导航 // 内部地址,使用 react-router 进行导航
return <Link to={url}>{text}</Link>; return <Link to={url}>{text}</Link>;
} }
if (url.startsWith(window.location.origin)) {
// 内部地址,使用 react-router 进行导航
return <Link to={url.replace(window.location.origin, '')}>{text}</Link>;
}
return ( return (
<a href={url} title={text} target="_blank" rel="noopener noreferrer"> <a href={url} title={text} target="_blank" rel="noopener noreferrer">
{text} {text}

Loading…
Cancel
Save