From 41e23cccc370bddf9582d58bbed39ad3e7189fc4 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Sat, 30 May 2026 11:22:17 +0800 Subject: [PATCH] feat(desktop): improve sql file preview --- .../sql-file/SqlFileExecutionDialog.vue | 38 +++++++++++++++---- apps/desktop/src/i18n/locales/en.ts | 2 + apps/desktop/src/i18n/locales/es.ts | 2 + apps/desktop/src/i18n/locales/zh-CN.ts | 2 + crates/dbx-web/src/routes/sql_file.rs | 2 +- src-tauri/src/commands/sql_file.rs | 2 +- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue b/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue index 1957b10f2b..25003f4152 100644 --- a/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue +++ b/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue @@ -97,6 +97,17 @@ const progressPercent = computed(() => { if (current <= 0) return running.value ? 8 : 0; return Math.min(95, Math.max(8, Math.round((attempted / current) * 100))); }); +const previewLineCount = computed(() => preview.value?.preview.split(/\r\n|\r|\n/).length ?? 0); +const previewLineNumbers = computed(() => Array.from({ length: previewLineCount.value }, (_, index) => index + 1)); +const previewIsTruncated = computed(() => { + if (!preview.value) return false; + return preview.value.sizeBytes > preview.value.preview.length; +}); +const previewLineSummary = computed(() => + previewIsTruncated.value + ? t("sqlFile.previewingFirstLines", { count: previewLineCount.value }) + : t("sqlFile.previewingLines", { count: previewLineCount.value }), +); function connectionIconType(id: string) { const config = store.getConfig(id); @@ -393,7 +404,7 @@ watch(