fix: stabilize custom theme integration

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

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",

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",

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;

View File

@ -1,12 +1,8 @@
{
"name": "dbx",
"private": true,
"version": "0.5.29",
"private": true,
"type": "module",
"packageManager": "pnpm@10.27.0",
"engines": {
"node": ">=22.13.0"
},
"scripts": {
"dev": "vite --config apps/desktop/vite.config.ts",
"dev:tauri": "tauri dev",
@ -38,6 +34,7 @@
"@codemirror/state": "^6.6.0",
"@codemirror/theme-one-dark": "^6.1.3",
"@codemirror/view": "^6.43.0",
"@lezer/highlight": "^1.2.3",
"@lucide/vue": "1.17.0",
"@msgpack/msgpack": "^3.1.3",
"@tauri-apps/api": "^2.11.0",
@ -73,7 +70,6 @@
"vue-virtual-scroller": "^3.0.4"
},
"devDependencies": {
"@lezer/highlight": "^1.2.3",
"@oxfmt/binding-darwin-arm64": "0.53.0",
"@oxlint/binding-darwin-arm64": "1.68.0",
"@tailwindcss/vite": "^4.3.0",
@ -91,14 +87,18 @@
"vite": "^8.0.16",
"vue-tsc": "^3.3.3"
},
"lint-staged": {
"apps/desktop/src/**/*.{ts,vue}": "oxfmt"
},
"engines": {
"node": ">=22.13.0"
},
"packageManager": "pnpm@10.27.0",
"pnpm": {
"onlyBuiltDependencies": [
"better-sqlite3",
"esbuild",
"keytar"
]
},
"lint-staged": {
"apps/desktop/src/**/*.{ts,vue}": "oxfmt"
}
}

View File

@ -38,6 +38,9 @@ importers:
'@codemirror/view':
specifier: ^6.43.0
version: 6.43.0
'@lezer/highlight':
specifier: ^1.2.3
version: 1.2.3
'@lucide/vue':
specifier: 1.17.0
version: 1.17.0(vue@3.5.35(typescript@6.0.3))
@ -138,9 +141,6 @@ importers:
specifier: ^3.0.4
version: 3.0.4(vue@3.5.35(typescript@6.0.3))
devDependencies:
'@lezer/highlight':
specifier: ^1.2.3
version: 1.2.3
'@oxfmt/binding-darwin-arm64':
specifier: 0.53.0
version: 0.53.0

View File

@ -20,7 +20,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
base64 = "0.22"
log = "0.4"
tauri = { version = "2.10.3", features = ["tray-icon", "custom-protocol"] }
tauri = { version = "2.10.3", features = ["tray-icon"] }
tauri-plugin-log = "2"
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4", "with-uuid-1", "with-serde_json-1"] }
deadpool-postgres = { version = "0.14", features = ["rt_tokio_1"] }