From 9419e18b798dcc033f7cc3417b7754cdc02fda99 Mon Sep 17 00:00:00 2001 From: lxk955 <164191365+lxk955@users.noreply.github.com> Date: Sun, 4 Oct 2026 16:33:28 +0800 Subject: [PATCH] feat(ui): support customizable maximum tab width --- .../editor/CloudSyncSelectionDialog.vue | 1 + .../editor/EditorSettingsDialog.vue | 26 +++++++++++++- .../components/layout/EditorGroupTabBar.vue | 31 +++++++++++++--- .../EditorGroupTabBar.behavior.spec.ts | 24 +++++++++++++ .../src/components/layout/appTabBar.css | 12 ++++++- apps/desktop/src/i18n/locales/az.ts | 7 ++++ apps/desktop/src/i18n/locales/en.ts | 7 ++++ apps/desktop/src/i18n/locales/es.ts | 7 ++++ apps/desktop/src/i18n/locales/id.ts | 7 ++++ apps/desktop/src/i18n/locales/it.ts | 7 ++++ apps/desktop/src/i18n/locales/ja.ts | 7 ++++ apps/desktop/src/i18n/locales/ko.ts | 7 ++++ apps/desktop/src/i18n/locales/pt-BR.ts | 7 ++++ apps/desktop/src/i18n/locales/ru.ts | 7 ++++ apps/desktop/src/i18n/locales/tr.ts | 7 ++++ apps/desktop/src/i18n/locales/zh-CN.ts | 7 ++++ apps/desktop/src/i18n/locales/zh-TW.ts | 7 ++++ .../__tests__/editorSettingsDraft.spec.ts | 35 +++++++++++++++++++ .../src/lib/settings/editorSettingsDraft.ts | 1 + .../src/lib/settings/settingsSearch.ts | 1 + .../src/lib/settings/settingsTransfer.ts | 1 + .../stores/__tests__/settingsStore.spec.ts | 20 +++++++++++ apps/desktop/src/stores/settingsStore.ts | 12 +++++++ 23 files changed, 242 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue b/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue index eca52254cc..56b36335cd 100644 --- a/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue +++ b/apps/desktop/src/components/editor/CloudSyncSelectionDialog.vue @@ -64,6 +64,7 @@ const editorSettingCategoryOverrides: Partial(settingsStore.editorSettings.tabPlace const editColorizeConnectionTabs = ref(settingsStore.editorSettings.colorizeConnectionTabs); const editTabGroupMode = ref(settingsStore.editorSettings.tabGroupMode); const editTabSortMode = ref(settingsStore.editorSettings.tabSortMode); +const editTabMaxWidth = ref(settingsStore.editorSettings.tabMaxWidth); const editShowTrayIcon = ref(settingsStore.desktopSettings.show_tray_icon); const editQuitOnClose = ref(settingsStore.desktopSettings.quit_on_close); const desktopCloseBehaviorResetPending = ref(false); @@ -1094,6 +1096,7 @@ function currentEditorSettingsDraft(): EditorSettingsDraft { colorizeConnectionTabs: editColorizeConnectionTabs.value, tabGroupMode: editTabGroupMode.value, tabSortMode: editTabSortMode.value, + tabMaxWidth: editTabMaxWidth.value, showColumnCommentsInHeader: editShowColumnCommentsInHeader.value, showColumnTypesInHeader: editShowColumnTypesInHeader.value, showColumnHeaderTooltips: editShowColumnHeaderTooltips.value, @@ -1769,6 +1772,7 @@ function syncEditorSettingsDraftFromStore() { editColorizeConnectionTabs.value = settingsStore.editorSettings.colorizeConnectionTabs; editTabGroupMode.value = settingsStore.editorSettings.tabGroupMode; editTabSortMode.value = settingsStore.editorSettings.tabSortMode; + editTabMaxWidth.value = settingsStore.editorSettings.tabMaxWidth; editShowColumnCommentsInHeader.value = settingsStore.editorSettings.showColumnCommentsInHeader; editShowColumnTypesInHeader.value = settingsStore.editorSettings.showColumnTypesInHeader; editShowColumnHeaderTooltips.value = settingsStore.editorSettings.showColumnHeaderTooltips; @@ -1919,6 +1923,7 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = { colorizeConnectionTabs: editColorizeConnectionTabs, tabGroupMode: editTabGroupMode, tabSortMode: editTabSortMode, + tabMaxWidth: editTabMaxWidth, showColumnCommentsInHeader: editShowColumnCommentsInHeader, showColumnTypesInHeader: editShowColumnTypesInHeader, showColumnHeaderTooltips: editShowColumnHeaderTooltips, @@ -2465,6 +2470,7 @@ function resetDefaultsForTab(tab: SettingsCategory) { editColorizeConnectionTabs.value = DEFAULT_EDITOR_SETTINGS.colorizeConnectionTabs; editTabGroupMode.value = DEFAULT_EDITOR_SETTINGS.tabGroupMode; editTabSortMode.value = DEFAULT_EDITOR_SETTINGS.tabSortMode; + editTabMaxWidth.value = DEFAULT_EDITOR_SETTINGS.tabMaxWidth; editShowTrayIcon.value = DEFAULT_DESKTOP_SETTINGS.show_tray_icon; editQuitOnClose.value = DEFAULT_DESKTOP_SETTINGS.quit_on_close; desktopCloseBehaviorResetPending.value = true; @@ -3160,6 +3166,10 @@ function setTabSortMode(value: TabSortMode) { editTabSortMode.value = value; } +function setTabMaxWidth(value: number) { + editTabMaxWidth.value = normalizeTabMaxWidth(value); +} + function setSidebarActivation(value: "single" | "double") { editSidebarActivation.value = value; } @@ -7579,7 +7589,7 @@ onUnmounted(() => {
-
+
+
+ + +

{{ t("settings.tabPlacementDescription") }}

{{ t("settings.tabOrganizationDescription") }}

+

{{ t("settings.tabMaxWidthDescription") }}

diff --git a/apps/desktop/src/components/layout/EditorGroupTabBar.vue b/apps/desktop/src/components/layout/EditorGroupTabBar.vue index 78024d6d88..6d3407e85a 100644 --- a/apps/desktop/src/components/layout/EditorGroupTabBar.vue +++ b/apps/desktop/src/components/layout/EditorGroupTabBar.vue @@ -42,6 +42,7 @@ import { Clock3, Copy, Database, + FoldHorizontal, ListFilter, ListOrdered, Maximize2, @@ -189,8 +190,15 @@ const showTabTreeGuides = computed(() => isVerticalLayout.value && !isTabBarColl // the shared vertical rail width; fill that rail so nested pane bars stay in // sync while the resize handle updates the outer panel (issue #9977). const tabBarStyle = computed(() => { - if (!isVerticalLayout.value) return undefined; - return { width: "100%", flex: "0 0 100%" }; + const styles: CSSProperties = {}; + if (isVerticalLayout.value) { + styles.width = "100%"; + styles.flex = "0 0 100%"; + } + if (!isVerticalLayout.value && settingsStore.editorSettings.tabMaxWidth > 0) { + styles["--tab-max-width"] = `${settingsStore.editorSettings.tabMaxWidth}px`; + } + return Object.keys(styles).length > 0 ? styles : undefined; }); const tabBarCollapseIcon = computed(() => { const isLeft = settingsStore.editorSettings.tabPlacement === "left"; @@ -375,8 +383,15 @@ const tabPlacementItems = computed(() => [ { value: "left", label: t("settings.tabPlacementLeft") }, { value: "right", label: t("settings.tabPlacementRight") }, ]); +const tabMaxWidthItems = computed(() => [ + { value: 0, label: t("settings.tabMaxWidthUnlimited") }, + { value: 160, label: t("settings.tabMaxWidthCompact") }, + { value: 200, label: t("settings.tabMaxWidthMedium") }, + { value: 240, label: t("settings.tabMaxWidthStandard") }, + { value: 320, label: t("settings.tabMaxWidthWide") }, +]); -type TabPreferencePatch = Partial>; +type TabPreferencePatch = Partial>; async function persistTabPreferences(partial: TabPreferencePatch) { try { @@ -398,6 +413,10 @@ function updateTabPlacement(value: string) { if (value === "top" || value === "bottom" || value === "left" || value === "right") void persistTabPreferences({ tabPlacement: value }); } +function updateTabMaxWidth(value: number) { + if (Number.isFinite(value) && value >= 0) void persistTabPreferences({ tabMaxWidth: value }); +} + function databaseTabGroupKey(tab: QueryTab) { const database = tab.database || ""; if (connectionStore.getConfig(tab.connectionId)?.db_type === "redis") { @@ -879,8 +898,9 @@ const tabOrganizationItems = computed(() => [ groupLabel: index === 0 ? t("settings.tabGroup") : undefined, })), ...tabSortItems.value.map((item, index) => ({ ...item, value: `sort:${item.value}`, icon: { manual: ListOrdered, "created-asc": Clock3, "title-asc": ArrowDownAZ }[item.value], separatorBefore: index === 0, groupLabel: index === 0 ? t("settings.tabSort") : undefined })), + ...tabMaxWidthItems.value.map((item, index) => ({ ...item, value: `maxwidth:${item.value}`, icon: item.value === 0 ? Maximize2 : FoldHorizontal, separatorBefore: index === 0, groupLabel: index === 0 ? t("settings.tabMaxWidth") : undefined })), ]); -const selectedTabOrganizationItems = computed(() => [`placement:${settingsStore.editorSettings.tabPlacement}`, `group:${settingsStore.editorSettings.tabGroupMode}`, `sort:${settingsStore.editorSettings.tabSortMode}`]); +const selectedTabOrganizationItems = computed(() => [`placement:${settingsStore.editorSettings.tabPlacement}`, `group:${settingsStore.editorSettings.tabGroupMode}`, `sort:${settingsStore.editorSettings.tabSortMode}`, `maxwidth:${settingsStore.editorSettings.tabMaxWidth}`]); function selectTabOrganizationItem(value: string) { const [section, option] = value.split(":"); @@ -888,6 +908,7 @@ function selectTabOrganizationItem(value: string) { if (section === "placement") updateTabPlacement(option); else if (section === "group") updateTabGroupMode(option); else if (section === "sort") updateTabSortMode(option); + else if (section === "maxwidth") updateTabMaxWidth(Number(option)); } function getTabGroupMenuItems(tab: QueryTab): ContextMenuItem[] { @@ -1566,6 +1587,7 @@ watch( props.specialPageTabs?.driverStoreOpen, settingsStore.editorSettings.tabLayout, settingsStore.editorSettings.tabGroupMode, + settingsStore.editorSettings.tabMaxWidth, compactTabTitle.value, Array.from(collapsedTabGroups.value).sort().join("|"), ], @@ -1618,6 +1640,7 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs? :data-group-id="groupId" :data-group-mode="settingsStore.editorSettings.tabGroupMode" :data-placement="settingsStore.editorSettings.tabPlacement" + :data-has-max-tab-width="!isVerticalLayout && settingsStore.editorSettings.tabMaxWidth > 0" >
diff --git a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts index da2c2b17e0..271097c4d0 100644 --- a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts +++ b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.behavior.spec.ts @@ -45,6 +45,7 @@ import EditorGroupTabBar from "../EditorGroupTabBar.vue"; import { createNoopEditorToolbarActions, EDITOR_TOOLBAR_ACTIONS, type EditorToolbarActions } from "../editorToolbarActions"; import { useConnectionStore } from "@/stores/connectionStore"; import { useQueryStore } from "@/stores/queryStore"; +import { useSettingsStore } from "@/stores/settingsStore"; import type { ConnectionConfig } from "@/types/database"; function createHost(): HTMLDivElement { @@ -729,4 +730,27 @@ describe("EditorGroupTabBar behavior", () => { app.unmount(); host.remove(); }); + + it("applies --tab-max-width and data-has-max-tab-width when tabMaxWidth is configured", async () => { + const store = useQueryStore(); + const settings = useSettingsStore(); + settings.editorSettings.tabMaxWidth = 240; + const firstId = store.createTab("pg-1", "app", "Query 1", "query"); + const mainGroup = store.groups[0]; + const { app, host } = mountBar(mainGroup.id, [firstId], firstId, pinia); + await settle(); + + const bar = host.querySelector(".app-tab-bar")!; + expect(bar.dataset.hasMaxTabWidth).toBe("true"); + expect(bar.style.getPropertyValue("--tab-max-width")).toBe("240px"); + + // Setting tabMaxWidth to 0 removes the limit + settings.editorSettings.tabMaxWidth = 0; + await settle(); + expect(bar.dataset.hasMaxTabWidth).toBe("false"); + expect(bar.style.getPropertyValue("--tab-max-width")).toBe(""); + + app.unmount(); + host.remove(); + }); }); diff --git a/apps/desktop/src/components/layout/appTabBar.css b/apps/desktop/src/components/layout/appTabBar.css index 67468b1c08..98c670b075 100644 --- a/apps/desktop/src/components/layout/appTabBar.css +++ b/apps/desktop/src/components/layout/appTabBar.css @@ -334,6 +334,7 @@ .app-tab-bar:not(.vertical-tab-layout) .app-tab-pill { border: 0.5px solid color-mix(in oklch, var(--foreground) 14%, var(--border)); + max-width: var(--tab-max-width, none); } .app-tab-bar:not(.vertical-tab-layout) .app-tab-pill[data-active-tab="true"] { @@ -843,7 +844,7 @@ * expand smoothly instead of appearing and disappearing in one frame. */ .app-tab-bar:not(.vertical-tab-layout):not(:has(.wrap-mode)) .tab-group-entry { min-width: 0; - max-width: var(--tab-group-entry-expanded-width, 100%); + max-width: var(--tab-group-entry-expanded-width, var(--tab-max-width, 100%)); max-height: 2rem; overflow: hidden; transition: @@ -859,6 +860,11 @@ flex: none; } +.app-tab-bar:not(.vertical-tab-layout):not(:has(.wrap-mode))[data-has-max-tab-width="true"] .tab-group-entry[data-tab-group-id] > .tab-group-tab { + min-width: var(--tab-group-entry-expanded-width, 0) !important; + max-width: var(--tab-max-width, 100%); +} + /* The classic single-row strip is 2.25rem tall. Keep ordinary tab wrappers * at the full row height so direct tabs such as Settings do not look taller. */ .app-tab-bar.classic-tab-layout:not(.vertical-tab-layout):not(:has(.wrap-mode)) .tab-group-entry { @@ -906,6 +912,10 @@ /* Do not animate dimensions in wrapped mode. The browser must reflow the * complete set of rows immediately when a group is expanded or collapsed. */ +.app-tab-scroll.wrap-mode .tab-group-entry { + max-width: var(--tab-max-width, none); +} + .app-tab-scroll.wrap-mode .tab-group-entry, .app-tab-scroll.wrap-mode .tab-group-entry--collapsed, .app-tab-scroll.wrap-mode .tab-group-tab, diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts index bf59d69ccb..04c5f76f6c 100644 --- a/apps/desktop/src/i18n/locales/az.ts +++ b/apps/desktop/src/i18n/locales/az.ts @@ -7132,6 +7132,13 @@ export default withEnglishFallback({ tabSortCreated: "Yaradılma vaxtı", tabSortTitle: "Vərəq adı", tabOrganizationDescription: "Qruplaşdırma və sıralama yalnız göstərilən ardıcıllığa təsir edir. Əl ilə sıralamada sürükləmə mümkündür.", + tabMaxWidth: "Vərəqin maksimum eni", + tabMaxWidthDescription: "Üfüqi vərəqlərin maksimum enini məhdudlaşdırır, uzun başlıqları qısaldır. Tam başlığı görmək üçün üzərinə gəlin.", + tabMaxWidthUnlimited: "Məhdudiyyətsiz (adaptiv)", + tabMaxWidthCompact: "Yığcam (160px)", + tabMaxWidthMedium: "Orta (200px)", + tabMaxWidthStandard: "Standart (240px)", + tabMaxWidthWide: "Geniş (320px)", iconTheme: "İkon və loqo üslubu", iconThemeDefault: "Standart", iconThemeDefaultDescription: "DBX tətbiqinin rəngli ikonundan istifadə et.", diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts index b130a17c0b..309a250786 100644 --- a/apps/desktop/src/i18n/locales/en.ts +++ b/apps/desktop/src/i18n/locales/en.ts @@ -8002,6 +8002,13 @@ export default { tabSortCreated: "Creation time", tabSortTitle: "Tab name", tabOrganizationDescription: "Grouping and sorting affect only the displayed order. Dragging is available in manual order.", + tabMaxWidth: "Maximum tab width", + tabMaxWidthDescription: "Limit the maximum width of horizontal tabs, truncating long titles with ellipsis. Hover to view the full title.", + tabMaxWidthUnlimited: "Unlimited (adaptive)", + tabMaxWidthCompact: "Compact (160px)", + tabMaxWidthMedium: "Medium (200px)", + tabMaxWidthStandard: "Standard (240px)", + tabMaxWidthWide: "Wide (320px)", iconTheme: "Icon and logo style", iconThemeDefault: "Default", iconThemeDefaultDescription: "Use the color DBX app icon.", diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts index dbba013884..97d5229aa8 100644 --- a/apps/desktop/src/i18n/locales/es.ts +++ b/apps/desktop/src/i18n/locales/es.ts @@ -7339,6 +7339,13 @@ export default withEnglishFallback({ tabSortCreated: "Hora de creación", tabSortTitle: "Nombre de pestaña", tabOrganizationDescription: "La agrupación y la ordenación solo afectan al orden visible. Arrastre disponible en orden manual.", + tabMaxWidth: "Ancho máximo de pestaña", + tabMaxWidthDescription: "Limita el ancho máximo de las pestañas horizontales, truncando títulos largos. Pase el cursor para ver el título completo.", + tabMaxWidthUnlimited: "Sin límite (adaptativo)", + tabMaxWidthCompact: "Compacto (160px)", + tabMaxWidthMedium: "Medio (200px)", + tabMaxWidthStandard: "Estándar (240px)", + tabMaxWidthWide: "Ancho (320px)", iconTheme: "Estilo de icono y logo", iconThemeDefault: "Predeterminado", iconThemeDefaultDescription: "Usar el icono de color de DBX.", diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts index 2d9597e3b6..0c385f4198 100644 --- a/apps/desktop/src/i18n/locales/id.ts +++ b/apps/desktop/src/i18n/locales/id.ts @@ -7796,6 +7796,13 @@ export default withEnglishFallback({ tabSortCreated: "Waktu pembuatan", tabSortTitle: "Nama tab", tabOrganizationDescription: "Pengelompokan dan pengurutan hanya memengaruhi urutan tampilan. Menyeret tab tersedia dalam urutan manual.", + tabMaxWidth: "Lebar tab maksimum", + tabMaxWidthDescription: "Batasi lebar maksimum tab horizontal, memotong judul yang panjang. Arahkan kursor untuk melihat judul lengkap.", + tabMaxWidthUnlimited: "Tanpa batas (adaptif)", + tabMaxWidthCompact: "Kompak (160px)", + tabMaxWidthMedium: "Sedang (200px)", + tabMaxWidthStandard: "Standar (240px)", + tabMaxWidthWide: "Lebar (320px)", iconTheme: "Gaya ikon dan logo", iconThemeDefault: "Default", iconThemeDefaultDescription: "Gunakan ikon aplikasi DBX berwarna.", diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts index 12e0ab9012..9685263660 100644 --- a/apps/desktop/src/i18n/locales/it.ts +++ b/apps/desktop/src/i18n/locales/it.ts @@ -7117,6 +7117,13 @@ export default withEnglishFallback({ tabSortCreated: "Data di creazione", tabSortTitle: "Nome scheda", tabOrganizationDescription: "Raggruppamento e ordinamento influenzano solo l'ordine visibile. Il trascinamento è disponibile nell'ordine manuale.", + tabMaxWidth: "Larghezza massima scheda", + tabMaxWidthDescription: "Limita la larghezza massima delle schede orizzontali, troncando i titoli lunghi. Passa il cursore per vedere il titolo completo.", + tabMaxWidthUnlimited: "Nessun limite (adattivo)", + tabMaxWidthCompact: "Compatto (160px)", + tabMaxWidthMedium: "Medio (200px)", + tabMaxWidthStandard: "Standard (240px)", + tabMaxWidthWide: "Ampio (320px)", iconTheme: "Stile icona e logo", iconThemeDefault: "Predefinito", iconThemeDefaultDescription: "Utilizza l'icona colorata dell'app DBX.", diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts index 4858486370..c623093e1f 100644 --- a/apps/desktop/src/i18n/locales/ja.ts +++ b/apps/desktop/src/i18n/locales/ja.ts @@ -7148,6 +7148,13 @@ export default withEnglishFallback({ tabSortCreated: "作成日時", tabSortTitle: "タブ名", tabOrganizationDescription: "グループ化と並べ替えは表示順にのみ影響します。ドラッグは手動順で利用できます。", + tabMaxWidth: "タブの最大幅", + tabMaxWidthDescription: "水平タブの最大表示幅を制限し、長すぎるタイトルは省略してホバー時に完全なタイトルを表示します。", + tabMaxWidthUnlimited: "制限なし(自動適合)", + tabMaxWidthCompact: "コンパクト (160px)", + tabMaxWidthMedium: "標準的 (200px)", + tabMaxWidthStandard: "標準 (240px)", + tabMaxWidthWide: "ワイド (320px)", iconTheme: "アイコンとロゴのスタイル", iconThemeDefault: "デフォルト", iconThemeDefaultDescription: "カラーDBXアプリアイコンを使用。", diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts index 7466ed26ac..bf6be2bb04 100644 --- a/apps/desktop/src/i18n/locales/ko.ts +++ b/apps/desktop/src/i18n/locales/ko.ts @@ -6923,6 +6923,13 @@ export default withEnglishFallback({ tabSortCreated: "생성 시간", tabSortTitle: "탭 이름", tabOrganizationDescription: "그룹화와 정렬은 표시 순서에만 영향을 줍니다. 끌기는 수동 순서에서 사용할 수 있습니다.", + tabMaxWidth: "탭 최대 너비", + tabMaxWidthDescription: "가로 탭의 최대 표시 너비를 제한하며, 긴 제목은 말줄임표로 표시하고 마우스 호버 시 전체 제목을 표시합니다.", + tabMaxWidthUnlimited: "제한 없음 (자동 맞춤)", + tabMaxWidthCompact: "간결하게 (160px)", + tabMaxWidthMedium: "중간 (200px)", + tabMaxWidthStandard: "표준 (240px)", + tabMaxWidthWide: "넓게 (320px)", iconTheme: "아이콘 및 로고 스타일", iconThemeDefault: "기본", iconThemeDefaultDescription: "컬러 DBX 앱 아이콘을 사용합니다.", diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts index 1c860901cb..3b3b9c7ed9 100644 --- a/apps/desktop/src/i18n/locales/pt-BR.ts +++ b/apps/desktop/src/i18n/locales/pt-BR.ts @@ -7119,6 +7119,13 @@ export default withEnglishFallback({ tabSortCreated: "Hora de criação", tabSortTitle: "Nome da aba", tabOrganizationDescription: "Agrupamento e ordenação afetam apenas a ordem exibida. Arrastar fica disponível na ordem manual.", + tabMaxWidth: "Largura máxima da aba", + tabMaxWidthDescription: "Limita a largura máxima das abas horizontais, truncando títulos longos. Passe o mouse para ver o título completo.", + tabMaxWidthUnlimited: "Sem limite (adaptativo)", + tabMaxWidthCompact: "Compacto (160px)", + tabMaxWidthMedium: "Médio (200px)", + tabMaxWidthStandard: "Padrão (240px)", + tabMaxWidthWide: "Largo (320px)", iconTheme: "Estilo do ícone e do logo", iconThemeDefault: "Padrão", iconThemeDefaultDescription: "Usar o ícone colorido do app DBX.", diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts index ccebdb240d..f759235d7f 100644 --- a/apps/desktop/src/i18n/locales/ru.ts +++ b/apps/desktop/src/i18n/locales/ru.ts @@ -8332,6 +8332,13 @@ export default withEnglishFallback({ tabSortCreated: "Время создания", tabSortTitle: "Имя вкладки", tabOrganizationDescription: "Группировка и сортировка влияют только на отображаемый порядок. Перетаскивание доступно при ручном порядке.", + tabMaxWidth: "Максимальная ширина вкладки", + tabMaxWidthDescription: "Ограничивает максимальную ширину горизонтальных вкладок, усекая длинные названия. Наведите курсор для полного названия.", + tabMaxWidthUnlimited: "Без ограничений (адаптивная)", + tabMaxWidthCompact: "Компактная (160px)", + tabMaxWidthMedium: "Средняя (200px)", + tabMaxWidthStandard: "Стандартная (240px)", + tabMaxWidthWide: "Широкая (320px)", iconTheme: "Стиль значка и логотипа", iconThemeDefault: "По умолчанию", iconThemeDefaultDescription: "Использовать цветной значок приложения DBX.", diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts index 416aead11d..b6cc06d382 100644 --- a/apps/desktop/src/i18n/locales/tr.ts +++ b/apps/desktop/src/i18n/locales/tr.ts @@ -7014,6 +7014,13 @@ export default withEnglishFallback({ tabSortCreated: "Oluşturulma zamanı", tabSortTitle: "Sekme adı", tabOrganizationDescription: "Gruplama ve sıralama yalnızca görüntülenen sırayı etkiler. Sürükleme, elle sıralamada kullanılabilir.", + tabMaxWidth: "Maksimum sekme genişliği", + tabMaxWidthDescription: "Yatay sekmelerin maksimum genişliğini sınırlar, uzun başlıkları kısaltır. Tam başlığı görmek için üzerine gelin.", + tabMaxWidthUnlimited: "Sınırsız (uyarlanabilir)", + tabMaxWidthCompact: "Kompakt (160px)", + tabMaxWidthMedium: "Orta (200px)", + tabMaxWidthStandard: "Standart (240px)", + tabMaxWidthWide: "Geniş (320px)", iconTheme: "Simge ve logo biçemi", iconThemeDefault: "Varsayılan", iconThemeDefaultDescription: "Renkli DBX uygulama simgesini kullan.", diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts index c1d81476dc..7eca1df2f0 100644 --- a/apps/desktop/src/i18n/locales/zh-CN.ts +++ b/apps/desktop/src/i18n/locales/zh-CN.ts @@ -7988,6 +7988,13 @@ export default withEnglishFallback({ tabSortCreated: "按创建时间", tabSortTitle: "按标签页名称", tabOrganizationDescription: "分组和排序只影响显示顺序;仅手动排序时支持拖拽。", + tabMaxWidth: "标签最大宽度", + tabMaxWidthDescription: "限制水平标签页的最大显示宽度,超出时省略显示,悬停显示完整标题。", + tabMaxWidthUnlimited: "不限制(完整自适应)", + tabMaxWidthCompact: "紧凑 (160px)", + tabMaxWidthMedium: "中等 (200px)", + tabMaxWidthStandard: "标准 (240px)", + tabMaxWidthWide: "宽松 (320px)", iconTheme: "图标与 Logo 样式", iconThemeDefault: "默认", iconThemeDefaultDescription: "使用彩色 DBX 应用图标。", diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts index a43181907e..4315b5af25 100644 --- a/apps/desktop/src/i18n/locales/zh-TW.ts +++ b/apps/desktop/src/i18n/locales/zh-TW.ts @@ -6471,6 +6471,13 @@ export default withEnglishFallback({ tabSortCreated: "依建立時間", tabSortTitle: "依標籤頁名稱", tabOrganizationDescription: "分組和排序只影響顯示順序;只有手動排序時可拖曳。", + tabMaxWidth: "標籤最大寬度", + tabMaxWidthDescription: "限制水平標籤頁的最大顯示寬度,超出時省略顯示,懸停顯示完整標題。", + tabMaxWidthUnlimited: "不限制(完整自適應)", + tabMaxWidthCompact: "緊湊 (160px)", + tabMaxWidthMedium: "中等 (200px)", + tabMaxWidthStandard: "標準 (240px)", + tabMaxWidthWide: "寬鬆 (320px)", iconTheme: "圖示與 Logo 樣式", iconThemeDefault: "預設", iconThemeDefaultDescription: "使用彩色 DBX 應用程式圖示。", diff --git a/apps/desktop/src/lib/settings/__tests__/editorSettingsDraft.spec.ts b/apps/desktop/src/lib/settings/__tests__/editorSettingsDraft.spec.ts index 081091ce73..8cb8caf16b 100644 --- a/apps/desktop/src/lib/settings/__tests__/editorSettingsDraft.spec.ts +++ b/apps/desktop/src/lib/settings/__tests__/editorSettingsDraft.spec.ts @@ -563,3 +563,38 @@ describe("editorSettingsDraftPatchFromSettings", () => { expect(patch.pageSize).toBe(normalizeTableOpenPageSizeDraft(999999)); }); }); + +describe("editorSettingsDraft - tabMaxWidth", () => { + it("includes tabMaxWidth in EDITOR_SETTINGS_DRAFT_KEYS", () => { + expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("tabMaxWidth"); + }); + + it("maps tabMaxWidth from settings", () => { + expect(editorSettingsDraftFromSettings(makeSettings({ tabMaxWidth: 240 })).tabMaxWidth).toBe(240); + expect(editorSettingsDraftFromSettings(makeSettings({ tabMaxWidth: 0 })).tabMaxWidth).toBe(0); + }); + + it("detects change in tabMaxWidth", () => { + const settings = makeSettings({ tabMaxWidth: 0 }); + const draft = editorSettingsDraftFromSettings(settings); + const base = editorSettingsDraftFromSettings(settings); + draft.tabMaxWidth = 240; + expect(editorSettingsDraftChanged(draft, base)).toBe(true); + }); + + it("detects no change when tabMaxWidth matches", () => { + const settings = makeSettings({ tabMaxWidth: 240 }); + const draft = editorSettingsDraftFromSettings(settings); + const base = editorSettingsDraftFromSettings(settings); + expect(editorSettingsDraftChanged(draft, base)).toBe(false); + }); + + it("includes tabMaxWidth in patch when changed", () => { + const settings = makeSettings({ tabMaxWidth: 0 }); + const draft = editorSettingsDraftFromSettings(settings); + const base = editorSettingsDraftFromSettings(settings); + draft.tabMaxWidth = 240; + const patch = editorSettingsPatchFromDraft(draft, base); + expect(patch.tabMaxWidth).toBe(240); + }); +}); diff --git a/apps/desktop/src/lib/settings/editorSettingsDraft.ts b/apps/desktop/src/lib/settings/editorSettingsDraft.ts index 212d7685a1..e70db4d501 100644 --- a/apps/desktop/src/lib/settings/editorSettingsDraft.ts +++ b/apps/desktop/src/lib/settings/editorSettingsDraft.ts @@ -52,6 +52,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [ "colorizeConnectionTabs", "tabGroupMode", "tabSortMode", + "tabMaxWidth", "showColumnCommentsInHeader", "showColumnTypesInHeader", "showColumnHeaderTooltips", diff --git a/apps/desktop/src/lib/settings/settingsSearch.ts b/apps/desktop/src/lib/settings/settingsSearch.ts index b6911e74c5..5b227fecb6 100644 --- a/apps/desktop/src/lib/settings/settingsSearch.ts +++ b/apps/desktop/src/lib/settings/settingsSearch.ts @@ -190,6 +190,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] = { id: "appearance-welcome-page", category: "appearance", titleKey: "settings.welcomePage", descriptionKey: "settings.welcomePageDescription", targetId: "welcome-page-settings" }, { id: "appearance-layout", category: "appearance", titleKey: "settings.appLayout", targetId: "appearance" }, { id: "appearance-tab-layout", category: "appearance", titleKey: "settings.tabLayout", targetId: "appearance" }, + { id: "appearance-tab-max-width", category: "appearance", titleKey: "settings.tabMaxWidth", descriptionKey: "settings.tabMaxWidthDescription", targetId: "appearance" }, { id: "appearance-connection-tab-colors", category: "appearance", titleKey: "settings.colorizeConnectionTabs", descriptionKey: "settings.colorizeConnectionTabsDescription", targetId: "appearance" }, { id: "appearance-icons", category: "appearance", titleKey: "settings.iconTheme", targetId: "appearance", visible: desktopOnly }, { id: "appearance-tray", category: "appearance", titleKey: "settings.showTrayIcon", descriptionKey: "settings.showTrayIconDescription", targetId: "appearance", visible: desktopOnly }, diff --git a/apps/desktop/src/lib/settings/settingsTransfer.ts b/apps/desktop/src/lib/settings/settingsTransfer.ts index e84b13d4f3..15840563d8 100644 --- a/apps/desktop/src/lib/settings/settingsTransfer.ts +++ b/apps/desktop/src/lib/settings/settingsTransfer.ts @@ -119,6 +119,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record { }); }); +describe("normalizeEditorSettings - tabMaxWidth", () => { + it("defaults tabMaxWidth to 0", () => { + expect(normalizeEditorSettings({}).tabMaxWidth).toBe(0); + }); + + it("preserves valid width values", () => { + expect(normalizeEditorSettings({ tabMaxWidth: 160 }).tabMaxWidth).toBe(160); + expect(normalizeEditorSettings({ tabMaxWidth: 240 }).tabMaxWidth).toBe(240); + expect(normalizeEditorSettings({ tabMaxWidth: 320 }).tabMaxWidth).toBe(320); + }); + + it("falls back to 0 for invalid values", () => { + expect(normalizeEditorSettings({ tabMaxWidth: -10 } as any).tabMaxWidth).toBe(0); + expect(normalizeEditorSettings({ tabMaxWidth: 9999 } as any).tabMaxWidth).toBe(0); + expect(normalizeEditorSettings({ tabMaxWidth: "240" } as any).tabMaxWidth).toBe(0); + expect(normalizeEditorSettings({ tabMaxWidth: null } as any).tabMaxWidth).toBe(0); + expect(normalizeEditorSettings({ tabMaxWidth: undefined } as any).tabMaxWidth).toBe(0); + }); +}); + describe("normalizeEditorSettings - sidebarPinDefaultDatabase", () => { it("defaults sidebarPinDefaultDatabase to true", () => { expect(normalizeEditorSettings({}).sidebarPinDefaultDatabase).toBe(true); diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.ts index 754b511f71..7558f4497a 100644 --- a/apps/desktop/src/stores/settingsStore.ts +++ b/apps/desktop/src/stores/settingsStore.ts @@ -914,6 +914,8 @@ export interface EditorSettings { tabGroupMode: TabGroupMode; tabGroupCustomizations: Record; tabSortMode: TabSortMode; + /** 水平标签页最大显示宽度(像素,0 表示不限制)。 */ + tabMaxWidth: number; appLayout: "separated" | "classic"; pageSize: number; tableOpenPageSize: number; @@ -1242,6 +1244,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = { tabGroupMode: "none", tabGroupCustomizations: {}, tabSortMode: "manual", + tabMaxWidth: 0, appLayout: "classic", pageSize: 100, tableOpenPageSize: 100, @@ -1460,6 +1463,13 @@ function normalizeTabSortMode(value: unknown): TabSortMode { return TAB_SORT_MODES.includes(value as TabSortMode) ? (value as TabSortMode) : DEFAULT_EDITOR_SETTINGS.tabSortMode; } +export function normalizeTabMaxWidth(value: unknown): number { + if (typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1200) { + return Math.round(value); + } + return DEFAULT_EDITOR_SETTINGS.tabMaxWidth; +} + function normalizeCellDetailPanelLayout(value: unknown): CellDetailPanelLayout { return CELL_DETAIL_PANEL_LAYOUTS.includes(value as CellDetailPanelLayout) ? (value as CellDetailPanelLayout) : DEFAULT_EDITOR_SETTINGS.cellDetailPanelLayout; } @@ -1842,6 +1852,7 @@ export function normalizeEditorSettings(settings: Partial, exist tabGroupMode: normalizeTabGroupMode(settings.tabGroupMode), tabGroupCustomizations: normalizeTabGroupCustomizations(settings.tabGroupCustomizations), tabSortMode: normalizeTabSortMode(settings.tabSortMode), + tabMaxWidth: normalizeTabMaxWidth(settings.tabMaxWidth), appLayout: settings.appLayout ?? DEFAULT_EDITOR_SETTINGS.appLayout, pageSize: normalizeResultPageSize(settings.pageSize), tableOpenPageSize: normalizeResultPageSize(settings.tableOpenPageSize, DEFAULT_EDITOR_SETTINGS.tableOpenPageSize), @@ -2696,6 +2707,7 @@ export const useSettingsStore = defineStore("settings", () => { if (partial.tabGroupMode !== undefined) editorSettings.value.tabGroupMode = normalizeTabGroupMode(partial.tabGroupMode); if (partial.tabGroupCustomizations !== undefined) editorSettings.value.tabGroupCustomizations = normalizeTabGroupCustomizations(partial.tabGroupCustomizations); if (partial.tabSortMode !== undefined) editorSettings.value.tabSortMode = normalizeTabSortMode(partial.tabSortMode); + if (partial.tabMaxWidth !== undefined) editorSettings.value.tabMaxWidth = normalizeTabMaxWidth(partial.tabMaxWidth); if (partial.appLayout !== undefined) editorSettings.value.appLayout = partial.appLayout; if (partial.pageSize !== undefined) editorSettings.value.pageSize = normalizeResultPageSize(partial.pageSize); if (partial.tableOpenPageSize !== undefined) editorSettings.value.tableOpenPageSize = normalizeResultPageSize(partial.tableOpenPageSize, DEFAULT_EDITOR_SETTINGS.tableOpenPageSize);