dify知识库同步/删除问题修复
This commit is contained in:
1 parent
4ff07f8f9b
commit
c14046f9f3
8 files changed
+89
-44
No files matched your search
@@ -73,41 +73,43 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Transition name="delete-dialog-fade">
|
||||
<div
|
||||
v-if="modelValue"
|
||||
class="fixed inset-0 z-[100] bg-black/45 flex items-center justify-center p-4"
|
||||
@click.self="handleCancel"
|
||||
>
|
||||
<div class="delete-dialog-container w-full max-w-[416px] rounded-lg bg-white shadow-[0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)] px-6 pt-7 pb-5">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="delete-dialog-icon" aria-hidden="true">!</span>
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-[16px] leading-6 font-semibold text-[rgba(0,0,0,0.88)]">
|
||||
{{ resolvedTitle }}
|
||||
</h3>
|
||||
<p class="mt-3 text-[14px] leading-[22px] text-[rgba(0,0,0,0.65)] whitespace-pre-line">
|
||||
{{ resolvedMessage }}
|
||||
</p>
|
||||
<Teleport to="body">
|
||||
<Transition name="delete-dialog-fade">
|
||||
<div
|
||||
v-if="modelValue"
|
||||
class="fixed inset-0 z-[100] bg-black/45 flex items-center justify-center p-4"
|
||||
@click.self="handleCancel"
|
||||
>
|
||||
<div class="delete-dialog-container w-full max-w-[416px] rounded-lg bg-white shadow-[0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)] px-6 pt-7 pb-5">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="delete-dialog-icon" aria-hidden="true">!</span>
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-[16px] leading-6 font-semibold text-[rgba(0,0,0,0.88)]">
|
||||
{{ resolvedTitle }}
|
||||
</h3>
|
||||
<p class="mt-3 text-[14px] leading-[22px] text-[rgba(0,0,0,0.65)] whitespace-pre-line">
|
||||
{{ resolvedMessage }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-2">
|
||||
<button type="button" class="delete-dialog-btn cancel" @click="handleCancel">
|
||||
{{ resolvedCancelText }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="delete-dialog-btn confirm"
|
||||
:disabled="confirmLoading"
|
||||
@click="handleConfirm"
|
||||
>
|
||||
{{ resolvedConfirmText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-2">
|
||||
<button type="button" class="delete-dialog-btn cancel" @click="handleCancel">
|
||||
{{ resolvedCancelText }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="delete-dialog-btn confirm"
|
||||
:disabled="confirmLoading"
|
||||
@click="handleConfirm"
|
||||
>
|
||||
{{ resolvedConfirmText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -102,9 +102,11 @@ const openDeleteConfirmDialog = (
|
||||
message: string,
|
||||
onConfirm: () => Promise<void> | void
|
||||
) => {
|
||||
console.log('[KB] openDeleteConfirmDialog', message);
|
||||
deleteConfirmMessage.value = message;
|
||||
pendingDeleteAction = onConfirm;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
console.log('[KB] showDeleteConfirmDialog set to', showDeleteConfirmDialog.value);
|
||||
};
|
||||
|
||||
const closeDeleteConfirmDialog = () => {
|
||||
@@ -115,7 +117,13 @@ const closeDeleteConfirmDialog = () => {
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!pendingDeleteAction) return;
|
||||
await pendingDeleteAction();
|
||||
try {
|
||||
await pendingDeleteAction();
|
||||
} catch (err) {
|
||||
console.error('[deleteConfirm]', err);
|
||||
feedback.value = String(err) || '操作失败';
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
closeDeleteConfirmDialog();
|
||||
};
|
||||
const selectedDocument = computed(() => documents.value.find((item) => item.id === selectedDocumentId.value) || null);
|
||||
@@ -1110,6 +1118,7 @@ const toggleSelectAllFiltered = () => {
|
||||
};
|
||||
|
||||
const handleDeleteDocument = async (doc: KbDocumentItem) => {
|
||||
console.log('[KB] handleDeleteDocument called', doc.id, doc.title);
|
||||
openDeleteConfirmDialog(`确认删除文档「${getDocumentDisplayTitle(doc)}」吗?`, async () => {
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (!result.ok) {
|
||||
@@ -1161,6 +1170,7 @@ const handleBatchSync = async () => {
|
||||
};
|
||||
|
||||
const handleBatchDelete = async () => {
|
||||
console.log('[KB] handleBatchDelete called, selected:', selectedDocuments.value.length);
|
||||
if (!selectedDocuments.value.length) {
|
||||
feedback.value = '请先选择要批量删除的文档';
|
||||
feedbackType.value = 'error';
|
||||
@@ -2581,11 +2591,12 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="handleDeleteConfirm"
|
||||
@cancel="closeDeleteConfirmDialog"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="handleDeleteConfirm"
|
||||
@cancel="closeDeleteConfirmDialog"
|
||||
/>
|
||||
</template>
|
||||
Reference in new issue
Block a user