From 17523bafbf204805f085b43702e5d1cfdef16f25 Mon Sep 17 00:00:00 2001 From: "Crane.z" <1481445951@qq.com> Date: Wed, 5 Aug 2026 15:28:28 +0800 Subject: [PATCH] fix(chen): handle console permissions and outcomes --- ui/chen/components/ConsolePanel.vue | 10 +++------- .../components/ConsoleResultGrid.client.vue | 19 +++++++++++++++---- ui/chen/composables/useChenQueryConsole.ts | 4 +++- ui/chen/types.ts | 1 + ui/chen/workspaces/DatabaseSessionSurface.vue | 1 + 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ui/chen/components/ConsolePanel.vue b/ui/chen/components/ConsolePanel.vue index c7db2f0a..5bd6af6a 100644 --- a/ui/chen/components/ConsolePanel.vue +++ b/ui/chen/components/ConsolePanel.vue @@ -13,6 +13,7 @@ const props = defineProps<{ tab: ChenPromptConsoleTab; contextLabel: string; promptLabel: string; + canCopy: boolean; }>(); const emit = defineEmits<{ @@ -78,11 +79,6 @@ function handleKeydown(event: KeyboardEvent) { run(); return; } - if (event.key === "Enter" && pendingSqlValue.value.trimEnd().endsWith(";")) { - event.preventDefault(); - run(); - return; - } if (event.key === "ArrowUp" && !event.shiftKey && inputRef.value?.selectionStart === 0) { event.preventDefault(); moveHistory(-1); @@ -213,7 +209,7 @@ defineExpose({ focus: () => inputRef.value?.focus() }); Result {{ resultIndex + 1 }} {{ resultSummary(result) }} - +
inputRef.value?.focus() }); class="max-h-32 min-h-7 flex-1 resize-none bg-transparent py-1 text-[var(--app-fg)] outline-none placeholder:text-[var(--app-muted)]" :disabled="busy" rows="1" - placeholder="Enter SQL; finish with ; or press Cmd/Ctrl+Enter" + placeholder="Enter SQL; press Cmd/Ctrl+Enter to run" spellcheck="false" @keydown="handleKeydown" /> diff --git a/ui/chen/components/ConsoleResultGrid.client.vue b/ui/chen/components/ConsoleResultGrid.client.vue index eae77e9f..44c42e7d 100644 --- a/ui/chen/components/ConsoleResultGrid.client.vue +++ b/ui/chen/components/ConsoleResultGrid.client.vue @@ -8,9 +8,15 @@ import { AgGridVue } from "ag-grid-vue3"; import "ag-grid-community/styles/ag-grid.css"; import "ag-grid-community/styles/ag-theme-balham.css"; -const props = defineProps<{ - dataset: ChenDataViewDataset; -}>(); +const props = withDefaults( + defineProps<{ + dataset: ChenDataViewDataset; + canCopy?: boolean; + }>(), + { + canCopy: false + } +); ModuleRegistry.registerModules([AllCommunityModule]); @@ -42,6 +48,10 @@ function handleGridReady(event: GridReadyEvent) { fitColumns(event.api); } +function handleCopy(event: ClipboardEvent) { + if (!props.canCopy) event.preventDefault(); +} + watch([columnDefs, () => props.dataset.data], async () => { const api = gridApi.value; if (!api) return; @@ -53,7 +63,7 @@ watch([columnDefs, () => props.dataset.data], async () => {