feat: tabs adds new window opening and maximizing/restore capabilities
parent
f98f504534
commit
59a8ce9500
|
@ -138,10 +138,22 @@ function usePreferences() {
|
||||||
return enable && globalPreferences;
|
return enable && globalPreferences;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh_CN 内容是否已经最大化
|
||||||
|
* 排除 full-content模式
|
||||||
|
*/
|
||||||
|
const contentIsMaximize = computed(() => {
|
||||||
|
const headerIsHidden = preferences.header.hidden;
|
||||||
|
const sidebarIsHidden = preferences.sidebar.hidden;
|
||||||
|
|
||||||
|
return headerIsHidden && sidebarIsHidden && !isFullContent.value;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
authPanelCenter,
|
authPanelCenter,
|
||||||
authPanelLeft,
|
authPanelLeft,
|
||||||
authPanelRight,
|
authPanelRight,
|
||||||
|
contentIsMaximize,
|
||||||
diffPreference,
|
diffPreference,
|
||||||
globalLockScreenShortcutKey,
|
globalLockScreenShortcutKey,
|
||||||
globalLogoutShortcutKey,
|
globalLogoutShortcutKey,
|
||||||
|
|
|
@ -184,7 +184,10 @@
|
||||||
"closeLeft": "Close Left Tabs",
|
"closeLeft": "Close Left Tabs",
|
||||||
"closeRight": "Close Right Tabs",
|
"closeRight": "Close Right Tabs",
|
||||||
"closeOther": "Close Other Tabs",
|
"closeOther": "Close Other Tabs",
|
||||||
"closeAll": "Close All Tabs"
|
"closeAll": "Close All Tabs",
|
||||||
|
"openInNewWindow": "Open in New Window",
|
||||||
|
"maximize": "Maximize",
|
||||||
|
"restoreMaximize": "Restore"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navigationMenu": {
|
"navigationMenu": {
|
||||||
|
|
|
@ -184,7 +184,10 @@
|
||||||
"closeLeft": "关闭左侧标签页",
|
"closeLeft": "关闭左侧标签页",
|
||||||
"closeRight": "关闭右侧标签页",
|
"closeRight": "关闭右侧标签页",
|
||||||
"closeOther": "关闭其它标签页",
|
"closeOther": "关闭其它标签页",
|
||||||
"closeAll": "关闭全部标签页"
|
"closeAll": "关闭全部标签页",
|
||||||
|
"openInNewWindow": "在新窗口打开",
|
||||||
|
"maximize": "最大化",
|
||||||
|
"restoreMaximize": "还原"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navigationMenu": {
|
"navigationMenu": {
|
||||||
|
|
|
@ -79,6 +79,8 @@ export const IcRoundArrowBackIosNew = createIconifyIcon(
|
||||||
|
|
||||||
export const IcRoundMultipleStop = createIconifyIcon('ic:round-multiple-stop');
|
export const IcRoundMultipleStop = createIconifyIcon('ic:round-multiple-stop');
|
||||||
|
|
||||||
|
export const IcRoundTableView = createIconifyIcon('ic:round-table-view');
|
||||||
|
|
||||||
export const IcRoundRefresh = createIconifyIcon('ic:round-refresh');
|
export const IcRoundRefresh = createIconifyIcon('ic:round-refresh');
|
||||||
|
|
||||||
export const IcRoundCreditScore = createIconifyIcon('ic:round-credit-score');
|
export const IcRoundCreditScore = createIconifyIcon('ic:round-credit-score');
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import { preferences, updatePreferences } from '@vben-core/preferences';
|
import { preferences } from '@vben-core/preferences';
|
||||||
import { TabsToolMore, TabsToolScreen } from '@vben-core/tabs-ui';
|
import { TabsToolMore, TabsToolScreen } from '@vben-core/tabs-ui';
|
||||||
|
|
||||||
import { useTabs } from './use-tabs';
|
import { updateContentScreen, useTabs } from './use-tabs';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -14,17 +14,6 @@ const { createContextMenus } = useTabs();
|
||||||
const menus = computed(() => {
|
const menus = computed(() => {
|
||||||
return createContextMenus(route);
|
return createContextMenus(route);
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleScreenChange(screen: boolean) {
|
|
||||||
updatePreferences({
|
|
||||||
header: {
|
|
||||||
hidden: !!screen,
|
|
||||||
},
|
|
||||||
sidebar: {
|
|
||||||
hidden: !!screen,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -32,8 +21,8 @@ function handleScreenChange(screen: boolean) {
|
||||||
<TabsToolMore :menus="menus" />
|
<TabsToolMore :menus="menus" />
|
||||||
<TabsToolScreen
|
<TabsToolScreen
|
||||||
:screen="preferences.sidebar.hidden"
|
:screen="preferences.sidebar.hidden"
|
||||||
@change="handleScreenChange"
|
@change="updateContentScreen"
|
||||||
@update:screen="handleScreenChange"
|
@update:screen="updateContentScreen"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -10,8 +10,11 @@ import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IcRoundClose,
|
IcRoundClose,
|
||||||
|
IcRoundFitScreen,
|
||||||
IcRoundMultipleStop,
|
IcRoundMultipleStop,
|
||||||
IcRoundRefresh,
|
IcRoundRefresh,
|
||||||
|
IcRoundTableView,
|
||||||
|
IcTwotoneFitScreen,
|
||||||
MdiArrowExpandHorizontal,
|
MdiArrowExpandHorizontal,
|
||||||
MdiFormatHorizontalAlignLeft,
|
MdiFormatHorizontalAlignLeft,
|
||||||
MdiFormatHorizontalAlignRight,
|
MdiFormatHorizontalAlignRight,
|
||||||
|
@ -19,17 +22,30 @@ import {
|
||||||
MdiPinOff,
|
MdiPinOff,
|
||||||
} from '@vben-core/iconify';
|
} from '@vben-core/iconify';
|
||||||
import { $t, useI18n } from '@vben-core/locales';
|
import { $t, useI18n } from '@vben-core/locales';
|
||||||
|
import { updatePreferences, usePreferences } from '@vben-core/preferences';
|
||||||
import {
|
import {
|
||||||
storeToRefs,
|
storeToRefs,
|
||||||
useCoreAccessStore,
|
useCoreAccessStore,
|
||||||
useCoreTabbarStore,
|
useCoreTabbarStore,
|
||||||
} from '@vben-core/stores';
|
} from '@vben-core/stores';
|
||||||
import { filterTree } from '@vben-core/toolkit';
|
import { filterTree, openWindow } from '@vben-core/toolkit';
|
||||||
|
|
||||||
|
function updateContentScreen(screen: boolean) {
|
||||||
|
updatePreferences({
|
||||||
|
header: {
|
||||||
|
hidden: !!screen,
|
||||||
|
},
|
||||||
|
sidebar: {
|
||||||
|
hidden: !!screen,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function useTabs() {
|
function useTabs() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const accessStore = useCoreAccessStore();
|
const accessStore = useCoreAccessStore();
|
||||||
|
const { contentIsMaximize } = usePreferences();
|
||||||
const coreTabbarStore = useCoreTabbarStore();
|
const coreTabbarStore = useCoreTabbarStore();
|
||||||
const { accessMenus } = storeToRefs(accessStore);
|
const { accessMenus } = storeToRefs(accessStore);
|
||||||
|
|
||||||
|
@ -136,11 +152,36 @@ function useTabs() {
|
||||||
},
|
},
|
||||||
icon: affixTab ? MdiPinOff : MdiPin,
|
icon: affixTab ? MdiPinOff : MdiPin,
|
||||||
key: 'affix',
|
key: 'affix',
|
||||||
separator: true,
|
|
||||||
text: affixTab
|
text: affixTab
|
||||||
? $t('preferences.tabbar.contextMenu.unpin')
|
? $t('preferences.tabbar.contextMenu.unpin')
|
||||||
: $t('preferences.tabbar.contextMenu.pin'),
|
: $t('preferences.tabbar.contextMenu.pin'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
handler: async () => {
|
||||||
|
const { hash, origin } = location;
|
||||||
|
const path = tab.fullPath;
|
||||||
|
const fullPath = path.startsWith('/') ? path : `/${path}`;
|
||||||
|
const url = `${origin}${hash ? '/#' : ''}${fullPath}`;
|
||||||
|
openWindow(url, { target: '_blank' });
|
||||||
|
},
|
||||||
|
icon: IcRoundTableView,
|
||||||
|
key: 'open-in-new-window',
|
||||||
|
text: $t('preferences.tabbar.contextMenu.openInNewWindow'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
handler: async () => {
|
||||||
|
if (!contentIsMaximize.value) {
|
||||||
|
await router.push(tab.fullPath);
|
||||||
|
}
|
||||||
|
updateContentScreen(!contentIsMaximize.value);
|
||||||
|
},
|
||||||
|
icon: contentIsMaximize.value ? IcRoundFitScreen : IcTwotoneFitScreen,
|
||||||
|
key: contentIsMaximize.value ? 'restore-maximize' : 'maximize',
|
||||||
|
separator: true,
|
||||||
|
text: contentIsMaximize.value
|
||||||
|
? $t('preferences.tabbar.contextMenu.restoreMaximize')
|
||||||
|
: $t('preferences.tabbar.contextMenu.maximize'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
disabled: closeLeftDisabled,
|
disabled: closeLeftDisabled,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
|
@ -178,11 +219,6 @@ function useTabs() {
|
||||||
key: 'close-all',
|
key: 'close-all',
|
||||||
text: $t('preferences.tabbar.contextMenu.closeAll'),
|
text: $t('preferences.tabbar.contextMenu.closeAll'),
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// icon: 'icon-[material-symbols--back-to-tab-sharp]',
|
|
||||||
// key: 'close-all',
|
|
||||||
// text: '新窗口打开',
|
|
||||||
// },
|
|
||||||
];
|
];
|
||||||
return menus;
|
return menus;
|
||||||
};
|
};
|
||||||
|
@ -204,4 +240,4 @@ function useTabs() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export { useTabs };
|
export { updateContentScreen, useTabs };
|
||||||
|
|
Loading…
Reference in New Issue