Commit 3ad433a5 by Svend Committed by GitHub

fix: 修复在 hash 路由模式下无法在新窗口打开路由的问题 (#6652)

此问题是由于 PR #6583 中新增的 `resolveHref` 函数导致的。其在 hash 路由模式下,得到的 URL 会包含 #/ 前缀。在经过 openRouteInNewWindow 的逻辑后就会出现两次 /# 前缀
1 parent 8ac2db5b
...@@ -30,7 +30,7 @@ function openWindow(url: string, options: OpenWindowOptions = {}): void { ...@@ -30,7 +30,7 @@ function openWindow(url: string, options: OpenWindowOptions = {}): void {
function openRouteInNewWindow(path: string) { function openRouteInNewWindow(path: string) {
const { hash, origin } = location; const { hash, origin } = location;
const fullPath = path.startsWith('/') ? path : `/${path}`; const fullPath = path.startsWith('/') ? path : `/${path}`;
const url = `${origin}${hash ? '/#' : ''}${fullPath}`; const url = `${origin}${hash && !fullPath.startsWith('/#') ? '/#' : ''}${fullPath}`;
openWindow(url, { target: '_blank' }); openWindow(url, { target: '_blank' });
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!