fix: stabilize custom theme integration

This commit is contained in:
t8y2 committed 2026-06-06 21:04:19 +08:00
1 parent a067ee8d76
commit 85e2cf1f2f
6 files changed
+81 -20

No files matched your search

+32
View File
@@ -1791,6 +1791,38 @@ export default {
shortcutPressShortcut: "Premi scorciatoia",
shortcutConflict: "Questa scorciatoia è in conflitto con un'altra azione nello stesso ambito.",
preview: "Anteprima in tempo reale",
customTheme: "Tema personalizzato",
customThemeConfigure: "Configura tema personalizzato",
customThemeTitle: "Configurazione tema personalizzato",
customThemeMyThemes: "I miei temi",
customThemeNewTheme: "Nuovo tema",
customThemeVisualEdit: "Editor visuale",
customThemeJsonConfig: "Configurazione JSON",
customThemeLivePreview: "Anteprima in tempo reale",
customThemePreviewExample: "Esempio di query",
customThemePreset: "Tema predefinito",
customThemeSelectPreset: "Seleziona tema predefinito...",
customThemeApply: "Applica",
customThemePasteImport: "Importa da testo incollato",
customThemeExportJson: "Esporta JSON",
customThemeSaveAndApply: "Salva e applica",
customThemeKeyword: "Parola chiave",
customThemeField: "Campo/Variabile",
customThemeFunction: "Funzione",
customThemeString: "Stringa",
customThemeNumber: "Numero",
customThemeComment: "Commento",
customThemeTable: "Tabella",
customThemeOperator: "Operatore",
customThemeType: "Tipo",
customThemeBuiltin: "Integrato",
customThemeBackground: "Sfondo",
customThemeForeground: "Primo piano",
customThemeDefaultName: "Tema personalizzato",
customThemeCopySuffix: " Copia",
customThemeApplied: 'Schema colori "{name}" applicato',
customThemeKeepOne: "Mantieni almeno un tema",
customThemeJsonError: "Formato JSON non valido, controlla",
jdbcPlugin: "Plugin DBX JDBC",
jdbcPluginInstall: "Installa plugin JDBC",
jdbcPluginInstallSuccess: "Plugin JDBC installato",
+32
View File
@@ -1781,6 +1781,38 @@ export default {
shortcutPressShortcut: "Pressione o atalho",
shortcutConflict: "Este atalho conflita com outra ação no mesmo escopo.",
preview: "Pré-visualização ao vivo",
customTheme: "Tema personalizado",
customThemeConfigure: "Configurar tema personalizado",
customThemeTitle: "Configuração do tema personalizado",
customThemeMyThemes: "Meus temas",
customThemeNewTheme: "Novo tema",
customThemeVisualEdit: "Editor visual",
customThemeJsonConfig: "Configuração JSON",
customThemeLivePreview: "Pré-visualização ao vivo",
customThemePreviewExample: "Exemplo de consulta",
customThemePreset: "Tema predefinido",
customThemeSelectPreset: "Selecionar tema predefinido...",
customThemeApply: "Aplicar",
customThemePasteImport: "Importar colado",
customThemeExportJson: "Exportar JSON",
customThemeSaveAndApply: "Salvar e aplicar",
customThemeKeyword: "Palavra-chave",
customThemeField: "Campo/Variável",
customThemeFunction: "Função",
customThemeString: "String",
customThemeNumber: "Número",
customThemeComment: "Comentário",
customThemeTable: "Tabela",
customThemeOperator: "Operador",
customThemeType: "Tipo",
customThemeBuiltin: "Integrado",
customThemeBackground: "Plano de fundo",
customThemeForeground: "Primeiro plano",
customThemeDefaultName: "Tema personalizado",
customThemeCopySuffix: " Cópia",
customThemeApplied: 'Esquema de cores "{name}" aplicado',
customThemeKeepOne: "Mantenha pelo menos um tema",
customThemeJsonError: "Formato JSON inválido, verifique",
jdbcPlugin: "Plugin JDBC do DBX",
jdbcPluginInstall: "Instalar plugin JDBC",
jdbcPluginInstallSuccess: "Plugin JDBC instalado",
+4 -7
View File
@@ -191,7 +191,6 @@ export type DataGridRenderMode = (typeof DATA_GRID_RENDER_MODES)[number];
const DISCONNECT_TAB_HANDLING_MODES = ["close-tabs", "keep-tabs-clear-results", "keep-tabs-keep-results"] as const;
export type DisconnectTabHandlingMode = (typeof DISCONNECT_TAB_HANDLING_MODES)[number];
// 自定义主题颜色配置
export interface CustomThemeColors {
keyword: string;
field: string;
@@ -227,7 +226,7 @@ export interface CustomTheme {
}
export const DEFAULT_CUSTOM_THEMES: CustomTheme[] = [
{ id: "default", name: "自定义", colors: { ...DEFAULT_CUSTOM_THEME_COLORS } },
{ id: "default", name: "Custom", colors: { ...DEFAULT_CUSTOM_THEME_COLORS } },
];
export interface EditorSettings {
@@ -279,7 +278,7 @@ export const EDITOR_THEMES: { value: EditorTheme; label: string; dark: boolean }
{ value: "duotone-light", label: "Duotone Light", dark: false },
{ value: "duotone-dark", label: "Duotone Dark", dark: true },
{ value: "xcode", label: "Xcode", dark: false },
{ value: "custom", label: "Custom (可自定义)", dark: true },
{ value: "custom", label: "Custom", dark: true },
];
const EDITOR_THEME_VALUES = new Set<EditorTheme>(EDITOR_THEMES.map((theme) => theme.value));
@@ -438,15 +437,14 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
},
customThemes: (() => {
if (Array.isArray(settings.customThemes) && settings.customThemes.length > 0) {
// 自动重命名"默认"为"自定义"
return settings.customThemes.map((theme) => (theme.name === "默认" ? { ...theme, name: "自定义" } : theme));
return settings.customThemes.map((theme) => (theme.name === "默认" ? { ...theme, name: "Custom" } : theme));
}
return [
...(settings.customThemeColors
? [
{
id: "migrated",
name: "已迁移",
name: "Migrated",
colors: { ...DEFAULT_CUSTOM_THEME_COLORS, ...settings.customThemeColors },
},
]
@@ -627,7 +625,6 @@ export const useSettingsStore = defineStore("settings", () => {
if (partial.activeCustomThemeId !== undefined) {
editorSettings.value.activeCustomThemeId = partial.activeCustomThemeId;
}
// 同步 customThemeColors 为当前激活主题的颜色(兼容回退逻辑)
if (partial.customThemes !== undefined || partial.activeCustomThemeId !== undefined) {
const themes = editorSettings.value.customThemes;
const activeId = editorSettings.value.activeCustomThemeId;