fix(tabs): dropdown items enabled unnecessary

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

fixed: #1207
This commit is contained in:
无木 2021-09-15 23:15:01 +08:00
parent 84c7d516df
commit cecdfbaf29

View File

@ -34,18 +34,21 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp
const { meta } = unref(getTargetTab); const { meta } = unref(getTargetTab);
const { path } = unref(currentRoute); const { path } = unref(currentRoute);
// Refresh button
const curItem = state.current; const curItem = state.current;
const isCurItem = curItem ? curItem.path === path : false;
// Refresh button
const index = state.currentIndex; const index = state.currentIndex;
const refreshDisabled = curItem ? curItem.path !== path : true; const refreshDisabled = !isCurItem;
// Close left // Close left
const closeLeftDisabled = index === 0; const closeLeftDisabled = index === 0 || !isCurItem;
const disabled = tabStore.getTabList.length === 1; const disabled = tabStore.getTabList.length === 1;
// Close right // Close right
const closeRightDisabled = const closeRightDisabled =
index === tabStore.getTabList.length - 1 && tabStore.getLastDragEndIndex >= 0; !isCurItem || (index === tabStore.getTabList.length - 1 && tabStore.getLastDragEndIndex >= 0);
const dropMenuList: DropMenu[] = [ const dropMenuList: DropMenu[] = [
{ {
icon: 'ion:reload-sharp', icon: 'ion:reload-sharp',
@ -78,7 +81,7 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp
icon: 'dashicons:align-center', icon: 'dashicons:align-center',
event: MenuEventEnum.CLOSE_OTHER, event: MenuEventEnum.CLOSE_OTHER,
text: t('layout.multipleTab.closeOther'), text: t('layout.multipleTab.closeOther'),
disabled: disabled, disabled: disabled || !isCurItem,
}, },
{ {
icon: 'clarity:minus-line', icon: 'clarity:minus-line',