fix(sql): improve kingbase metadata loading and dangerous sql confirmation

This commit is contained in:
t8y2 committed 2026-06-05 12:48:29 +08:00
1 parent 47ddbd5ce7
commit e780e66e41
14 files changed
+399 -22

No files matched your search

@@ -4,12 +4,15 @@ import { useI18n } from "vue-i18n";
import { AlertTriangle } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { useSqlHighlighter } from "@/composables/useSqlHighlighter";
const { t } = useI18n();
const { highlight } = useSqlHighlighter();
const open = defineModel<boolean>("open", { default: false });
const suppressFuturePrompts = defineModel<boolean>("suppressFuturePrompts", { default: false });
const props = withDefaults(
defineProps<{
@@ -18,6 +21,8 @@ const props = withDefaults(
message?: string;
details?: string;
confirmLabel?: string;
showSuppressToggle?: boolean;
suppressToggleLabel?: string;
}>(),
{
sql: "",
@@ -25,6 +30,8 @@ const props = withDefaults(
message: "",
details: "",
confirmLabel: "",
showSuppressToggle: false,
suppressToggleLabel: "",
},
);
@@ -58,6 +65,15 @@ function onConfirm() {
class="text-xs bg-muted p-3 rounded overflow-auto max-h-40 min-w-0 font-mono whitespace-pre"
v-html="highlightedCode"
/>
<div
v-if="showSuppressToggle"
class="mt-3 flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2"
>
<Label for="danger-confirm-suppress" class="text-sm leading-5">{{
suppressToggleLabel || t("dangerDialog.suppressFuturePrompts")
}}</Label>
<Switch id="danger-confirm-suppress" v-model="suppressFuturePrompts" />
</div>
</div>
<DialogFooter>
@@ -105,6 +105,7 @@ const editUiScale = ref(settingsStore.editorSettings.uiScale);
const editTheme = ref(settingsStore.editorSettings.theme);
const editExecuteMode = ref(settingsStore.editorSettings.executeMode);
const editWordWrap = ref(settingsStore.editorSettings.wordWrap);
const editConfirmDangerousSqlExecution = ref(settingsStore.editorSettings.confirmDangerousSqlExecution);
const editAppLayout = ref(settingsStore.editorSettings.appLayout);
const editShowTrayIcon = ref(settingsStore.desktopSettings.show_tray_icon);
const editIconTheme = ref<DesktopIconTheme>(settingsStore.desktopSettings.icon_theme);
@@ -257,6 +258,7 @@ watch(
editTheme.value = settingsStore.editorSettings.theme;
editExecuteMode.value = settingsStore.editorSettings.executeMode;
editWordWrap.value = settingsStore.editorSettings.wordWrap;
editConfirmDangerousSqlExecution.value = settingsStore.editorSettings.confirmDangerousSqlExecution;
editAppLayout.value = settingsStore.editorSettings.appLayout;
editShowTrayIcon.value = settingsStore.desktopSettings.show_tray_icon;
editIconTheme.value = settingsStore.desktopSettings.icon_theme;
@@ -300,6 +302,7 @@ function hasChanges(): boolean {
editTheme.value !== settingsStore.editorSettings.theme ||
editExecuteMode.value !== settingsStore.editorSettings.executeMode ||
editWordWrap.value !== settingsStore.editorSettings.wordWrap ||
editConfirmDangerousSqlExecution.value !== settingsStore.editorSettings.confirmDangerousSqlExecution ||
editAppLayout.value !== settingsStore.editorSettings.appLayout ||
editShowTrayIcon.value !== settingsStore.desktopSettings.show_tray_icon ||
editIconTheme.value !== settingsStore.desktopSettings.icon_theme ||
@@ -332,6 +335,7 @@ async function persistSettings() {
theme: editTheme.value,
executeMode: editExecuteMode.value,
wordWrap: editWordWrap.value,
confirmDangerousSqlExecution: editConfirmDangerousSqlExecution.value,
appLayout: editAppLayout.value,
showColumnCommentsInHeader: editShowColumnCommentsInHeader.value,
compactColumnHeaderActions: editCompactColumnHeaderActions.value,
@@ -373,6 +377,7 @@ function resetDefaults() {
editTheme.value = DEFAULT_EDITOR_SETTINGS.theme;
editExecuteMode.value = DEFAULT_EDITOR_SETTINGS.executeMode;
editWordWrap.value = DEFAULT_EDITOR_SETTINGS.wordWrap;
editConfirmDangerousSqlExecution.value = DEFAULT_EDITOR_SETTINGS.confirmDangerousSqlExecution;
editAppLayout.value = DEFAULT_EDITOR_SETTINGS.appLayout;
editShowTrayIcon.value = DEFAULT_DESKTOP_SETTINGS.show_tray_icon;
editIconTheme.value = DEFAULT_DESKTOP_SETTINGS.icon_theme;
@@ -1264,6 +1269,16 @@ watch(
</div>
</div>
<div class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
<div class="space-y-1">
<Label for="editor-confirm-dangerous-sql">{{ t("settings.confirmDangerousSqlExecution") }}</Label>
<p class="text-xs text-muted-foreground">
{{ t("settings.confirmDangerousSqlExecutionDescription") }}
</p>
</div>
<Switch id="editor-confirm-dangerous-sql" v-model="editConfirmDangerousSqlExecution" class="mt-0.5" />
</div>
<Separator />
<!-- Live Preview -->
@@ -28,12 +28,14 @@ const props = defineProps<{
appVersion?: string;
showDangerDialog: boolean;
dangerSql: string;
suppressDangerConfirm: boolean;
}>();
const emit = defineEmits<{
"update:showConnectionDialog": [value: boolean];
"update:showSettingsDialog": [value: boolean];
"update:showDangerDialog": [value: boolean];
"update:suppressDangerConfirm": [value: boolean];
dangerConfirm: [];
connectStarted: [name: string];
connectSucceeded: [name: string];
@@ -115,7 +117,10 @@ watch(
v-if="showDangerDialog"
:open="showDangerDialog"
:sql="dangerSql"
:show-suppress-toggle="true"
:suppress-future-prompts="suppressDangerConfirm"
@update:open="emit('update:showDangerDialog', $event)"
@update:suppress-future-prompts="emit('update:suppressDangerConfirm', $event)"
@confirm="emit('dangerConfirm')"
/>
<DataTransferDialog