删除确认对话框

This commit is contained in:
sophie committed 2026-04-16 13:39:40 +08:00
1 parent 658ab92706
commit 5df6957e15
4 files changed
+440 -121

No files matched your search

+30 -7
View File
@@ -9,6 +9,7 @@ import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { config } from '../config';
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
import {
Settings,
LayoutGrid,
@@ -118,6 +119,8 @@ const registerForm = ref({ username: '', password: '', email: '', real_name: '',
const forgotPasswordForm = ref({ email: '' });
const pendingAgentId = ref<number | null>(null);
const isWecomLoggingIn = ref(false);
const showDeleteQuickQuestionDialog = ref(false);
const pendingDeleteQuickQuestionId = ref<number | null>(null);
const handleForgotPassword = async () => {
if (!forgotPasswordForm.value.email) {
@@ -650,9 +653,22 @@ const saveQuickQuestion = async () => {
};
const removeQuickQuestion = async (id: number) => {
if (!window.confirm(t('workspace.quickQuestions.confirmDelete'))) return;
await fetch(`/api/user/quick-questions/${id}`, { method: 'DELETE', headers: getAuthHeaders() });
// 删除动作分两步:先记录待删除 id 并打开公共弹框,真正删除在 confirm 回调中执行。
pendingDeleteQuickQuestionId.value = id;
showDeleteQuickQuestionDialog.value = true;
};
const confirmRemoveQuickQuestion = async () => {
if (pendingDeleteQuickQuestionId.value === null) return;
await fetch(`/api/user/quick-questions/${pendingDeleteQuickQuestionId.value}`, { method: 'DELETE', headers: getAuthHeaders() });
await fetchHome();
pendingDeleteQuickQuestionId.value = null;
showDeleteQuickQuestionDialog.value = false;
};
const cancelRemoveQuickQuestion = () => {
pendingDeleteQuickQuestionId.value = null;
showDeleteQuickQuestionDialog.value = false;
};
// Drag & Drop
@@ -959,7 +975,7 @@ onBeforeUnmount(() => {
<div class="md:pl-6">
<!-- Header -->
<div class="flex justify-between items-center mb-6">
<h2 class="text-lg md:text-xl font-semibold text-[#1b2b49] flex items-center gap-2.5 cursor-pointer select-none" @click="toggleSectionCollapse(section)">
<h2 class="text-lg md:text-xl font-semibold text-[#1b2b49] dark:text-slate-100 flex items-center gap-2.5 cursor-pointer select-none" @click="toggleSectionCollapse(section)">
<div class="p-2 rounded-lg" :class="{
'bg-emerald-50 text-emerald-600': section.id === 'announcements',
'bg-yellow-50 text-yellow-600': section.id === 'favorites',
@@ -1008,8 +1024,8 @@ onBeforeUnmount(() => {
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-5 h-5 sm:w-7 sm:h-7" />
<Bot v-else class="w-5 h-5 sm:w-7 sm:h-7" />
</div>
<div class="text-[15px] sm:text-base font-semibold text-[#1b2b49] mb-1 group-hover/card:text-brand-700 transition-colors truncate">{{ agent.name }}</div>
<div class="text-[13px] sm:text-xs text-[#8fa1b8] truncate">{{ agent.description }}</div>
<div class="text-[15px] sm:text-base font-semibold text-[#1b2b49] dark:text-slate-100 mb-1 group-hover/card:text-brand-700 dark:group-hover/card:text-brand-300 transition-colors truncate">{{ agent.name }}</div>
<div class="text-[13px] sm:text-xs text-[#8fa1b8] dark:text-slate-300 truncate">{{ agent.description }}</div>
<button @click.stop="toggleFavorite(agent.id)" class="absolute top-3 right-3 text-yellow-400 hover:text-yellow-500 hover:scale-110 transition-all opacity-0 group-hover/card:opacity-100">
<Star class="w-5 h-5 fill-current" />
</button>
@@ -1106,8 +1122,8 @@ onBeforeUnmount(() => {
<Star class="w-5 h-5" :class="{ 'fill-yellow-400 text-yellow-400': favoriteAgentIds.includes(agent.id) }" />
</button>
</div>
<h3 class="text-[15px] sm:text-base font-semibold text-[#1b2b49] mb-1 group-hover/card:text-brand-700 transition-colors line-clamp-1 sm:line-clamp-2 leading-tight">{{ agent.name }}</h3>
<p class="text-[13px] sm:text-xs text-[#8fa1b8] line-clamp-1 sm:line-clamp-2 h-4 sm:h-8 leading-relaxed">{{ agent.description }}</p>
<h3 class="text-[15px] sm:text-base font-semibold text-[#1b2b49] dark:text-slate-100 mb-1 group-hover/card:text-brand-700 dark:group-hover/card:text-brand-300 transition-colors line-clamp-1 sm:line-clamp-2 leading-tight">{{ agent.name }}</h3>
<p class="text-[13px] sm:text-xs text-[#8fa1b8] dark:text-slate-300 line-clamp-1 sm:line-clamp-2 h-4 sm:h-8 leading-relaxed">{{ agent.description }}</p>
</div>
</div>
</div>
@@ -1185,6 +1201,13 @@ onBeforeUnmount(() => {
</div>
</div>
<DeleteConfirmDialog
v-model="showDeleteQuickQuestionDialog"
:title="$t('workspace.quickQuestions.deleteDialog.title')"
:message="$t('workspace.quickQuestions.deleteDialog.message')"
@confirm="confirmRemoveQuickQuestion"
@cancel="cancelRemoveQuickQuestion"
/>
</div>
</template>