fix(editor): keep custom theme entry point when customThemes is empty
This commit is contained in:
1 parent
c737fde538
commit
7aa69a0e5e
5 files changed
+199
-50
No files matched your search
@@ -106,6 +106,7 @@ import {
|
||||
type CsvNullMode,
|
||||
type CustomThemeColors,
|
||||
type CustomTheme,
|
||||
DEFAULT_CUSTOM_THEMES,
|
||||
type McpConnectionPolicy,
|
||||
type McpGlobalPolicy,
|
||||
normalizeMcpGlobalPolicy,
|
||||
@@ -649,7 +650,7 @@ const backgroundImageFileMissing = ref(false);
|
||||
// Set when the draft clears a configured image; the stored copy is only
|
||||
// deleted once the change is actually applied.
|
||||
let pendingBackgroundImageCleanup: string | null = null;
|
||||
const editCustomThemes = ref<CustomTheme[]>([...settingsStore.editorSettings.customThemes]);
|
||||
const editCustomThemes = ref<CustomTheme[]>([...(settingsStore.editorSettings.customThemes.length > 0 ? settingsStore.editorSettings.customThemes : DEFAULT_CUSTOM_THEMES)]);
|
||||
const editActiveCustomThemeId = ref(settingsStore.editorSettings.activeCustomThemeId);
|
||||
const editDataGridTypeColorSchemes = ref<DataGridTypeColorScheme[]>(cloneDataGridTypeColorSchemes(settingsStore.editorSettings.dataGridTypeColorSchemes));
|
||||
const editActiveDataGridTypeColorSchemeId = ref(settingsStore.editorSettings.activeDataGridTypeColorSchemeId);
|
||||
@@ -1715,8 +1716,8 @@ function syncEditorSettingsDraftFromStore() {
|
||||
editTheme.value = settingsStore.editorSettings.theme;
|
||||
editBackgroundImage.value = cloneBackgroundImageDraft(settingsStore.editorSettings.backgroundImage);
|
||||
pendingBackgroundImageCleanup = null;
|
||||
editCustomThemes.value = [...settingsStore.editorSettings.customThemes];
|
||||
editActiveCustomThemeId.value = settingsStore.editorSettings.activeCustomThemeId;
|
||||
editCustomThemes.value = [...(settingsStore.editorSettings.customThemes.length > 0 ? settingsStore.editorSettings.customThemes : DEFAULT_CUSTOM_THEMES)];
|
||||
editActiveCustomThemeId.value = settingsStore.editorSettings.activeCustomThemeId || editCustomThemes.value[0]?.id || "default";
|
||||
editExecuteMode.value = settingsStore.editorSettings.executeMode;
|
||||
editDefaultTransactionMode.value = settingsStore.editorSettings.defaultTransactionMode;
|
||||
editKeepExplicitTransactionInAutoCommit.value = settingsStore.editorSettings.keepExplicitTransactionInAutoCommit;
|
||||
@@ -2891,7 +2892,11 @@ function resetAiTypography() {
|
||||
|
||||
const themeSelectValue = computed(() => {
|
||||
if (editTheme.value === "custom") {
|
||||
return `custom:${editActiveCustomThemeId.value}`;
|
||||
if (editCustomThemes.value.length > 0) {
|
||||
const activeMatch = editCustomThemes.value.find((t) => t.id === editActiveCustomThemeId.value);
|
||||
return activeMatch ? `custom:${activeMatch.id}` : `custom:${editCustomThemes.value[0].id}`;
|
||||
}
|
||||
return "custom";
|
||||
}
|
||||
return editTheme.value;
|
||||
});
|
||||
@@ -2903,12 +2908,21 @@ const themeSelectOptions = computed(() => [
|
||||
dark: theme.dark,
|
||||
isCustom: false,
|
||||
})),
|
||||
...editCustomThemes.value.map((theme) => ({
|
||||
value: `custom:${theme.id}`,
|
||||
label: theme.name,
|
||||
dark: true,
|
||||
isCustom: true,
|
||||
})),
|
||||
...(editCustomThemes.value.length === 0
|
||||
? [
|
||||
{
|
||||
value: "custom",
|
||||
label: t("settings.customTheme") || "Custom Theme",
|
||||
dark: true,
|
||||
isCustom: true,
|
||||
},
|
||||
]
|
||||
: editCustomThemes.value.map((theme) => ({
|
||||
value: `custom:${theme.id}`,
|
||||
label: theme.name,
|
||||
dark: true,
|
||||
isCustom: true,
|
||||
}))),
|
||||
]);
|
||||
|
||||
function onThemeChange(v: any) {
|
||||
@@ -2916,14 +2930,20 @@ function onThemeChange(v: any) {
|
||||
if (v.startsWith("custom:")) {
|
||||
editTheme.value = "custom";
|
||||
editActiveCustomThemeId.value = v.slice(7);
|
||||
} else if (v === "custom") {
|
||||
editTheme.value = "custom";
|
||||
if (editCustomThemes.value.length === 0) {
|
||||
editCustomThemes.value = JSON.parse(JSON.stringify(DEFAULT_CUSTOM_THEMES));
|
||||
}
|
||||
editActiveCustomThemeId.value = editCustomThemes.value[0]?.id ?? "default";
|
||||
} else {
|
||||
editTheme.value = v as typeof DEFAULT_EDITOR_SETTINGS.theme;
|
||||
}
|
||||
}
|
||||
|
||||
function handleThemeSave(updatedThemes: CustomTheme[], activeId: string) {
|
||||
editCustomThemes.value = updatedThemes;
|
||||
editActiveCustomThemeId.value = activeId;
|
||||
editCustomThemes.value = updatedThemes.length > 0 ? updatedThemes : JSON.parse(JSON.stringify(DEFAULT_CUSTOM_THEMES));
|
||||
editActiveCustomThemeId.value = activeId || editCustomThemes.value[0]?.id || "default";
|
||||
editTheme.value = "custom";
|
||||
showThemeCustomizer.value = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user