Skip to content

Commit b93e22c

Browse files
authored
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.
1 parent 193f5b6 commit b93e22c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ function useNavigation() {
3232
return route?.meta?.openInNewWindow ?? false;
3333
};
3434

35+
const resolveHref = (path: string): string => {
36+
return router.resolve(path).href;
37+
};
38+
3539
const navigation = async (path: string) => {
3640
try {
3741
const route = routeMetaMap.get(path);
@@ -40,7 +44,7 @@ function useNavigation() {
4044
if (isHttpUrl(path)) {
4145
openWindow(path, { target: '_blank' });
4246
} else if (openInNewWindow) {
43-
openRouteInNewWindow(path);
47+
openRouteInNewWindow(resolveHref(path));
4448
} else {
4549
await router.push({
4650
path,

0 commit comments

Comments
 (0)