Commit cecdfbaf297ab4650c247c78cb8e8749292f661e

Authored by 无木
1 parent 84c7d516

fix(tabs): dropdown items enabled unnecessary

修复标签头的右键菜单某些项目不恰当地处于可用状态

fixed: #1207
src/layouts/default/tabs/useTabDropdown.ts
@@ -34,18 +34,21 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp @@ -34,18 +34,21 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp
34 const { meta } = unref(getTargetTab); 34 const { meta } = unref(getTargetTab);
35 const { path } = unref(currentRoute); 35 const { path } = unref(currentRoute);
36 36
37 - // Refresh button  
38 const curItem = state.current; 37 const curItem = state.current;
  38 +
  39 + const isCurItem = curItem ? curItem.path === path : false;
  40 +
  41 + // Refresh button
39 const index = state.currentIndex; 42 const index = state.currentIndex;
40 - const refreshDisabled = curItem ? curItem.path !== path : true; 43 + const refreshDisabled = !isCurItem;
41 // Close left 44 // Close left
42 - const closeLeftDisabled = index === 0; 45 + const closeLeftDisabled = index === 0 || !isCurItem;
43 46
44 const disabled = tabStore.getTabList.length === 1; 47 const disabled = tabStore.getTabList.length === 1;
45 48
46 // Close right 49 // Close right
47 const closeRightDisabled = 50 const closeRightDisabled =
48 - index === tabStore.getTabList.length - 1 && tabStore.getLastDragEndIndex >= 0; 51 + !isCurItem || (index === tabStore.getTabList.length - 1 && tabStore.getLastDragEndIndex >= 0);
49 const dropMenuList: DropMenu[] = [ 52 const dropMenuList: DropMenu[] = [
50 { 53 {
51 icon: 'ion:reload-sharp', 54 icon: 'ion:reload-sharp',
@@ -78,7 +81,7 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp @@ -78,7 +81,7 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp
78 icon: 'dashicons:align-center', 81 icon: 'dashicons:align-center',
79 event: MenuEventEnum.CLOSE_OTHER, 82 event: MenuEventEnum.CLOSE_OTHER,
80 text: t('layout.multipleTab.closeOther'), 83 text: t('layout.multipleTab.closeOther'),
81 - disabled: disabled, 84 + disabled: disabled || !isCurItem,
82 }, 85 },
83 { 86 {
84 icon: 'clarity:minus-line', 87 icon: 'clarity:minus-line',