Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(breadcrumb): 修复面包屑跳转外链时,导致当前页面404问题 #3337

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/hooks/web/usePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { unref } from 'vue';

import { useRouter } from 'vue-router';
import { REDIRECT_NAME } from '@/router/constant';
import { isHttpUrl } from '@/utils/is';
import { openWindow } from '@/utils';

export type PathAsPageEnum<T> = T extends { path: string } ? T & { path: PageEnum } : T;
export type RouteLocationRawEx = PathAsPageEnum<RouteLocationRaw>;
Expand All @@ -22,6 +24,13 @@ export function useGo(_router?: Router) {
if (!opt) {
return;
}
let path = unref(opt) as string;
if (path[0] === '/') {
path = path.slice(1);
}
if (isHttpUrl(path)) {
return openWindow(path);
}
isReplace ? replace(opt).catch(handleError) : push(opt).catch(handleError);
}
return go;
Expand Down