feat(tabs): configurable tab bar position, grouping and sorting

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-01 10:59:50 +08:00
1 parent d69cf9da79
commit 5f9ba51769
18 files changed
+728 -353

No files matched your search

+14 -16
View File
@@ -733,6 +733,16 @@ export const useQueryStore = defineStore("query", () => {
const t = getI18nT();
const settingsStore = useSettingsStore();
const tabs = ref<QueryTab[]>([]);
// New tabs are created by many feature-specific entry points. Tracking id
// changes here gives every one a stable timestamp without duplicating the
// field at each call site; restored legacy tabs retain their saved order.
function ensureTabCreationTimes() {
const migrationBase = Date.now() - tabs.value.length;
tabs.value.forEach((tab, index) => {
if (typeof tab.createdAt !== "number" || !Number.isFinite(tab.createdAt)) tab.createdAt = migrationBase + index;
});
}
watch(() => tabs.value.map((tab) => tab.id), ensureTabCreationTimes, { immediate: true, flush: "sync" });
// Default auto-commit for a fresh query tab follows the user's global
// "默认事务提交方式" setting (Settings > Editor), not a hard-coded constant.
const defaultAutoCommitForDbTypeWithSetting = (dbType?: string) => defaultAutoCommitForDbType(dbType, settingsStore.editorSettings.defaultTransactionMode);
@@ -2858,20 +2868,8 @@ export const useQueryStore = defineStore("query", () => {
);
}
function closeLeftTabs(id: string, onComplete?: () => void) {
const target = tabs.value.find((tab) => tab.id === id);
if (!target) return;
const groupedTabs = tabs.value.filter((tab) => Boolean(tab.pinned) === Boolean(target.pinned));
const targetIndex = groupedTabs.findIndex((tab) => tab.id === id);
const ids = groupedTabs.slice(0, targetIndex).map((tab) => tab.id);
if (ids.length === 0) {
onComplete?.();
return;
}
const finalActiveTabId = activeTabId.value && !ids.includes(activeTabId.value) ? activeTabId.value : id;
beginBatchClose(ids, finalActiveTabId, onComplete);
function closeTabsByIds(ids: Iterable<string>, finalActiveTabId?: string | null, onComplete?: () => void) {
beginBatchClose([...ids], finalActiveTabId, onComplete);
}
function closeRightTabs(id: string, onComplete?: () => void) {
@@ -2887,7 +2885,7 @@ export const useQueryStore = defineStore("query", () => {
}
const finalActiveTabId = activeTabId.value && !ids.includes(activeTabId.value) ? activeTabId.value : id;
beginBatchClose(ids, finalActiveTabId, onComplete);
closeTabsByIds(ids, finalActiveTabId, onComplete);
}
function finalActiveTabAfterClosing(ids: string[]) {
@@ -6852,7 +6850,7 @@ export const useQueryStore = defineStore("query", () => {
discardTabChanges,
requestAppCloseConfirmation,
closeOtherTabs,
closeLeftTabs,
closeTabsByIds,
closeRightTabs,
closeOtherRegularTabs,
closeRegularTabs,