Skip to content

Commit

Permalink
fix(breadcrumb): 修复面包屑跳转外链时,导致当前页面404问题 (#3337). close #3336
Browse files Browse the repository at this point in the history
Co-authored-by: jackhoo_98 <jackhoo_98@foxmail.com>
  • Loading branch information
13982720426 and jackhoo_98 committed Nov 25, 2023
1 parent 064922d commit 895352a
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 895352a

Please sign in to comment.