refactor(@vben-core/tabs-ui): refactor tabs chrome component

This commit is contained in:
vben
2024-07-14 15:18:02 +08:00
parent d1a19c525f
commit fed422e187
35 changed files with 662 additions and 518 deletions

View File

@@ -83,8 +83,8 @@ function useTabs() {
return {
...tab,
meta: {
...tab.meta,
title: $t(tab.meta.title as string),
...tab?.meta,
title: $t(tab?.meta?.title as string),
},
};
}
@@ -126,6 +126,27 @@ function useTabs() {
disabled || !isCurrentTab || tabs.length - affixTabs.length <= 1;
const menus: IContextMenuItem[] = [
{
disabled: !!affixTab || disabled,
handler: async () => {
await coreTabbarStore.closeTab(tab, router);
},
icon: IcRoundClose,
key: 'close',
text: $t('preferences.tabbar.contextMenu.close'),
},
{
handler: async () => {
await (affixTab
? coreTabbarStore.unpinTab(tab)
: coreTabbarStore.pinTab(tab));
},
icon: affixTab ? MdiPinOff : MdiPin,
key: 'affix',
text: affixTab
? $t('preferences.tabbar.contextMenu.unpin')
: $t('preferences.tabbar.contextMenu.pin'),
},
{
handler: async () => {
if (!contentIsMaximize.value) {
@@ -148,27 +169,7 @@ function useTabs() {
key: 'reload',
text: $t('preferences.tabbar.contextMenu.reload'),
},
{
disabled: !!affixTab || disabled,
handler: async () => {
await coreTabbarStore.closeTab(tab, router);
},
icon: IcRoundClose,
key: 'close',
text: $t('preferences.tabbar.contextMenu.close'),
},
{
handler: async () => {
await (affixTab
? coreTabbarStore.unpinTab(tab)
: coreTabbarStore.pinTab(tab));
},
icon: affixTab ? MdiPinOff : MdiPin,
key: 'affix',
text: affixTab
? $t('preferences.tabbar.contextMenu.unpin')
: $t('preferences.tabbar.contextMenu.pin'),
},
{
handler: async () => {
const { hash, origin } = location;