feat(safety): 增加危险删除操作二次确认 (#11)

将现有 SQL 危险确认弹窗扩展为可复用确认组件。

覆盖 SQL UPDATE/MERGE/REPLACE 等危险语句识别,并在识别前去除注释。

为表格行删除、Redis key/hash/list/set 删除、MongoDB 文档和字段删除接入确认弹窗。

补充中英文危险确认文案,保持本次提交只聚焦确认流程。
This commit is contained in:
vrustx
2026-04-30 14:00:57 +08:00
committed by GitHub
parent 84ea2a6e13
commit 68430d16c1
8 changed files with 231 additions and 27 deletions
+17 -7
View File
@@ -10,9 +10,19 @@ const { t } = useI18n();
const open = defineModel<boolean>("open", { default: false });
defineProps<{
sql: string;
}>();
withDefaults(defineProps<{
sql?: string;
title?: string;
message?: string;
details?: string;
confirmLabel?: string;
}>(), {
sql: "",
title: "",
message: "",
details: "",
confirmLabel: "",
});
const emit = defineEmits<{
confirm: [];
@@ -30,18 +40,18 @@ function onConfirm() {
<DialogHeader>
<DialogTitle class="flex items-center gap-2 text-destructive">
<AlertTriangle class="h-5 w-5" />
{{ t('dangerDialog.title') }}
{{ title || t('dangerDialog.title') }}
</DialogTitle>
</DialogHeader>
<div class="py-4">
<p class="text-sm text-muted-foreground mb-3">{{ t('dangerDialog.message') }}</p>
<pre class="text-xs bg-muted p-3 rounded overflow-auto max-h-40 font-mono whitespace-pre-wrap">{{ sql }}</pre>
<p class="text-sm text-muted-foreground mb-3">{{ message || t('dangerDialog.message') }}</p>
<pre v-if="details || sql" class="text-xs bg-muted p-3 rounded overflow-auto max-h-40 font-mono whitespace-pre-wrap">{{ details || sql }}</pre>
</div>
<DialogFooter>
<Button variant="outline" @click="open = false">{{ t('dangerDialog.cancel') }}</Button>
<Button variant="destructive" @click="onConfirm">{{ t('dangerDialog.confirm') }}</Button>
<Button variant="destructive" @click="onConfirm">{{ confirmLabel || t('dangerDialog.confirm') }}</Button>
</DialogFooter>
</DialogContent>
</Dialog>