feat(settings): add interface font selection
This commit is contained in:
1 parent
074715b002
commit
d249bd5ac8
13 files changed
+175
-25
No files matched your search
@@ -73,6 +73,7 @@ import { buildHistoryAiAnalysisPrompt } from "@/lib/historyAiAnalysis";
|
|||||||
import { countAvailableAgentDriverUpdates, type AgentDriverUpdateBadgeState } from "@/lib/agentDriverUpdateBadge";
|
import { countAvailableAgentDriverUpdates, type AgentDriverUpdateBadgeState } from "@/lib/agentDriverUpdateBadge";
|
||||||
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/safeStorage";
|
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/safeStorage";
|
||||||
import { apiUrl, webPath } from "@/lib/webPath";
|
import { apiUrl, webPath } from "@/lib/webPath";
|
||||||
|
import { APP_FONT_SANS_CSS_VAR, DEFAULT_UI_FONT_FAMILY } from "@/lib/appFonts";
|
||||||
import { rankSavedSqlHistory } from "@/lib/savedSqlHistory";
|
import { rankSavedSqlHistory } from "@/lib/savedSqlHistory";
|
||||||
import { isSchemaAware, isSingleDatabase, usesTreeSchemaMode } from "@/lib/databaseFeatureSupport";
|
import { isSchemaAware, isSingleDatabase, usesTreeSchemaMode } from "@/lib/databaseFeatureSupport";
|
||||||
import { codeMirrorSqlDialect, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection } from "@/lib/jdbcDialect";
|
import { codeMirrorSqlDialect, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection } from "@/lib/jdbcDialect";
|
||||||
@@ -383,6 +384,22 @@ function resetUiZoom() {
|
|||||||
setGlobalUiScale(1);
|
setGlobalUiScale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyUiFontFamily(fontFamily: string) {
|
||||||
|
if (typeof document === "undefined") return;
|
||||||
|
const next = fontFamily || DEFAULT_UI_FONT_FAMILY;
|
||||||
|
// Override Tailwind's shared sans variable so app chrome and existing UI classes stay in sync.
|
||||||
|
document.documentElement.style.setProperty(APP_FONT_SANS_CSS_VAR, next);
|
||||||
|
document.body.style.fontFamily = `var(${APP_FONT_SANS_CSS_VAR}, ${DEFAULT_UI_FONT_FAMILY})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const appUiFontFamilyStyle = computed<Record<string, string>>(() => {
|
||||||
|
const fontFamily = settingsStore.editorSettings.uiFontFamily || DEFAULT_UI_FONT_FAMILY;
|
||||||
|
return {
|
||||||
|
[APP_FONT_SANS_CSS_VAR]: fontFamily,
|
||||||
|
fontFamily: `var(${APP_FONT_SANS_CSS_VAR}, ${DEFAULT_UI_FONT_FAMILY})`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
function isGlobalUiZoomTarget(target: EventTarget | null): target is Element {
|
function isGlobalUiZoomTarget(target: EventTarget | null): target is Element {
|
||||||
if (!(target instanceof Element)) return false;
|
if (!(target instanceof Element)) return false;
|
||||||
if (target.closest("[data-query-editor-root], [data-cell-detail-editor-root], [data-object-source-editor]")) {
|
if (target.closest("[data-query-editor-root], [data-cell-detail-editor-root], [data-object-source-editor]")) {
|
||||||
@@ -428,6 +445,14 @@ watch(
|
|||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => settingsStore.editorSettings.uiFontFamily,
|
||||||
|
(fontFamily) => {
|
||||||
|
applyUiFontFamily(fontFamily);
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
function toggleAiPanel() {
|
function toggleAiPanel() {
|
||||||
showAiPanel.value = !showAiPanel.value;
|
showAiPanel.value = !showAiPanel.value;
|
||||||
safeLocalStorageSet("dbx-ai-panel-open", String(showAiPanel.value));
|
safeLocalStorageSet("dbx-ai-panel-open", String(showAiPanel.value));
|
||||||
@@ -1675,7 +1700,7 @@ onUnmounted(() => {
|
|||||||
<LoginPage v-if="setupRequired || (needsAuth && !authenticated)" :setup-mode="setupRequired" @authenticated="onLoginSuccess" />
|
<LoginPage v-if="setupRequired || (needsAuth && !authenticated)" :setup-mode="setupRequired" @authenticated="onLoginSuccess" />
|
||||||
<div v-show="!setupRequired && (!needsAuth || authenticated)" class="fixed inset-0 h-screen w-screen overflow-hidden">
|
<div v-show="!setupRequired && (!needsAuth || authenticated)" class="fixed inset-0 h-screen w-screen overflow-hidden">
|
||||||
<TooltipProvider :delay-duration="300">
|
<TooltipProvider :delay-duration="300">
|
||||||
<div class="h-screen w-screen max-w-full min-w-[760px] min-h-[600px] flex flex-col bg-background text-foreground overflow-hidden">
|
<div class="h-screen w-screen max-w-full min-w-[760px] min-h-[600px] flex flex-col bg-background text-foreground overflow-hidden" :style="appUiFontFamilyStyle">
|
||||||
<AppToolbar
|
<AppToolbar
|
||||||
:is-dark="isDark"
|
:is-dark="isDark"
|
||||||
:theme-mode="themeMode"
|
:theme-mode="themeMode"
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ import { currentLocale, setLocale, type Locale } from "@/i18n";
|
|||||||
import { LOCALE_OPTIONS } from "@/lib/localeOptions";
|
import { LOCALE_OPTIONS } from "@/lib/localeOptions";
|
||||||
import { DEFAULT_WEB_DAV_AUTO_UPLOAD_INTERVAL_MINUTES, DEFAULT_WEB_DAV_REMOTE_PATH, normalizedWebDavAutoUploadInterval, writeWebDavAutoUploadFields } from "@/lib/webdavAutoUploadConfig";
|
import { DEFAULT_WEB_DAV_AUTO_UPLOAD_INTERVAL_MINUTES, DEFAULT_WEB_DAV_REMOTE_PATH, normalizedWebDavAutoUploadInterval, writeWebDavAutoUploadFields } from "@/lib/webdavAutoUploadConfig";
|
||||||
import { apiUrl } from "@/lib/webPath";
|
import { apiUrl } from "@/lib/webPath";
|
||||||
|
import { DEFAULT_UI_FONT_FAMILY, SYSTEM_UI_FONT_FAMILY } from "@/lib/appFonts";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const settingsStore = useSettingsStore();
|
const settingsStore = useSettingsStore();
|
||||||
@@ -202,6 +203,7 @@ function createEmptyTableColumnTemplateRow(): TableColumnTemplateGridRow {
|
|||||||
// Local edit state
|
// Local edit state
|
||||||
const editFontFamily = ref(settingsStore.editorSettings.fontFamily);
|
const editFontFamily = ref(settingsStore.editorSettings.fontFamily);
|
||||||
const editFontSize = ref(settingsStore.editorSettings.fontSize);
|
const editFontSize = ref(settingsStore.editorSettings.fontSize);
|
||||||
|
const editUiFontFamily = ref(settingsStore.editorSettings.uiFontFamily);
|
||||||
const editUiScale = ref(settingsStore.editorSettings.uiScale);
|
const editUiScale = ref(settingsStore.editorSettings.uiScale);
|
||||||
const editTheme = ref(settingsStore.editorSettings.theme);
|
const editTheme = ref(settingsStore.editorSettings.theme);
|
||||||
const editCustomThemes = ref<CustomTheme[]>([...settingsStore.editorSettings.customThemes]);
|
const editCustomThemes = ref<CustomTheme[]>([...settingsStore.editorSettings.customThemes]);
|
||||||
@@ -260,6 +262,9 @@ const systemFonts = ref<string[]>([]);
|
|||||||
const systemFontsLoading = ref(false);
|
const systemFontsLoading = ref(false);
|
||||||
const systemFontsLoaded = ref(false);
|
const systemFontsLoaded = ref(false);
|
||||||
const uiScaleOptions = [0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
const uiScaleOptions = [0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||||
|
const fontSearchTriggerClass =
|
||||||
|
"h-8 w-full max-w-none justify-between gap-1.5 rounded-[6px] border border-input bg-transparent py-2 pl-2.5 pr-2 text-sm font-normal shadow-none hover:bg-transparent focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-expanded:bg-transparent dark:bg-input/30 dark:hover:bg-input/50";
|
||||||
|
const fontSearchTriggerIconClass = "size-4 text-muted-foreground";
|
||||||
const disconnectTabHandlingModeDescriptionKey = computed(() => {
|
const disconnectTabHandlingModeDescriptionKey = computed(() => {
|
||||||
switch (editDisconnectTabHandlingMode.value) {
|
switch (editDisconnectTabHandlingMode.value) {
|
||||||
case "close-tabs":
|
case "close-tabs":
|
||||||
@@ -425,6 +430,7 @@ function confirmDeleteSnippet(snippet: SqlSnippet) {
|
|||||||
|
|
||||||
const presetFontLabels = new Map(FONT_FAMILIES.map((font) => [font.value, font.label]));
|
const presetFontLabels = new Map(FONT_FAMILIES.map((font) => [font.value, font.label]));
|
||||||
const presetFontValues = new Set(FONT_FAMILIES.map((font) => font.value));
|
const presetFontValues = new Set(FONT_FAMILIES.map((font) => font.value));
|
||||||
|
const uiFontPreviewValues = new Set([DEFAULT_UI_FONT_FAMILY, SYSTEM_UI_FONT_FAMILY]);
|
||||||
|
|
||||||
function cssFontFamilyForName(name: string): string {
|
function cssFontFamilyForName(name: string): string {
|
||||||
return `'${name.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}', monospace`;
|
return `'${name.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}', monospace`;
|
||||||
@@ -449,12 +455,24 @@ const systemFontOptions = computed(() => {
|
|||||||
return [...options];
|
return [...options];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const uiFontOptions = computed(() => {
|
||||||
|
const options = new Set([SYSTEM_UI_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY, ...systemFontOptions.value]);
|
||||||
|
if (editUiFontFamily.value) options.add(editUiFontFamily.value);
|
||||||
|
return [...options];
|
||||||
|
});
|
||||||
|
|
||||||
function displayFontFamily(value: string): string {
|
function displayFontFamily(value: string): string {
|
||||||
return presetFontLabels.get(value) ?? readableFontFamily(value);
|
return presetFontLabels.get(value) ?? readableFontFamily(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fontOptionStyle(value: string) {
|
function displayUiFontFamily(value: string): string {
|
||||||
return presetFontValues.has(value) || value === editFontFamily.value ? { fontFamily: value } : undefined;
|
if (value === SYSTEM_UI_FONT_FAMILY) return t("settings.uiFontSystemDefault");
|
||||||
|
if (value === DEFAULT_UI_FONT_FAMILY) return t("settings.uiFontAppDefault");
|
||||||
|
return displayFontFamily(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fontOptionStyle(value: string, selectedValue = editFontFamily.value) {
|
||||||
|
return presetFontValues.has(value) || uiFontPreviewValues.has(value) || value === selectedValue ? { fontFamily: value } : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadSystemFontOptions() {
|
async function loadSystemFontOptions() {
|
||||||
@@ -485,6 +503,7 @@ watch(
|
|||||||
if (open) {
|
if (open) {
|
||||||
editFontFamily.value = settingsStore.editorSettings.fontFamily;
|
editFontFamily.value = settingsStore.editorSettings.fontFamily;
|
||||||
editFontSize.value = settingsStore.editorSettings.fontSize;
|
editFontSize.value = settingsStore.editorSettings.fontSize;
|
||||||
|
editUiFontFamily.value = settingsStore.editorSettings.uiFontFamily;
|
||||||
editUiScale.value = settingsStore.editorSettings.uiScale;
|
editUiScale.value = settingsStore.editorSettings.uiScale;
|
||||||
editTheme.value = settingsStore.editorSettings.theme;
|
editTheme.value = settingsStore.editorSettings.theme;
|
||||||
editCustomThemes.value = [...settingsStore.editorSettings.customThemes];
|
editCustomThemes.value = [...settingsStore.editorSettings.customThemes];
|
||||||
@@ -553,6 +572,7 @@ function hasChanges(): boolean {
|
|||||||
return (
|
return (
|
||||||
editFontFamily.value !== settingsStore.editorSettings.fontFamily ||
|
editFontFamily.value !== settingsStore.editorSettings.fontFamily ||
|
||||||
editFontSize.value !== settingsStore.editorSettings.fontSize ||
|
editFontSize.value !== settingsStore.editorSettings.fontSize ||
|
||||||
|
editUiFontFamily.value !== settingsStore.editorSettings.uiFontFamily ||
|
||||||
editUiScale.value !== settingsStore.editorSettings.uiScale ||
|
editUiScale.value !== settingsStore.editorSettings.uiScale ||
|
||||||
editTheme.value !== settingsStore.editorSettings.theme ||
|
editTheme.value !== settingsStore.editorSettings.theme ||
|
||||||
JSON.stringify(editCustomThemes.value) !== JSON.stringify(settingsStore.editorSettings.customThemes) ||
|
JSON.stringify(editCustomThemes.value) !== JSON.stringify(settingsStore.editorSettings.customThemes) ||
|
||||||
@@ -607,6 +627,7 @@ async function persistSettings() {
|
|||||||
settingsStore.updateEditorSettings({
|
settingsStore.updateEditorSettings({
|
||||||
fontFamily: editFontFamily.value,
|
fontFamily: editFontFamily.value,
|
||||||
fontSize: editFontSize.value,
|
fontSize: editFontSize.value,
|
||||||
|
uiFontFamily: editUiFontFamily.value,
|
||||||
uiScale: editUiScale.value,
|
uiScale: editUiScale.value,
|
||||||
theme: editTheme.value,
|
theme: editTheme.value,
|
||||||
customThemes: editCustomThemes.value,
|
customThemes: editCustomThemes.value,
|
||||||
@@ -687,6 +708,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
|
|||||||
editSqlFormatter.value = normalizeSqlFormatterSettings(DEFAULT_EDITOR_SETTINGS.sqlFormatter);
|
editSqlFormatter.value = normalizeSqlFormatterSettings(DEFAULT_EDITOR_SETTINGS.sqlFormatter);
|
||||||
sqlFormatterConfigValid.value = true;
|
sqlFormatterConfigValid.value = true;
|
||||||
} else if (tab === "appearance") {
|
} else if (tab === "appearance") {
|
||||||
|
editUiFontFamily.value = DEFAULT_EDITOR_SETTINGS.uiFontFamily;
|
||||||
editUiScale.value = DEFAULT_EDITOR_SETTINGS.uiScale;
|
editUiScale.value = DEFAULT_EDITOR_SETTINGS.uiScale;
|
||||||
editTheme.value = DEFAULT_EDITOR_SETTINGS.theme;
|
editTheme.value = DEFAULT_EDITOR_SETTINGS.theme;
|
||||||
editCustomThemes.value = [...DEFAULT_EDITOR_SETTINGS.customThemes];
|
editCustomThemes.value = [...DEFAULT_EDITOR_SETTINGS.customThemes];
|
||||||
@@ -734,6 +756,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
|
|||||||
function resetAllDefaults() {
|
function resetAllDefaults() {
|
||||||
editFontFamily.value = DEFAULT_EDITOR_SETTINGS.fontFamily;
|
editFontFamily.value = DEFAULT_EDITOR_SETTINGS.fontFamily;
|
||||||
editFontSize.value = DEFAULT_EDITOR_SETTINGS.fontSize;
|
editFontSize.value = DEFAULT_EDITOR_SETTINGS.fontSize;
|
||||||
|
editUiFontFamily.value = DEFAULT_EDITOR_SETTINGS.uiFontFamily;
|
||||||
editUiScale.value = DEFAULT_EDITOR_SETTINGS.uiScale;
|
editUiScale.value = DEFAULT_EDITOR_SETTINGS.uiScale;
|
||||||
editTheme.value = DEFAULT_EDITOR_SETTINGS.theme;
|
editTheme.value = DEFAULT_EDITOR_SETTINGS.theme;
|
||||||
editCustomThemes.value = [...DEFAULT_EDITOR_SETTINGS.customThemes];
|
editCustomThemes.value = [...DEFAULT_EDITOR_SETTINGS.customThemes];
|
||||||
@@ -919,6 +942,10 @@ function onFontFamilyChange(v: any) {
|
|||||||
if (typeof v === "string") editFontFamily.value = v;
|
if (typeof v === "string") editFontFamily.value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onUiFontFamilyChange(v: any) {
|
||||||
|
if (typeof v === "string") editUiFontFamily.value = v;
|
||||||
|
}
|
||||||
|
|
||||||
const themeSelectValue = computed(() => {
|
const themeSelectValue = computed(() => {
|
||||||
if (editTheme.value === "custom") {
|
if (editTheme.value === "custom") {
|
||||||
return `custom:${editActiveCustomThemeId.value}`;
|
return `custom:${editActiveCustomThemeId.value}`;
|
||||||
@@ -2044,7 +2071,8 @@ onUnmounted(cleanupPreviewEditor);
|
|||||||
allow-custom
|
allow-custom
|
||||||
:display-name="displayFontFamily"
|
:display-name="displayFontFamily"
|
||||||
:normalize-custom="normalizeCustomFontFamilyInput"
|
:normalize-custom="normalizeCustomFontFamilyInput"
|
||||||
trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"
|
:trigger-class="fontSearchTriggerClass"
|
||||||
|
:trigger-icon-class="fontSearchTriggerIconClass"
|
||||||
content-class="w-[var(--reka-popover-trigger-width)] min-w-[260px]"
|
content-class="w-[var(--reka-popover-trigger-width)] min-w-[260px]"
|
||||||
@update:model-value="onFontFamilyChange"
|
@update:model-value="onFontFamilyChange"
|
||||||
@update:open="(open: boolean) => open && loadSystemFontOptions()"
|
@update:open="(open: boolean) => open && loadSystemFontOptions()"
|
||||||
@@ -2260,23 +2288,60 @@ onUnmounted(cleanupPreviewEditor);
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section v-else-if="activeSettingsTab === 'appearance'" class="flex flex-col gap-5 py-2">
|
<section v-else-if="activeSettingsTab === 'appearance'" class="flex flex-col gap-5 py-2">
|
||||||
<div class="space-y-2">
|
<div class="grid gap-4 md:grid-cols-[minmax(220px,280px)_minmax(260px,1fr)]">
|
||||||
<Label>{{ t("settings.languageTitle") }}</Label>
|
<div class="space-y-2 min-w-0">
|
||||||
<Select :model-value="currentLocale()" @update:model-value="onLocaleChange">
|
<Label>{{ t("settings.languageTitle") }}</Label>
|
||||||
<SelectTrigger class="min-w-36">
|
<Select :model-value="currentLocale()" @update:model-value="onLocaleChange">
|
||||||
<SelectValue />
|
<SelectTrigger class="h-8 w-full">
|
||||||
</SelectTrigger>
|
<SelectValue />
|
||||||
<SelectContent>
|
</SelectTrigger>
|
||||||
<SelectItem v-for="locale in LOCALE_OPTIONS" :key="locale.value" :value="locale.value">
|
<SelectContent>
|
||||||
<div class="flex items-center gap-2">
|
<SelectItem v-for="locale in LOCALE_OPTIONS" :key="locale.value" :value="locale.value">
|
||||||
<span class="inline-flex h-5 w-6 shrink-0 items-center justify-center text-sm font-medium leading-none">
|
<div class="flex items-center gap-2">
|
||||||
{{ locale.flag }}
|
<span class="inline-flex h-5 w-6 shrink-0 items-center justify-center text-sm font-medium leading-none">
|
||||||
</span>
|
{{ locale.flag }}
|
||||||
<span>{{ locale.label }}</span>
|
</span>
|
||||||
</div>
|
<span>{{ locale.label }}</span>
|
||||||
</SelectItem>
|
</div>
|
||||||
</SelectContent>
|
</SelectItem>
|
||||||
</Select>
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-2 min-w-0">
|
||||||
|
<Label>{{ t("settings.uiFontFamily") }}</Label>
|
||||||
|
<SearchableSelect
|
||||||
|
:model-value="editUiFontFamily"
|
||||||
|
:options="uiFontOptions"
|
||||||
|
:placeholder="t('settings.selectFont')"
|
||||||
|
:search-placeholder="t('settings.searchFont')"
|
||||||
|
:empty-text="t('settings.noFontsFound')"
|
||||||
|
:loading-text="t('settings.loadingFonts')"
|
||||||
|
allow-custom
|
||||||
|
:display-name="displayUiFontFamily"
|
||||||
|
:normalize-custom="normalizeCustomFontFamilyInput"
|
||||||
|
:trigger-class="fontSearchTriggerClass"
|
||||||
|
:trigger-icon-class="fontSearchTriggerIconClass"
|
||||||
|
content-class="w-[var(--reka-popover-trigger-width)] min-w-[260px]"
|
||||||
|
@update:model-value="onUiFontFamilyChange"
|
||||||
|
@update:open="(open: boolean) => open && loadSystemFontOptions()"
|
||||||
|
>
|
||||||
|
<template #trigger-label="{ label, loading }">
|
||||||
|
<span class="truncate" :style="{ fontFamily: editUiFontFamily }">
|
||||||
|
{{ loading ? t("settings.loadingFonts") : label }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #option-label="{ option, label }">
|
||||||
|
<span class="truncate" :style="fontOptionStyle(option, editUiFontFamily)">{{ label }}</span>
|
||||||
|
</template>
|
||||||
|
<template #custom-option-label="{ value }">
|
||||||
|
<span class="truncate" :style="{ fontFamily: value }">
|
||||||
|
{{ t("settings.useCustomFont", { font: readableFontFamily(value) }) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</SearchableSelect>
|
||||||
|
<p class="text-xs text-muted-foreground">{{ t("settings.uiFontFamilyDescription") }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const props = withDefaults(
|
|||||||
allowCustom?: boolean;
|
allowCustom?: boolean;
|
||||||
triggerVariant?: ButtonVariants["variant"];
|
triggerVariant?: ButtonVariants["variant"];
|
||||||
triggerClass?: HTMLAttributes["class"];
|
triggerClass?: HTMLAttributes["class"];
|
||||||
|
triggerIconClass?: HTMLAttributes["class"];
|
||||||
contentClass?: HTMLAttributes["class"];
|
contentClass?: HTMLAttributes["class"];
|
||||||
itemClass?: HTMLAttributes["class"];
|
itemClass?: HTMLAttributes["class"];
|
||||||
displayName?: (option: string) => string;
|
displayName?: (option: string) => string;
|
||||||
@@ -35,6 +36,7 @@ const props = withDefaults(
|
|||||||
clearable: false,
|
clearable: false,
|
||||||
loadingText: "Loading...",
|
loadingText: "Loading...",
|
||||||
triggerVariant: "ghost",
|
triggerVariant: "ghost",
|
||||||
|
triggerIconClass: "h-3 w-3",
|
||||||
displayName: (option: string) => option,
|
displayName: (option: string) => option,
|
||||||
normalizeCustom: (value: string) => value,
|
normalizeCustom: (value: string) => value,
|
||||||
},
|
},
|
||||||
@@ -158,8 +160,8 @@ function handleKeydown(event: KeyboardEvent) {
|
|||||||
<slot name="trigger-label" :value="modelValue" :label="selectedLabel" :loading="loading">
|
<slot name="trigger-label" :value="modelValue" :label="selectedLabel" :loading="loading">
|
||||||
<span class="truncate">{{ loading ? loadingText : selectedLabel }}</span>
|
<span class="truncate">{{ loading ? loadingText : selectedLabel }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
<X v-if="clearable && !disabled && modelValue" class="h-3 w-3 shrink-0 opacity-60 hover:opacity-100" @pointerdown.stop.prevent="emit('update:modelValue', '')" />
|
<X v-if="clearable && !disabled && modelValue" :class="cn('shrink-0 opacity-60 hover:opacity-100', triggerIconClass)" @pointerdown.stop.prevent="emit('update:modelValue', '')" />
|
||||||
<ChevronDown v-else class="h-3 w-3 shrink-0 opacity-60" />
|
<ChevronDown v-else :class="cn('shrink-0 opacity-60', triggerIconClass)" />
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent align="end" :class="cn('w-52 gap-1 p-1.5', contentClass)">
|
<PopoverContent align="end" :class="cn('w-52 gap-1 p-1.5', contentClass)">
|
||||||
|
|||||||
@@ -2591,6 +2591,10 @@ export default {
|
|||||||
securityTab: "Security",
|
securityTab: "Security",
|
||||||
aboutTab: "About",
|
aboutTab: "About",
|
||||||
fontFamily: "Font Family",
|
fontFamily: "Font Family",
|
||||||
|
uiFontFamily: "Interface Font",
|
||||||
|
uiFontAppDefault: "DBX Default",
|
||||||
|
uiFontSystemDefault: "System Default",
|
||||||
|
uiFontFamilyDescription: "Applies to app chrome such as the toolbar, tabs, sidebar, dialogs, and other non-editor UI.",
|
||||||
selectFont: "Select font...",
|
selectFont: "Select font...",
|
||||||
searchFont: "Search fonts...",
|
searchFont: "Search fonts...",
|
||||||
loadingFonts: "Loading fonts...",
|
loadingFonts: "Loading fonts...",
|
||||||
|
|||||||
@@ -2594,6 +2594,10 @@ export default withEnglishFallback({
|
|||||||
securityTab: "Seguridad",
|
securityTab: "Seguridad",
|
||||||
aboutTab: "Acerca de",
|
aboutTab: "Acerca de",
|
||||||
fontFamily: "Familia tipográfica",
|
fontFamily: "Familia tipográfica",
|
||||||
|
uiFontFamily: "Fuente de la interfaz",
|
||||||
|
uiFontAppDefault: "Predeterminada de DBX",
|
||||||
|
uiFontSystemDefault: "Predeterminada del sistema",
|
||||||
|
uiFontFamilyDescription: "Se aplica a la barra superior, pestañas, barra lateral, diálogos y demás UI fuera del editor.",
|
||||||
selectFont: "Seleccionar fuente...",
|
selectFont: "Seleccionar fuente...",
|
||||||
searchFont: "Buscar fuentes...",
|
searchFont: "Buscar fuentes...",
|
||||||
loadingFonts: "Cargando fuentes...",
|
loadingFonts: "Cargando fuentes...",
|
||||||
|
|||||||
@@ -2592,6 +2592,10 @@ export default withEnglishFallback({
|
|||||||
securityTab: "Sicurezza",
|
securityTab: "Sicurezza",
|
||||||
aboutTab: "Informazioni",
|
aboutTab: "Informazioni",
|
||||||
fontFamily: "Famiglia Carattere (Font)",
|
fontFamily: "Famiglia Carattere (Font)",
|
||||||
|
uiFontFamily: "Carattere interfaccia",
|
||||||
|
uiFontAppDefault: "Predefinito DBX",
|
||||||
|
uiFontSystemDefault: "Predefinito di sistema",
|
||||||
|
uiFontFamilyDescription: "Si applica a barra strumenti, schede, barra laterale, finestre di dialogo e altra UI fuori dall'editor.",
|
||||||
selectFont: "Seleziona font...",
|
selectFont: "Seleziona font...",
|
||||||
searchFont: "Cerca font...",
|
searchFont: "Cerca font...",
|
||||||
loadingFonts: "Caricamento font...",
|
loadingFonts: "Caricamento font...",
|
||||||
|
|||||||
@@ -2592,6 +2592,10 @@ export default withEnglishFallback({
|
|||||||
securityTab: "セキュリティ",
|
securityTab: "セキュリティ",
|
||||||
aboutTab: "バージョン情報",
|
aboutTab: "バージョン情報",
|
||||||
fontFamily: "フォントファミリー",
|
fontFamily: "フォントファミリー",
|
||||||
|
uiFontFamily: "インターフェイスフォント",
|
||||||
|
uiFontAppDefault: "DBX デフォルト",
|
||||||
|
uiFontSystemDefault: "システムデフォルト",
|
||||||
|
uiFontFamilyDescription: "ツールバー、タブ、サイドバー、ダイアログなど、エディター以外のUIに適用します。",
|
||||||
selectFont: "フォントを選択...",
|
selectFont: "フォントを選択...",
|
||||||
searchFont: "フォントを検索...",
|
searchFont: "フォントを検索...",
|
||||||
loadingFonts: "フォントを読み込み中...",
|
loadingFonts: "フォントを読み込み中...",
|
||||||
|
|||||||
@@ -2593,6 +2593,10 @@ export default withEnglishFallback({
|
|||||||
securityTab: "Segurança",
|
securityTab: "Segurança",
|
||||||
aboutTab: "Sobre",
|
aboutTab: "Sobre",
|
||||||
fontFamily: "Família da fonte",
|
fontFamily: "Família da fonte",
|
||||||
|
uiFontFamily: "Fonte da interface",
|
||||||
|
uiFontAppDefault: "Padrão do DBX",
|
||||||
|
uiFontSystemDefault: "Padrão do sistema",
|
||||||
|
uiFontFamilyDescription: "Aplica-se à barra superior, abas, barra lateral, diálogos e demais UI fora do editor.",
|
||||||
selectFont: "Selecionar fonte...",
|
selectFont: "Selecionar fonte...",
|
||||||
searchFont: "Pesquisar fontes...",
|
searchFont: "Pesquisar fontes...",
|
||||||
loadingFonts: "Carregando fontes...",
|
loadingFonts: "Carregando fontes...",
|
||||||
|
|||||||
@@ -2593,6 +2593,10 @@ export default withEnglishFallback({
|
|||||||
securityTab: "安全",
|
securityTab: "安全",
|
||||||
aboutTab: "关于我们",
|
aboutTab: "关于我们",
|
||||||
fontFamily: "字体",
|
fontFamily: "字体",
|
||||||
|
uiFontFamily: "界面字体",
|
||||||
|
uiFontAppDefault: "DBX 默认",
|
||||||
|
uiFontSystemDefault: "系统默认",
|
||||||
|
uiFontFamilyDescription: "用于顶部栏、标签页、侧边栏、弹窗等非编辑器界面。",
|
||||||
selectFont: "选择字体...",
|
selectFont: "选择字体...",
|
||||||
searchFont: "搜索字体...",
|
searchFont: "搜索字体...",
|
||||||
loadingFonts: "正在加载字体...",
|
loadingFonts: "正在加载字体...",
|
||||||
|
|||||||
@@ -2495,6 +2495,10 @@ export default withEnglishFallback({
|
|||||||
aboutTab: "關於我們",
|
aboutTab: "關於我們",
|
||||||
dataTab: "資料",
|
dataTab: "資料",
|
||||||
fontFamily: "字型",
|
fontFamily: "字型",
|
||||||
|
uiFontFamily: "介面字型",
|
||||||
|
uiFontAppDefault: "DBX 預設",
|
||||||
|
uiFontSystemDefault: "系統預設",
|
||||||
|
uiFontFamilyDescription: "套用於工具列、分頁、側邊欄、對話框等非編輯器介面。",
|
||||||
selectFont: "選擇字型……",
|
selectFont: "選擇字型……",
|
||||||
searchFont: "搜尋字型……",
|
searchFont: "搜尋字型……",
|
||||||
loadingFonts: "正在載入字型……",
|
loadingFonts: "正在載入字型……",
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export const APP_FONT_SANS_CSS_VAR = "--font-sans";
|
||||||
|
|
||||||
|
export const DEFAULT_UI_FONT_FAMILY = `"Geist Variable", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif`;
|
||||||
|
|
||||||
|
// Native-feeling UI option without DBX's bundled/brand font at the front of the stack.
|
||||||
|
export const SYSTEM_UI_FONT_FAMILY = `system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;
|
||||||
@@ -11,6 +11,7 @@ import type { SqlSnippet } from "@/types/database";
|
|||||||
import { DEFAULT_SQL_SNIPPETS } from "@/lib/sqlCompletion";
|
import { DEFAULT_SQL_SNIPPETS } from "@/lib/sqlCompletion";
|
||||||
import { setDebugLoggingEnabled } from "@/lib/debugLog";
|
import { setDebugLoggingEnabled } from "@/lib/debugLog";
|
||||||
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS, normalizeTableColumnTemplateFields } from "@/lib/tableColumnTemplates";
|
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS, normalizeTableColumnTemplateFields } from "@/lib/tableColumnTemplates";
|
||||||
|
import { DEFAULT_UI_FONT_FAMILY } from "@/lib/appFonts";
|
||||||
|
|
||||||
export type AiProvider = "claude" | "openai" | "gemini" | "deepseek" | "qwen" | "ollama" | "openai-compatible" | "codex-cli" | "custom";
|
export type AiProvider = "claude" | "openai" | "gemini" | "deepseek" | "qwen" | "ollama" | "openai-compatible" | "codex-cli" | "custom";
|
||||||
export type AiApiStyle = "completions" | "responses" | "anthropic-messages";
|
export type AiApiStyle = "completions" | "responses" | "anthropic-messages";
|
||||||
@@ -324,6 +325,7 @@ export const DEFAULT_CUSTOM_THEMES: CustomTheme[] = [{ id: "default", name: "Cus
|
|||||||
export interface EditorSettings {
|
export interface EditorSettings {
|
||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
|
uiFontFamily: string;
|
||||||
uiScale: number;
|
uiScale: number;
|
||||||
theme: EditorTheme;
|
theme: EditorTheme;
|
||||||
customThemeColors: CustomThemeColors;
|
customThemeColors: CustomThemeColors;
|
||||||
@@ -435,6 +437,7 @@ export const FONT_FAMILIES: { value: string; label: string }[] = [
|
|||||||
export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
||||||
fontFamily: "'JetBrains Mono', 'Fira Code', monospace",
|
fontFamily: "'JetBrains Mono', 'Fira Code', monospace",
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
|
uiFontFamily: DEFAULT_UI_FONT_FAMILY,
|
||||||
uiScale: 1,
|
uiScale: 1,
|
||||||
theme: "app",
|
theme: "app",
|
||||||
customThemeColors: { ...DEFAULT_CUSTOM_THEME_COLORS },
|
customThemeColors: { ...DEFAULT_CUSTOM_THEME_COLORS },
|
||||||
@@ -501,6 +504,12 @@ function normalizeUiScale(value: unknown): number {
|
|||||||
return Math.min(MAX_UI_SCALE, Math.max(MIN_UI_SCALE, Math.round(value * 100) / 100));
|
return Math.min(MAX_UI_SCALE, Math.max(MIN_UI_SCALE, Math.round(value * 100) / 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeFontFamily(value: unknown, fallback: string): string {
|
||||||
|
if (typeof value !== "string") return fallback;
|
||||||
|
const trimmed = value.trim();
|
||||||
|
return trimmed || fallback;
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeDrawerWidth(value: unknown, min: number, fallback: number): number {
|
function normalizeDrawerWidth(value: unknown, min: number, fallback: number): number {
|
||||||
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
||||||
return Math.min(900, Math.max(min, Math.round(value)));
|
return Math.min(900, Math.max(min, Math.round(value)));
|
||||||
@@ -615,8 +624,9 @@ function normalizeToolbarItems(items: Partial<ToolbarItems> | undefined): Toolba
|
|||||||
export function normalizeEditorSettings(settings: Partial<EditorSettings>, existing?: EditorSettings): EditorSettings {
|
export function normalizeEditorSettings(settings: Partial<EditorSettings>, existing?: EditorSettings): EditorSettings {
|
||||||
const sqlSemanticDiagnosticsMode = normalizeSqlSemanticDiagnosticsMode(settings.sqlSemanticDiagnosticsMode, settings.sqlSemanticDiagnosticsEnabled);
|
const sqlSemanticDiagnosticsMode = normalizeSqlSemanticDiagnosticsMode(settings.sqlSemanticDiagnosticsMode, settings.sqlSemanticDiagnosticsEnabled);
|
||||||
return {
|
return {
|
||||||
fontFamily: settings.fontFamily ?? DEFAULT_EDITOR_SETTINGS.fontFamily,
|
fontFamily: normalizeFontFamily(settings.fontFamily, DEFAULT_EDITOR_SETTINGS.fontFamily),
|
||||||
fontSize: settings.fontSize ?? DEFAULT_EDITOR_SETTINGS.fontSize,
|
fontSize: settings.fontSize ?? DEFAULT_EDITOR_SETTINGS.fontSize,
|
||||||
|
uiFontFamily: normalizeFontFamily(settings.uiFontFamily, DEFAULT_EDITOR_SETTINGS.uiFontFamily),
|
||||||
uiScale: normalizeUiScale(settings.uiScale),
|
uiScale: normalizeUiScale(settings.uiScale),
|
||||||
theme: settings.theme && EDITOR_THEME_VALUES.has(settings.theme) ? settings.theme : DEFAULT_EDITOR_SETTINGS.theme,
|
theme: settings.theme && EDITOR_THEME_VALUES.has(settings.theme) ? settings.theme : DEFAULT_EDITOR_SETTINGS.theme,
|
||||||
customThemeColors: {
|
customThemeColors: {
|
||||||
@@ -838,8 +848,9 @@ export const useSettingsStore = defineStore("settings", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateEditorSettings(partial: Partial<EditorSettings>) {
|
function updateEditorSettings(partial: Partial<EditorSettings>) {
|
||||||
if (partial.fontFamily !== undefined) editorSettings.value.fontFamily = partial.fontFamily;
|
if (partial.fontFamily !== undefined) editorSettings.value.fontFamily = normalizeFontFamily(partial.fontFamily, DEFAULT_EDITOR_SETTINGS.fontFamily);
|
||||||
if (partial.fontSize !== undefined) editorSettings.value.fontSize = partial.fontSize;
|
if (partial.fontSize !== undefined) editorSettings.value.fontSize = partial.fontSize;
|
||||||
|
if (partial.uiFontFamily !== undefined) editorSettings.value.uiFontFamily = normalizeFontFamily(partial.uiFontFamily, DEFAULT_EDITOR_SETTINGS.uiFontFamily);
|
||||||
if (partial.uiScale !== undefined) editorSettings.value.uiScale = normalizeUiScale(partial.uiScale);
|
if (partial.uiScale !== undefined) editorSettings.value.uiScale = normalizeUiScale(partial.uiScale);
|
||||||
if (partial.theme !== undefined) editorSettings.value.theme = partial.theme;
|
if (partial.theme !== undefined) editorSettings.value.theme = partial.theme;
|
||||||
if (partial.customThemeColors !== undefined) {
|
if (partial.customThemeColors !== undefined) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
|
|||||||
import { createPinia, setActivePinia } from "pinia";
|
import { createPinia, setActivePinia } from "pinia";
|
||||||
import { DEFAULT_SQL_FORMATTER_SETTINGS } from "../../apps/desktop/src/lib/sqlFormatterConfig.ts";
|
import { DEFAULT_SQL_FORMATTER_SETTINGS } from "../../apps/desktop/src/lib/sqlFormatterConfig.ts";
|
||||||
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS } from "../../apps/desktop/src/lib/tableColumnTemplates.ts";
|
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS } from "../../apps/desktop/src/lib/tableColumnTemplates.ts";
|
||||||
|
import { DEFAULT_UI_FONT_FAMILY, SYSTEM_UI_FONT_FAMILY } from "../../apps/desktop/src/lib/appFonts.ts";
|
||||||
import { AI_PROVIDER_PRESETS, DEFAULT_EDITOR_SETTINGS, normalizeAiConfig, normalizeEditorSettings, useSettingsStore } from "../../apps/desktop/src/stores/settingsStore.ts";
|
import { AI_PROVIDER_PRESETS, DEFAULT_EDITOR_SETTINGS, normalizeAiConfig, normalizeEditorSettings, useSettingsStore } from "../../apps/desktop/src/stores/settingsStore.ts";
|
||||||
|
|
||||||
const OLD_FONT_SIZE_KEY = "dbx-query-editor-font-size";
|
const OLD_FONT_SIZE_KEY = "dbx-query-editor-font-size";
|
||||||
@@ -101,6 +102,18 @@ test("normalizes editor theme settings", () => {
|
|||||||
assert.equal(normalizeEditorSettings({ theme: "invalid" as any }).theme, DEFAULT_EDITOR_SETTINGS.theme);
|
assert.equal(normalizeEditorSettings({ theme: "invalid" as any }).theme, DEFAULT_EDITOR_SETTINGS.theme);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("defaults UI font family to the app sans stack", () => {
|
||||||
|
assert.equal(DEFAULT_EDITOR_SETTINGS.uiFontFamily, DEFAULT_UI_FONT_FAMILY);
|
||||||
|
assert.equal(normalizeEditorSettings({}).uiFontFamily, DEFAULT_UI_FONT_FAMILY);
|
||||||
|
assert.equal(normalizeEditorSettings({ uiFontFamily: "" as any }).uiFontFamily, DEFAULT_UI_FONT_FAMILY);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("keeps saved UI font family", () => {
|
||||||
|
const uiFontFamily = `"Aptos", system-ui, sans-serif`;
|
||||||
|
assert.equal(normalizeEditorSettings({ uiFontFamily } as any).uiFontFamily, uiFontFamily);
|
||||||
|
assert.equal(normalizeEditorSettings({ uiFontFamily: SYSTEM_UI_FONT_FAMILY } as any).uiFontFamily, SYSTEM_UI_FONT_FAMILY);
|
||||||
|
});
|
||||||
|
|
||||||
test("defaults dangerous SQL confirmation to enabled", () => {
|
test("defaults dangerous SQL confirmation to enabled", () => {
|
||||||
assert.equal(DEFAULT_EDITOR_SETTINGS.confirmDangerousSqlExecution, true);
|
assert.equal(DEFAULT_EDITOR_SETTINGS.confirmDangerousSqlExecution, true);
|
||||||
assert.equal(normalizeEditorSettings({}).confirmDangerousSqlExecution, true);
|
assert.equal(normalizeEditorSettings({}).confirmDangerousSqlExecution, true);
|
||||||
|
|||||||
Reference in new issue
Block a user