From f5f986cdd6a858791919cf76db4dfd02bf3cac2c Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 26 May 2026 15:31:15 +0800 Subject: [PATCH] fix: add Shiki SQL syntax highlighting to all SQL display components Add useSqlHighlighter composable and integrate Shiki highlighting into DangerConfirmDialog, QueryHistory, DataGrid (replacing regex-based highlighting), SqlFileExecutionDialog, SchemaDiffDialog, TreeItem, ObjectBrowser, and FieldLineageDialog. Also fix danger dialog overflow by adding overflow-hidden to DialogContent and wrap/scroll support. --- .../src/components/diff/SchemaDiffDialog.vue | 12 +- .../components/editor/DangerConfirmDialog.vue | 18 +- .../src/components/editor/QueryHistory.vue | 8 +- apps/desktop/src/components/grid/DataGrid.vue | 6 +- .../components/lineage/FieldLineageDialog.vue | 6 +- .../src/components/objects/ObjectBrowser.vue | 160 +++++++++++++++++- .../src/components/sidebar/TreeItem.vue | 6 +- .../sql-file/SqlFileExecutionDialog.vue | 9 +- .../components/ui/dialog/DialogContent.vue | 2 +- .../src/composables/useSqlHighlighter.ts | 20 +++ 10 files changed, 221 insertions(+), 26 deletions(-) create mode 100644 apps/desktop/src/composables/useSqlHighlighter.ts diff --git a/apps/desktop/src/components/diff/SchemaDiffDialog.vue b/apps/desktop/src/components/diff/SchemaDiffDialog.vue index c527b990f..560a3f15a 100644 --- a/apps/desktop/src/components/diff/SchemaDiffDialog.vue +++ b/apps/desktop/src/components/diff/SchemaDiffDialog.vue @@ -16,6 +16,7 @@ import type { TableInfo } from "@/types/database"; import { sqlMetadataRefreshTarget } from "@/lib/sqlMetadataRefresh"; import { useToast } from "@/composables/useToast"; import { Loader2, Copy, Play, GitCompareArrows, ArrowLeftRight } from "lucide-vue-next"; +import { useSqlHighlighter } from "@/composables/useSqlHighlighter"; interface SelectableTableDiff extends TableDiff { selected: boolean; @@ -23,6 +24,7 @@ interface SelectableTableDiff extends TableDiff { const { t } = useI18n(); const { toast } = useToast(); +const { highlight } = useSqlHighlighter(); const open = defineModel("open", { default: false }); const store = useConnectionStore(); @@ -52,6 +54,7 @@ const executedCount = ref(0); const executeTotal = ref(0); const syncErrors = ref<{ sql: string; error: string }[]>([]); const syncSql = ref(""); +const highlightedSyncSql = computed(() => highlight(syncSql.value)); const allSelected = computed(() => diffs.value.length > 0 && diffs.value.every((d) => d.selected)); const someSelected = computed(() => diffs.value.some((d) => d.selected) && !allSelected.value); @@ -616,11 +619,10 @@ watch(
-