Browse Source

fix(@vben/layouts): respect base URL when opening route in new window (#6583)

Previously, the generated URL for opening routes in a new window did not include the router base,
which led to incorrect paths when the app was deployed under a subdirectory (e.g., /admin/).
This change ensures that the resolved path includes the configured base by using
router.resolve(path).href.
pull/6568/head
leo 6 months ago
committed by GitHub
parent
commit
b93e22c45a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      packages/effects/layouts/src/basic/menu/use-navigation.ts

6
packages/effects/layouts/src/basic/menu/use-navigation.ts

@ -32,6 +32,10 @@ function useNavigation() {
return route?.meta?.openInNewWindow ?? false; return route?.meta?.openInNewWindow ?? false;
}; };
const resolveHref = (path: string): string => {
return router.resolve(path).href;
};
const navigation = async (path: string) => { const navigation = async (path: string) => {
try { try {
const route = routeMetaMap.get(path); const route = routeMetaMap.get(path);
@ -40,7 +44,7 @@ function useNavigation() {
if (isHttpUrl(path)) { if (isHttpUrl(path)) {
openWindow(path, { target: '_blank' }); openWindow(path, { target: '_blank' });
} else if (openInNewWindow) { } else if (openInNewWindow) {
openRouteInNewWindow(path); openRouteInNewWindow(resolveHref(path));
} else { } else {
await router.push({ await router.push({
path, path,

Loading…
Cancel
Save