File tree 4 files changed +31
-15
lines changed
4 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ import {
23
23
24
24
import { useNamespace } from ' @vben-core/composables' ;
25
25
import { Ellipsis } from ' @vben-core/icons' ;
26
- import { isHttpUrl } from ' @vben-core/shared/utils' ;
27
26
28
27
import { useResizeObserver } from ' @vueuse/core' ;
29
28
@@ -248,9 +247,6 @@ function handleMenuItemClick(data: MenuItemClicked) {
248
247
if (! path || ! parentPaths ) {
249
248
return ;
250
249
}
251
- if (! isHttpUrl (path )) {
252
- activePath .value = path ;
253
- }
254
250
255
251
emit (' select' , path , parentPaths );
256
252
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import { useNavigation } from './use-navigation';
13
13
14
14
function useExtraMenu ( useRootMenus ?: ComputedRef < MenuRecordRaw [ ] > ) {
15
15
const accessStore = useAccessStore ( ) ;
16
- const { navigation } = useNavigation ( ) ;
16
+ const { navigation, willOpenedByWindow } = useNavigation ( ) ;
17
17
18
18
const menus = computed ( ( ) => useRootMenus ?. value ?? accessStore . accessMenus ) ;
19
19
@@ -33,11 +33,15 @@ function useExtraMenu(useRootMenus?: ComputedRef<MenuRecordRaw[]>) {
33
33
* @param menu
34
34
*/
35
35
const handleMixedMenuSelect = async ( menu : MenuRecordRaw ) => {
36
- extraMenus . value = menu ?. children ?? [ ] ;
37
- extraActiveMenu . value = menu . parents ?. [ parentLevel . value ] ?? menu . path ;
38
- const hasChildren = extraMenus . value . length > 0 ;
36
+ const _extraMenus = menu ?. children ?? [ ] ;
37
+ const hasChildren = _extraMenus . length > 0 ;
38
+
39
+ if ( ! willOpenedByWindow ( menu . path ) ) {
40
+ extraMenus . value = _extraMenus ?? [ ] ;
41
+ extraActiveMenu . value = menu . parents ?. [ parentLevel . value ] ?? menu . path ;
42
+ sidebarExtraVisible . value = hasChildren ;
43
+ }
39
44
40
- sidebarExtraVisible . value = hasChildren ;
41
45
if ( ! hasChildren ) {
42
46
await navigation ( menu . path ) ;
43
47
} else if ( preferences . sidebar . autoActivateChild ) {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { findRootMenuByPath } from '@vben/utils';
10
10
import { useNavigation } from './use-navigation' ;
11
11
12
12
function useMixedMenu ( ) {
13
- const { navigation } = useNavigation ( ) ;
13
+ const { navigation, willOpenedByWindow } = useNavigation ( ) ;
14
14
const accessStore = useAccessStore ( ) ;
15
15
const route = useRoute ( ) ;
16
16
const splitSideMenus = ref < MenuRecordRaw [ ] > ( [ ] ) ;
@@ -89,11 +89,15 @@ function useMixedMenu() {
89
89
navigation ( key ) ;
90
90
return ;
91
91
}
92
-
93
92
const rootMenu = menus . value . find ( ( item ) => item . path === key ) ;
94
- rootMenuPath . value = rootMenu ?. path ?? '' ;
95
- splitSideMenus . value = rootMenu ?. children ?? [ ] ;
96
- if ( splitSideMenus . value . length === 0 ) {
93
+ const _splitSideMenus = rootMenu ?. children ?? [ ] ;
94
+
95
+ if ( ! willOpenedByWindow ( key ) ) {
96
+ rootMenuPath . value = rootMenu ?. path ?? '' ;
97
+ splitSideMenus . value = _splitSideMenus ;
98
+ }
99
+
100
+ if ( _splitSideMenus . length === 0 ) {
97
101
navigation ( key ) ;
98
102
} else if ( rootMenu && preferences . sidebar . autoActivateChild ) {
99
103
navigation (
Original file line number Diff line number Diff line change @@ -29,7 +29,19 @@ function useNavigation() {
29
29
}
30
30
} ;
31
31
32
- return { navigation } ;
32
+ const willOpenedByWindow = ( path : string ) => {
33
+ const route = routeMetaMap . get ( path ) ;
34
+ const { openInNewWindow = false } = route ?. meta ?? { } ;
35
+ if ( isHttpUrl ( path ) ) {
36
+ return true ;
37
+ } else if ( openInNewWindow ) {
38
+ return true ;
39
+ } else {
40
+ return false ;
41
+ }
42
+ } ;
43
+
44
+ return { navigation, willOpenedByWindow } ;
33
45
}
34
46
35
47
export { useNavigation } ;
You can’t perform that action at this time.
0 commit comments