+
+
+ 确定清理“{{ pendingPurge ? fileName(pendingPurge) : '' }}”吗?文件本体不可恢复,但审计记录会永久保留。
+ 取消确认物理清理
+
+
+ 恢复成功,新的取件码:
+ {{ restoredCode }}复制
+
@@ -71,10 +80,12 @@ import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
import { EraserIcon, FileX2Icon, InfinityIcon, RefreshCwIcon, RotateCcwIcon, Settings2Icon, ShieldCheckIcon, Trash2Icon } from 'lucide-vue-next'
import BaseButton from '@/components/common/BaseButton.vue'
+import BaseModal from '@/components/common/BaseModal.vue'
import DataPagination from '@/components/common/DataPagination.vue'
import { useAdminTrash, useInjectedDarkMode } from '@/composables'
import type { TrashFileItem } from '@/types'
import { formatFileSize, formatTimestamp } from '@/utils/common'
+import { copyRetrieveCode } from '@/utils/clipboard'
const isDarkMode = useInjectedDarkMode()
const router = useRouter()
@@ -87,6 +98,9 @@ const isLoading = ref(false)
const errorText = ref('')
const busyId = ref
(null)
const busyAction = ref('')
+const showPurgeModal = ref(false)
+const pendingPurge = ref(null)
+const restoredCode = ref('')
const primaryTextClass = computed(() => isDarkMode.value ? 'text-white' : 'text-[#1f3c45]')
const mutedTextClass = computed(() => isDarkMode.value ? 'text-[#a9bdc2]' : 'text-[#617980]')
const panelClass = computed(() => isDarkMode.value ? 'border-[#40545c] bg-[#202f36]/90' : 'border-[#d7e3e5] bg-[#f8fbfb]')
@@ -100,10 +114,13 @@ const expiryLabel = (item: TrashFileItem) => item.isTrashPurged ? `文件本体
const openRetentionSettings = () => { void router.push({ path: '/admin/settings', hash: '#settings-upload' }) }
const loadTrash = async () => { isLoading.value = true; errorText.value = ''; try { const detail = await fetchTrash({ page: page.value, size: size.value }); items.value = detail?.data || []; total.value = Number(detail?.total || 0) } catch (error: unknown) { errorText.value = (error as { response?: { data?: { detail?: string } } })?.response?.data?.detail || '回收站加载失败,请稍后重试。' } finally { isLoading.value = false } }
-const run = async (item: TrashFileItem, action: string, operation: () => Promise) => { busyId.value = item.id; busyAction.value = action; try { await operation(); await loadTrash() } catch (error: unknown) { errorText.value = (error as { response?: { data?: { detail?: string } } })?.response?.data?.detail || '操作未完成,请稍后重试。' } finally { busyId.value = null; busyAction.value = '' } }
-const restore = (item: TrashFileItem) => run(item, 'restore', () => restoreTrashItem(item.id))
+const run = async (item: TrashFileItem, action: string, operation: () => Promise) => { if (busyId.value !== null) return; busyId.value = item.id; busyAction.value = action; errorText.value = ''; try { const response = await operation(); if (action === 'restore') restoredCode.value = String((response as { detail?: { code?: string } })?.detail?.code || ''); await loadTrash() } catch (error: unknown) { errorText.value = (error as { response?: { data?: { detail?: string } } })?.response?.data?.detail || '操作未完成,请稍后重试。' } finally { busyId.value = null; busyAction.value = '' } }
+const restore = (item: TrashFileItem) => void run(item, 'restore', () => restoreTrashItem(item.id))
const makePermanent = (item: TrashFileItem) => run(item, 'retention', () => updateTrashRetention(item.id, 0))
-const purge = (item: TrashFileItem) => { if (!window.confirm(`确定物理清理“${fileName(item)}”吗?文件本体不可恢复,但审计记录会永久保留。`)) return; void run(item, 'purge', () => purgeTrashItem(item.id)) }
+const purge = (item: TrashFileItem) => { if (busyId.value === null) { pendingPurge.value = item; showPurgeModal.value = true } }
+const closePurgeModal = () => { if (busyId.value === null) { showPurgeModal.value = false; pendingPurge.value = null } }
+const confirmPurge = () => { if (!pendingPurge.value) return; const item = pendingPurge.value; closePurgeModal(); void run(item, 'purge', () => purgeTrashItem(item.id)) }
+const copyCode = () => { if (restoredCode.value) void copyRetrieveCode(restoredCode.value) }
const changePage = (nextPage: number) => { page.value = nextPage; void loadTrash() }
const changePageSize = (nextSize: number) => { size.value = nextSize; page.value = 1; void loadTrash() }
void loadTrash()