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 CsvNullMode,
|
||||||
type CustomThemeColors,
|
type CustomThemeColors,
|
||||||
type CustomTheme,
|
type CustomTheme,
|
||||||
|
DEFAULT_CUSTOM_THEMES,
|
||||||
type McpConnectionPolicy,
|
type McpConnectionPolicy,
|
||||||
type McpGlobalPolicy,
|
type McpGlobalPolicy,
|
||||||
normalizeMcpGlobalPolicy,
|
normalizeMcpGlobalPolicy,
|
||||||
@@ -649,7 +650,7 @@ const backgroundImageFileMissing = ref(false);
|
|||||||
// Set when the draft clears a configured image; the stored copy is only
|
// Set when the draft clears a configured image; the stored copy is only
|
||||||
// deleted once the change is actually applied.
|
// deleted once the change is actually applied.
|
||||||
let pendingBackgroundImageCleanup: string | null = null;
|
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 editActiveCustomThemeId = ref(settingsStore.editorSettings.activeCustomThemeId);
|
||||||
const editDataGridTypeColorSchemes = ref<DataGridTypeColorScheme[]>(cloneDataGridTypeColorSchemes(settingsStore.editorSettings.dataGridTypeColorSchemes));
|
const editDataGridTypeColorSchemes = ref<DataGridTypeColorScheme[]>(cloneDataGridTypeColorSchemes(settingsStore.editorSettings.dataGridTypeColorSchemes));
|
||||||
const editActiveDataGridTypeColorSchemeId = ref(settingsStore.editorSettings.activeDataGridTypeColorSchemeId);
|
const editActiveDataGridTypeColorSchemeId = ref(settingsStore.editorSettings.activeDataGridTypeColorSchemeId);
|
||||||
@@ -1715,8 +1716,8 @@ function syncEditorSettingsDraftFromStore() {
|
|||||||
editTheme.value = settingsStore.editorSettings.theme;
|
editTheme.value = settingsStore.editorSettings.theme;
|
||||||
editBackgroundImage.value = cloneBackgroundImageDraft(settingsStore.editorSettings.backgroundImage);
|
editBackgroundImage.value = cloneBackgroundImageDraft(settingsStore.editorSettings.backgroundImage);
|
||||||
pendingBackgroundImageCleanup = null;
|
pendingBackgroundImageCleanup = null;
|
||||||
editCustomThemes.value = [...settingsStore.editorSettings.customThemes];
|
editCustomThemes.value = [...(settingsStore.editorSettings.customThemes.length > 0 ? settingsStore.editorSettings.customThemes : DEFAULT_CUSTOM_THEMES)];
|
||||||
editActiveCustomThemeId.value = settingsStore.editorSettings.activeCustomThemeId;
|
editActiveCustomThemeId.value = settingsStore.editorSettings.activeCustomThemeId || editCustomThemes.value[0]?.id || "default";
|
||||||
editExecuteMode.value = settingsStore.editorSettings.executeMode;
|
editExecuteMode.value = settingsStore.editorSettings.executeMode;
|
||||||
editDefaultTransactionMode.value = settingsStore.editorSettings.defaultTransactionMode;
|
editDefaultTransactionMode.value = settingsStore.editorSettings.defaultTransactionMode;
|
||||||
editKeepExplicitTransactionInAutoCommit.value = settingsStore.editorSettings.keepExplicitTransactionInAutoCommit;
|
editKeepExplicitTransactionInAutoCommit.value = settingsStore.editorSettings.keepExplicitTransactionInAutoCommit;
|
||||||
@@ -2891,7 +2892,11 @@ function resetAiTypography() {
|
|||||||
|
|
||||||
const themeSelectValue = computed(() => {
|
const themeSelectValue = computed(() => {
|
||||||
if (editTheme.value === "custom") {
|
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;
|
return editTheme.value;
|
||||||
});
|
});
|
||||||
@@ -2903,12 +2908,21 @@ const themeSelectOptions = computed(() => [
|
|||||||
dark: theme.dark,
|
dark: theme.dark,
|
||||||
isCustom: false,
|
isCustom: false,
|
||||||
})),
|
})),
|
||||||
...editCustomThemes.value.map((theme) => ({
|
...(editCustomThemes.value.length === 0
|
||||||
value: `custom:${theme.id}`,
|
? [
|
||||||
label: theme.name,
|
{
|
||||||
dark: true,
|
value: "custom",
|
||||||
isCustom: true,
|
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) {
|
function onThemeChange(v: any) {
|
||||||
@@ -2916,14 +2930,20 @@ function onThemeChange(v: any) {
|
|||||||
if (v.startsWith("custom:")) {
|
if (v.startsWith("custom:")) {
|
||||||
editTheme.value = "custom";
|
editTheme.value = "custom";
|
||||||
editActiveCustomThemeId.value = v.slice(7);
|
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 {
|
} else {
|
||||||
editTheme.value = v as typeof DEFAULT_EDITOR_SETTINGS.theme;
|
editTheme.value = v as typeof DEFAULT_EDITOR_SETTINGS.theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleThemeSave(updatedThemes: CustomTheme[], activeId: string) {
|
function handleThemeSave(updatedThemes: CustomTheme[], activeId: string) {
|
||||||
editCustomThemes.value = updatedThemes;
|
editCustomThemes.value = updatedThemes.length > 0 ? updatedThemes : JSON.parse(JSON.stringify(DEFAULT_CUSTOM_THEMES));
|
||||||
editActiveCustomThemeId.value = activeId;
|
editActiveCustomThemeId.value = activeId || editCustomThemes.value[0]?.id || "default";
|
||||||
editTheme.value = "custom";
|
editTheme.value = "custom";
|
||||||
showThemeCustomizer.value = false;
|
showThemeCustomizer.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import type { CustomTheme, CustomThemeColors } from "@/stores/settingsStore";
|
import type { CustomTheme, CustomThemeColors } from "@/stores/settingsStore";
|
||||||
import { DEFAULT_CUSTOM_THEME_COLORS, DEFAULT_CUSTOM_THEME_DDL_COLORS } from "@/stores/settingsStore";
|
import { DEFAULT_CUSTOM_THEMES, DEFAULT_CUSTOM_THEME_COLORS, DEFAULT_CUSTOM_THEME_DDL_COLORS } from "@/stores/settingsStore";
|
||||||
import { Plus, Trash2, Copy, Pencil, ChevronDown, Palette } from "@lucide/vue";
|
import { Plus, Trash2, Copy, Pencil, ChevronDown, Palette } from "@lucide/vue";
|
||||||
import { useToast } from "@/composables/useToast";
|
import { useToast } from "@/composables/useToast";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
@@ -32,12 +32,22 @@ const jsonText = ref("");
|
|||||||
const renamingId = ref<string | null>(null);
|
const renamingId = ref<string | null>(null);
|
||||||
const renamingName = ref("");
|
const renamingName = ref("");
|
||||||
|
|
||||||
|
function cloneCustomThemes(themes: CustomTheme[]): CustomTheme[] {
|
||||||
|
return themes.map((theme) => ({
|
||||||
|
id: theme.id,
|
||||||
|
name: theme.name,
|
||||||
|
colors: { ...theme.colors },
|
||||||
|
ddlColors: { ...theme.ddlColors },
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.open,
|
() => props.open,
|
||||||
(isOpen) => {
|
(isOpen) => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
localThemes.value = JSON.parse(JSON.stringify(props.themes));
|
localThemes.value = props.themes && props.themes.length > 0 ? cloneCustomThemes(props.themes) : cloneCustomThemes(DEFAULT_CUSTOM_THEMES);
|
||||||
activeEditId.value = props.activeThemeId;
|
const hasActive = localThemes.value.some((t) => t.id === props.activeThemeId);
|
||||||
|
activeEditId.value = hasActive ? props.activeThemeId : (localThemes.value[0]?.id ?? "default");
|
||||||
syncJson();
|
syncJson();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -352,11 +362,9 @@ function handleJsonChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSave() {
|
function handleSave() {
|
||||||
emit(
|
const themesToSave = localThemes.value.length > 0 ? localThemes.value : cloneCustomThemes(DEFAULT_CUSTOM_THEMES);
|
||||||
"save",
|
const activeId = themesToSave.some((t) => t.id === activeEditId.value) ? activeEditId.value : (themesToSave[0]?.id ?? "default");
|
||||||
localThemes.value.map((t) => ({ ...t })),
|
emit("save", cloneCustomThemes(themesToSave), activeId);
|
||||||
activeEditId.value,
|
|
||||||
);
|
|
||||||
emit("update:open", false);
|
emit("update:open", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+76
@@ -0,0 +1,76 @@
|
|||||||
|
// @vitest-environment happy-dom
|
||||||
|
|
||||||
|
import { createApp, defineComponent, h, nextTick, ref } from "vue";
|
||||||
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import { createPinia, setActivePinia } from "pinia";
|
||||||
|
import ThemeCustomizerDialog from "../ThemeCustomizerDialog.vue";
|
||||||
|
import dialogSource from "../EditorSettingsDialog.vue?raw";
|
||||||
|
|
||||||
|
vi.mock("vue-i18n", async () => {
|
||||||
|
const { ref } = await import("vue");
|
||||||
|
const locale = ref("en");
|
||||||
|
const t = (key: string) => key;
|
||||||
|
return {
|
||||||
|
createI18n: () => ({ global: { t, locale }, install: () => undefined }),
|
||||||
|
useI18n: () => ({ t, locale }),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("ThemeCustomizerDialog with empty themes (#10994)", () => {
|
||||||
|
let app: ReturnType<typeof createApp> | null = null;
|
||||||
|
let container: HTMLDivElement | null = null;
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (app && container) {
|
||||||
|
app.unmount();
|
||||||
|
container.remove();
|
||||||
|
}
|
||||||
|
app = null;
|
||||||
|
container = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("seeds DEFAULT_CUSTOM_THEMES when opened with empty themes", async () => {
|
||||||
|
setActivePinia(createPinia());
|
||||||
|
container = document.createElement("div");
|
||||||
|
document.body.appendChild(container);
|
||||||
|
|
||||||
|
const onSave = vi.fn();
|
||||||
|
const isOpen = ref(false);
|
||||||
|
|
||||||
|
const Host = defineComponent({
|
||||||
|
setup() {
|
||||||
|
return () =>
|
||||||
|
h(ThemeCustomizerDialog, {
|
||||||
|
open: isOpen.value,
|
||||||
|
themes: [],
|
||||||
|
activeThemeId: "",
|
||||||
|
"onUpdate:open": (val: boolean) => {
|
||||||
|
isOpen.value = val;
|
||||||
|
},
|
||||||
|
onSave,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
app = createApp(Host);
|
||||||
|
app.mount(container);
|
||||||
|
|
||||||
|
// Open the dialog
|
||||||
|
isOpen.value = true;
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
// Verify dialog content is rendered into document.body via Teleport and does not crash
|
||||||
|
expect(document.body.innerHTML).toContain("Custom");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("EditorSettingsDialog theme select fallback (#10994)", () => {
|
||||||
|
it("includes a custom theme option even if editCustomThemes is empty", () => {
|
||||||
|
// Ensures themeSelectOptions checks editCustomThemes.value.length === 0
|
||||||
|
// and supplies a fallback custom theme entry so the entry point never disappears
|
||||||
|
expect(dialogSource).toContain("editCustomThemes.value.length === 0");
|
||||||
|
expect(dialogSource).toContain('value: "custom"');
|
||||||
|
expect(dialogSource).toContain('} else if (v === "custom")');
|
||||||
|
expect(dialogSource).toContain("editCustomThemes.value = JSON.parse(JSON.stringify(DEFAULT_CUSTOM_THEMES))");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -4,6 +4,7 @@ import { isProxy } from "vue";
|
|||||||
import {
|
import {
|
||||||
AI_PROVIDER_PARTNER_PRESETS,
|
AI_PROVIDER_PARTNER_PRESETS,
|
||||||
AI_PROVIDER_PRESETS,
|
AI_PROVIDER_PRESETS,
|
||||||
|
DEFAULT_CUSTOM_THEMES,
|
||||||
DEFAULT_EDITOR_SETTINGS,
|
DEFAULT_EDITOR_SETTINGS,
|
||||||
EXECUTE_MODE_CURRENT_DEFAULT_VERSION,
|
EXECUTE_MODE_CURRENT_DEFAULT_VERSION,
|
||||||
SIDEBAR_BROWSE_OBJECTS_MIGRATION_VERSION,
|
SIDEBAR_BROWSE_OBJECTS_MIGRATION_VERSION,
|
||||||
@@ -130,6 +131,37 @@ describe("normalizeEditorSettings", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("normalizes customThemes when empty or absent by seeding DEFAULT_CUSTOM_THEMES", () => {
|
||||||
|
// When customThemes is an empty array
|
||||||
|
const normalizedEmpty = normalizeEditorSettings({ customThemes: [] });
|
||||||
|
expect(normalizedEmpty.customThemes).toEqual(DEFAULT_CUSTOM_THEMES);
|
||||||
|
expect(normalizedEmpty.activeCustomThemeId).toBe("default");
|
||||||
|
|
||||||
|
// When customThemes is absent
|
||||||
|
const normalizedAbsent = normalizeEditorSettings({});
|
||||||
|
expect(normalizedAbsent.customThemes).toEqual(DEFAULT_CUSTOM_THEMES);
|
||||||
|
expect(normalizedAbsent.activeCustomThemeId).toBe("default");
|
||||||
|
|
||||||
|
// When customThemes has invalid activeCustomThemeId, fall back to first theme id
|
||||||
|
const customList = [{ id: "my-theme", name: "My Theme", colors: DEFAULT_CUSTOM_THEMES[0].colors, ddlColors: DEFAULT_CUSTOM_THEMES[0].ddlColors }];
|
||||||
|
const normalizedInvalidActive = normalizeEditorSettings({
|
||||||
|
customThemes: customList,
|
||||||
|
activeCustomThemeId: "nonexistent",
|
||||||
|
});
|
||||||
|
expect(normalizedInvalidActive.customThemes).toHaveLength(1);
|
||||||
|
expect(normalizedInvalidActive.activeCustomThemeId).toBe("my-theme");
|
||||||
|
|
||||||
|
// When legacy customThemeColors is provided and customThemes is empty
|
||||||
|
const legacyColors = { ...DEFAULT_CUSTOM_THEMES[0].colors, keyword: "#ff0000" };
|
||||||
|
const normalizedLegacy = normalizeEditorSettings({
|
||||||
|
customThemes: [],
|
||||||
|
customThemeColors: legacyColors,
|
||||||
|
});
|
||||||
|
expect(normalizedLegacy.customThemes).toHaveLength(1);
|
||||||
|
expect(normalizedLegacy.customThemes[0].id).toBe("migrated");
|
||||||
|
expect(normalizedLegacy.customThemes[0].colors.keyword).toBe("#ff0000");
|
||||||
|
});
|
||||||
|
|
||||||
it("defaults and bounds the persisted text filter panel height", () => {
|
it("defaults and bounds the persisted text filter panel height", () => {
|
||||||
expect(normalizeEditorSettings({}).dataGridTextFilterPanelHeight).toBe(168);
|
expect(normalizeEditorSettings({}).dataGridTextFilterPanelHeight).toBe(168);
|
||||||
expect(normalizeEditorSettings({ dataGridTextFilterPanelHeight: 236.4 }).dataGridTextFilterPanelHeight).toBe(236);
|
expect(normalizeEditorSettings({ dataGridTextFilterPanelHeight: 236.4 }).dataGridTextFilterPanelHeight).toBe(236);
|
||||||
@@ -1186,6 +1218,15 @@ describe("settingsStore persisted settings initialization", () => {
|
|||||||
expect(saveEditorSettings).toHaveBeenCalledWith(expect.objectContaining({ fontSize: 17, theme: "xcode-dark", appLayout: "separated" }));
|
expect(saveEditorSettings).toHaveBeenCalledWith(expect.objectContaining({ fontSize: 17, theme: "xcode-dark", appLayout: "separated" }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("seeds DEFAULT_CUSTOM_THEMES when updateEditorSettings receives empty customThemes", async () => {
|
||||||
|
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||||
|
const store = useSettingsStore();
|
||||||
|
|
||||||
|
store.updateEditorSettings({ customThemes: [] });
|
||||||
|
expect(store.editorSettings.customThemes).toEqual(DEFAULT_CUSTOM_THEMES);
|
||||||
|
expect(store.editorSettings.activeCustomThemeId).toBe("default");
|
||||||
|
});
|
||||||
|
|
||||||
it("migrates the legacy filter-editor preference in incremental settings updates", async () => {
|
it("migrates the legacy filter-editor preference in incremental settings updates", async () => {
|
||||||
const loadEditorSettings = vi.fn().mockResolvedValue({});
|
const loadEditorSettings = vi.fn().mockResolvedValue({});
|
||||||
const saveEditorSettings = vi.fn().mockResolvedValue(undefined);
|
const saveEditorSettings = vi.fn().mockResolvedValue(undefined);
|
||||||
|
|||||||
@@ -1704,6 +1704,36 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
|||||||
const autoUpdateJdbc = typeof settings.autoUpdateJdbc === "boolean" ? settings.autoUpdateJdbc : legacyUpdateOptOut ? false : DEFAULT_EDITOR_SETTINGS.autoUpdateJdbc;
|
const autoUpdateJdbc = typeof settings.autoUpdateJdbc === "boolean" ? settings.autoUpdateJdbc : legacyUpdateOptOut ? false : DEFAULT_EDITOR_SETTINGS.autoUpdateJdbc;
|
||||||
const autoUpdateMcp = typeof settings.autoUpdateMcp === "boolean" ? settings.autoUpdateMcp : legacyUpdateOptOut ? false : DEFAULT_EDITOR_SETTINGS.autoUpdateMcp;
|
const autoUpdateMcp = typeof settings.autoUpdateMcp === "boolean" ? settings.autoUpdateMcp : legacyUpdateOptOut ? false : DEFAULT_EDITOR_SETTINGS.autoUpdateMcp;
|
||||||
const autoUpdatePlugins = typeof settings.autoUpdatePlugins === "boolean" ? settings.autoUpdatePlugins : legacyUpdateOptOut ? false : DEFAULT_EDITOR_SETTINGS.autoUpdatePlugins;
|
const autoUpdatePlugins = typeof settings.autoUpdatePlugins === "boolean" ? settings.autoUpdatePlugins : legacyUpdateOptOut ? false : DEFAULT_EDITOR_SETTINGS.autoUpdatePlugins;
|
||||||
|
const customThemes = (() => {
|
||||||
|
if (Array.isArray(settings.customThemes) && settings.customThemes.length > 0) {
|
||||||
|
return settings.customThemes.map((theme) => {
|
||||||
|
const renamed = theme.name === "默认" ? { ...theme, name: "Custom" } : { ...theme };
|
||||||
|
return {
|
||||||
|
...renamed,
|
||||||
|
colors: { ...DEFAULT_CUSTOM_THEME_COLORS, ...renamed.colors },
|
||||||
|
ddlColors: {
|
||||||
|
...DEFAULT_CUSTOM_THEME_DDL_COLORS,
|
||||||
|
...(renamed as any).ddlColors,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (settings.customThemeColors && Object.keys(settings.customThemeColors).length > 0) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: "migrated",
|
||||||
|
name: "Migrated",
|
||||||
|
colors: {
|
||||||
|
...DEFAULT_CUSTOM_THEME_COLORS,
|
||||||
|
...settings.customThemeColors,
|
||||||
|
},
|
||||||
|
ddlColors: { ...DEFAULT_CUSTOM_THEME_DDL_COLORS },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [...DEFAULT_CUSTOM_THEMES];
|
||||||
|
})();
|
||||||
|
const activeCustomThemeId = settings.activeCustomThemeId && customThemes.some((t) => t.id === settings.activeCustomThemeId) ? settings.activeCustomThemeId : (customThemes[0]?.id ?? "default");
|
||||||
return {
|
return {
|
||||||
fontFamily: normalizeFontFamily(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,
|
||||||
@@ -1716,35 +1746,8 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
|||||||
...DEFAULT_CUSTOM_THEME_COLORS,
|
...DEFAULT_CUSTOM_THEME_COLORS,
|
||||||
...settings.customThemeColors,
|
...settings.customThemeColors,
|
||||||
},
|
},
|
||||||
customThemes: (() => {
|
customThemes,
|
||||||
if (Array.isArray(settings.customThemes) && settings.customThemes.length > 0) {
|
activeCustomThemeId,
|
||||||
return settings.customThemes.map((theme) => {
|
|
||||||
const renamed = theme.name === "默认" ? { ...theme, name: "Custom" } : { ...theme };
|
|
||||||
return {
|
|
||||||
...renamed,
|
|
||||||
colors: { ...DEFAULT_CUSTOM_THEME_COLORS, ...renamed.colors },
|
|
||||||
ddlColors: {
|
|
||||||
...DEFAULT_CUSTOM_THEME_DDL_COLORS,
|
|
||||||
...(renamed as any).ddlColors,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return settings.customThemeColors
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
id: "migrated",
|
|
||||||
name: "Migrated",
|
|
||||||
colors: {
|
|
||||||
...DEFAULT_CUSTOM_THEME_COLORS,
|
|
||||||
...settings.customThemeColors,
|
|
||||||
},
|
|
||||||
ddlColors: { ...DEFAULT_CUSTOM_THEME_DDL_COLORS },
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: [];
|
|
||||||
})(),
|
|
||||||
activeCustomThemeId: settings.activeCustomThemeId ?? "default",
|
|
||||||
executeMode: hasCurrentExecuteModeDefault && (settings.executeMode === "all" || settings.executeMode === "current") ? settings.executeMode : DEFAULT_EDITOR_SETTINGS.executeMode,
|
executeMode: hasCurrentExecuteModeDefault && (settings.executeMode === "all" || settings.executeMode === "current") ? settings.executeMode : DEFAULT_EDITOR_SETTINGS.executeMode,
|
||||||
executeModeDefaultVersion,
|
executeModeDefaultVersion,
|
||||||
executeAllOnBlankLine: settings.executeAllOnBlankLine === true,
|
executeAllOnBlankLine: settings.executeAllOnBlankLine === true,
|
||||||
@@ -2578,7 +2581,7 @@ export const useSettingsStore = defineStore("settings", () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (partial.customThemes !== undefined) {
|
if (partial.customThemes !== undefined) {
|
||||||
editorSettings.value.customThemes = Array.isArray(partial.customThemes) ? partial.customThemes : editorSettings.value.customThemes;
|
editorSettings.value.customThemes = Array.isArray(partial.customThemes) && partial.customThemes.length > 0 ? partial.customThemes : [...DEFAULT_CUSTOM_THEMES];
|
||||||
}
|
}
|
||||||
if (partial.activeCustomThemeId !== undefined) {
|
if (partial.activeCustomThemeId !== undefined) {
|
||||||
editorSettings.value.activeCustomThemeId = partial.activeCustomThemeId;
|
editorSettings.value.activeCustomThemeId = partial.activeCustomThemeId;
|
||||||
@@ -2589,6 +2592,7 @@ export const useSettingsStore = defineStore("settings", () => {
|
|||||||
const activeTheme = themes.find((t) => t.id === activeId) || themes[0];
|
const activeTheme = themes.find((t) => t.id === activeId) || themes[0];
|
||||||
if (activeTheme) {
|
if (activeTheme) {
|
||||||
editorSettings.value.customThemeColors = { ...activeTheme.colors };
|
editorSettings.value.customThemeColors = { ...activeTheme.colors };
|
||||||
|
editorSettings.value.activeCustomThemeId = activeTheme.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (partial.executeMode !== undefined) editorSettings.value.executeMode = partial.executeMode;
|
if (partial.executeMode !== undefined) editorSettings.value.executeMode = partial.executeMode;
|
||||||
|
|||||||
Reference in new issue
Block a user