mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 10:33:50 +08:00
Co-authored-by: jackhoo_98 <jackhoo_98@foxmail.com>
This commit is contained in:
parent
064922dd4c
commit
895352ad22
@ -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>;
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user