🔀 整合发送详情与回收站界面优化
This commit is contained in:
commit
0a4ca0db62
8 files changed
+159
-29
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
class="rounded-2xl p-8 flex flex-col items-center justify-center border-2 border-dashed transition-all duration-300 group cursor-pointer relative min-h-72 overflow-hidden"
|
||||
class="rounded-2xl p-5 sm:p-8 flex flex-col items-center justify-center border-2 border-dashed transition-all duration-300 group cursor-pointer relative min-h-56 sm:min-h-72 overflow-hidden"
|
||||
:class="[
|
||||
isDarkMode
|
||||
? 'bg-gray-800/60 border-gray-600 hover:border-indigo-400'
|
||||
@@ -64,7 +64,7 @@
|
||||
]"
|
||||
>
|
||||
<span v-if="selectedFiles && selectedFiles.length > 1" class="block">
|
||||
<span v-for="(f, i) in selectedFiles" :key="i" class="block truncate">{{ f.name }}</span>
|
||||
<span v-for="f in uniqueFiles.slice(0, 3)" :key="fileKey(f)" class="block truncate">{{ f.name }}</span>
|
||||
</span>
|
||||
<span v-else class="block break-words line-clamp-2">
|
||||
{{ displayText }}
|
||||
@@ -214,6 +214,17 @@ const displayText = computed(() => {
|
||||
return placeholderText.value
|
||||
})
|
||||
|
||||
const uniqueFiles = computed(() => {
|
||||
const seen = new Set<string>()
|
||||
return props.selectedFiles.filter((file) => {
|
||||
const key = `${file.name}-${file.size}-${file.lastModified}`
|
||||
if (seen.has(key)) return false
|
||||
seen.add(key)
|
||||
return true
|
||||
})
|
||||
})
|
||||
const fileKey = (file: File) => `${file.name}-${file.size}-${file.lastModified}`
|
||||
|
||||
const statusIcon = computed(() => {
|
||||
if (isUploading.value) return LoaderIcon
|
||||
if (isSuccess.value) return CheckCircleIcon
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
<transition name="fade">
|
||||
<div
|
||||
v-if="record"
|
||||
ref="modalRef"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-labelledby="modalTitleId"
|
||||
tabindex="-1"
|
||||
@keydown="handleKeydown"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center overflow-y-auto bg-black/60 p-3 backdrop-blur-sm sm:p-4"
|
||||
>
|
||||
<div
|
||||
@@ -14,13 +20,16 @@
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<h3
|
||||
:id="modalTitleId"
|
||||
class="text-base font-semibold sm:text-xl"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||||
>
|
||||
{{ t('send.fileDetails') }}
|
||||
</h3>
|
||||
<button
|
||||
@click="$emit('close')"
|
||||
type="button"
|
||||
aria-label="关闭文件详情"
|
||||
@click="emit('close')"
|
||||
class="rounded-[30px] p-1.5 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800 sm:p-2"
|
||||
>
|
||||
<XIcon
|
||||
@@ -45,7 +54,8 @@
|
||||
</div>
|
||||
<div class="ml-3 sm:ml-4 min-w-0 flex-1">
|
||||
<h4
|
||||
class="font-medium text-sm sm:text-base truncate"
|
||||
class="font-medium text-sm sm:text-base break-words"
|
||||
:title="record.filename"
|
||||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||||
>
|
||||
{{ record.filename }}
|
||||
@@ -92,8 +102,10 @@
|
||||
<div class="flex items-center justify-between mb-3 sm:mb-4">
|
||||
<h4 class="font-medium text-sm sm:text-base">取件码</h4>
|
||||
<button
|
||||
@click="$emit('copy-code', record)"
|
||||
class="p-1.5 sm:p-2 rounded-full hover:bg-white/10 transition-colors"
|
||||
type="button"
|
||||
aria-label="复制取件码"
|
||||
@click="emit('copy-code', record)"
|
||||
class="min-h-11 min-w-11 p-1.5 sm:p-2 rounded-full hover:bg-white/10 transition-colors"
|
||||
>
|
||||
<ClipboardCopyIcon class="w-4 h-4 sm:w-5 sm:h-5" />
|
||||
</button>
|
||||
@@ -116,8 +128,10 @@
|
||||
<span class="truncate">wget下载</span>
|
||||
</h4>
|
||||
<button
|
||||
@click="$emit('copy-wget', record)"
|
||||
class="p-1.5 sm:p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0"
|
||||
type="button"
|
||||
aria-label="复制 wget 命令"
|
||||
@click="emit('copy-wget', record)"
|
||||
class="min-h-11 min-w-11 p-1.5 sm:p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0"
|
||||
>
|
||||
<ClipboardCopyIcon
|
||||
class="w-4 h-4 sm:w-5 sm:h-5"
|
||||
@@ -138,9 +152,13 @@
|
||||
class="rounded-xl p-4 sm:p-5 flex flex-col items-center"
|
||||
:class="[isDarkMode ? 'bg-gray-800 bg-opacity-50' : 'bg-gray-50 bg-opacity-95']"
|
||||
>
|
||||
<div class="bg-white p-3 sm:p-4 rounded-lg shadow-sm mb-3 sm:mb-4">
|
||||
<button
|
||||
type="button"
|
||||
class="bg-white p-3 sm:p-4 rounded-lg shadow-sm mb-3 sm:mb-4"
|
||||
aria-label="取件二维码"
|
||||
>
|
||||
<QRCode :value="qrValue" :size="140" level="M" class="sm:w-[160px] sm:h-[160px]" />
|
||||
</div>
|
||||
</button>
|
||||
<p
|
||||
class="text-xs sm:text-sm truncate max-w-full"
|
||||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||||
@@ -156,8 +174,9 @@
|
||||
:class="[isDarkMode ? 'border-gray-800' : 'border-gray-100']"
|
||||
>
|
||||
<button
|
||||
@click="$emit('copy-link', record)"
|
||||
class="w-full bg-indigo-600 hover:bg-indigo-700 text-white px-4 sm:px-6 py-2 sm:py-3 rounded-lg text-sm sm:text-base font-medium transition-colors"
|
||||
type="button"
|
||||
@click="emit('copy-link', record)"
|
||||
class="min-h-11 w-full bg-teal-600 hover:bg-teal-700 text-white px-4 sm:px-6 py-2 sm:py-3 rounded-xl text-sm sm:text-base font-medium transition-colors"
|
||||
>
|
||||
复制取件链接
|
||||
</button>
|
||||
@@ -168,7 +187,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, defineAsyncComponent, inject } from 'vue'
|
||||
import { computed, defineAsyncComponent, inject, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import {
|
||||
ClipboardCopyIcon,
|
||||
ClockIcon,
|
||||
@@ -180,13 +199,14 @@ import {
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { SentFileRecord } from '@/types'
|
||||
import { lockBodyScroll, unlockBodyScroll } from './scrollLock'
|
||||
|
||||
const props = defineProps<{
|
||||
record: SentFileRecord | null
|
||||
getQRCodeValue: (record: SentFileRecord) => string
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
const emit = defineEmits<{
|
||||
close: []
|
||||
'copy-code': [record: SentFileRecord]
|
||||
'copy-link': [record: SentFileRecord]
|
||||
@@ -197,6 +217,29 @@ const { t } = useI18n()
|
||||
const isDarkMode = inject('isDarkMode')
|
||||
const QRCode = defineAsyncComponent(() => import('qrcode.vue'))
|
||||
const qrValue = computed(() => (props.record ? props.getQRCodeValue(props.record) : ''))
|
||||
const modalRef = ref<HTMLElement>()
|
||||
|
||||
const modalTitleId = 'sent-record-detail-title'
|
||||
let returnFocusElement: HTMLElement | null = null
|
||||
const focusableSelector = 'button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'
|
||||
const handleKeydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') { event.preventDefault(); emit('close'); return }
|
||||
if (event.key !== 'Tab' || !modalRef.value) return
|
||||
const focusable = [...modalRef.value.querySelectorAll<HTMLElement>(focusableSelector)]
|
||||
const first = focusable[0]; const last = focusable[focusable.length - 1]
|
||||
if (first && last && ((event.shiftKey && document.activeElement === first) || (!event.shiftKey && document.activeElement === last))) {
|
||||
event.preventDefault(); (event.shiftKey ? last : first).focus()
|
||||
}
|
||||
}
|
||||
watch(() => props.record, async (record) => {
|
||||
if (record) {
|
||||
returnFocusElement = document.activeElement instanceof HTMLElement ? document.activeElement : null
|
||||
lockBodyScroll(); await nextTick(); modalRef.value?.focus()
|
||||
} else {
|
||||
unlockBodyScroll(); await nextTick(); returnFocusElement?.focus(); returnFocusElement = null
|
||||
}
|
||||
}, { immediate: true })
|
||||
onBeforeUnmount(() => { unlockBodyScroll(); returnFocusElement = null })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -46,9 +46,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject, nextTick, ref, watch } from 'vue'
|
||||
import { inject, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { XIcon } from 'lucide-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { lockBodyScroll, unlockBodyScroll } from './scrollLock'
|
||||
|
||||
const props = defineProps<{ visible: boolean; title: string }>()
|
||||
const emit = defineEmits<{ close: [] }>()
|
||||
@@ -83,17 +84,20 @@ watch(
|
||||
() => props.visible,
|
||||
async (visible) => {
|
||||
if (visible) {
|
||||
lockBodyScroll()
|
||||
returnFocusElement = document.activeElement instanceof HTMLElement ? document.activeElement : null
|
||||
await nextTick()
|
||||
const first = drawerRef.value?.querySelector<HTMLElement>(focusableSelector)
|
||||
;(first || drawerRef.value)?.focus()
|
||||
} else {
|
||||
unlockBodyScroll()
|
||||
await nextTick()
|
||||
returnFocusElement?.focus()
|
||||
returnFocusElement = null
|
||||
}
|
||||
}
|
||||
)
|
||||
onBeforeUnmount(() => unlockBodyScroll())
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
let lockCount = 0
|
||||
let previousOverflow = ''
|
||||
|
||||
export function lockBodyScroll(): void {
|
||||
if (lockCount === 0) {
|
||||
previousOverflow = document.body.style.overflow
|
||||
document.body.style.overflow = 'hidden'
|
||||
}
|
||||
lockCount += 1
|
||||
}
|
||||
|
||||
export function unlockBodyScroll(): void {
|
||||
if (lockCount === 0) return
|
||||
lockCount -= 1
|
||||
if (lockCount === 0) {
|
||||
document.body.style.overflow = previousOverflow
|
||||
previousOverflow = ''
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,10 @@ export function useSendFlow() {
|
||||
const selectedRecord = ref<SentFileRecord | null>(null)
|
||||
const isSubmitting = ref(false)
|
||||
const fileHash = ref('')
|
||||
const uploadStatus = ref<'idle' | 'uploading' | 'success' | 'error'>('idle')
|
||||
const uploadedBytes = ref(0)
|
||||
const totalBytes = ref(0)
|
||||
const uploadError = ref('')
|
||||
const sendRecords = computed(() => fileDataStore.shareData)
|
||||
const uploadDescription = computed(() =>
|
||||
t('send.uploadArea.descriptionWithLimit', {
|
||||
@@ -62,7 +66,11 @@ export function useSendFlow() {
|
||||
translate: t,
|
||||
onProgress: (progress) => {
|
||||
uploadProgress.value = progress
|
||||
const total = selectedFile.value?.size || selectedFiles.value.reduce((sum, file) => sum + file.size, 0)
|
||||
totalBytes.value = total
|
||||
uploadedBytes.value = Math.round((progress / 100) * total)
|
||||
},
|
||||
onStatus: (status) => { uploadStatus.value = status },
|
||||
onHashCalculated: (hash) => {
|
||||
fileHash.value = hash
|
||||
}
|
||||
@@ -207,6 +215,7 @@ export function useSendFlow() {
|
||||
const handleSubmit = async () => {
|
||||
if (isSubmitting.value) return
|
||||
isSubmitting.value = true
|
||||
uploadStatus.value = 'uploading'
|
||||
|
||||
try {
|
||||
if (sendType.value === 'file' && !selectedFile.value && selectedFiles.value.length === 0) {
|
||||
@@ -273,6 +282,9 @@ export function useSendFlow() {
|
||||
selectedFiles.value = []
|
||||
textContent.value = ''
|
||||
uploadProgress.value = 0
|
||||
uploadedBytes.value = 0
|
||||
totalBytes.value = 0
|
||||
uploadStatus.value = 'idle'
|
||||
resetPresignUpload()
|
||||
selectedRecord.value = newRecord
|
||||
await sentRecordActions.copyLink(newRecord)
|
||||
@@ -280,6 +292,8 @@ export function useSendFlow() {
|
||||
throw new Error(t('send.messages.serverError'))
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
uploadStatus.value = 'error'
|
||||
uploadError.value = getErrorMessage(error, t('send.messages.sendFailed'))
|
||||
alertStore.showAlert(getErrorMessage(error, t('send.messages.sendFailed')), 'error')
|
||||
} finally {
|
||||
uploadProgress.value = 0
|
||||
@@ -319,6 +333,10 @@ export function useSendFlow() {
|
||||
showDrawer,
|
||||
selectedRecord,
|
||||
isSubmitting,
|
||||
uploadStatus,
|
||||
uploadedBytes,
|
||||
totalBytes,
|
||||
uploadError,
|
||||
sendRecords,
|
||||
uploadDescription,
|
||||
expirationOptions,
|
||||
|
||||
@@ -14,6 +14,7 @@ type UseSendSubmitOptions = {
|
||||
translate: Translate
|
||||
onProgress: (progress: number) => void
|
||||
onHashCalculated: (hash: string) => void
|
||||
onStatus?: (status: 'idle' | 'uploading' | 'success' | 'error') => void
|
||||
}
|
||||
|
||||
type SubmitFileOptions = {
|
||||
@@ -106,9 +107,17 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
throw new Error(options.translate('send.messages.selectFile'))
|
||||
}
|
||||
|
||||
return enableChunk
|
||||
? handleChunkUpload(fileToUpload, expireValue, expireStyle)
|
||||
: handlePresignedUpload(fileToUpload, expireValue, expireStyle)
|
||||
options.onStatus?.('uploading')
|
||||
try {
|
||||
const response = enableChunk
|
||||
? await handleChunkUpload(fileToUpload, expireValue, expireStyle)
|
||||
: await handlePresignedUpload(fileToUpload, expireValue, expireStyle)
|
||||
if (response?.code === 200) options.onStatus?.('success')
|
||||
return response
|
||||
} catch (error) {
|
||||
options.onStatus?.('error')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const submitText = ({ text, expireValue, expireStyle }: SubmitTextOptions) =>
|
||||
|
||||
@@ -26,10 +26,15 @@
|
||||
:selected-file="selectedFile"
|
||||
:selected-files="selectedFiles"
|
||||
:progress="uploadProgress"
|
||||
:upload-status="uploadStatus"
|
||||
:uploaded-bytes="uploadedBytes"
|
||||
:total-bytes="totalBytes"
|
||||
:error-message="uploadError"
|
||||
:description="uploadDescription"
|
||||
@file-selected="handleFileSelected"
|
||||
@files-selected="handleFilesSelected"
|
||||
@file-drop="handleFileDrop"
|
||||
@retry="handleSubmit"
|
||||
/>
|
||||
</div>
|
||||
<div v-else key="text" class="grid grid-cols-1 gap-8">
|
||||
@@ -165,6 +170,10 @@ const {
|
||||
showDrawer,
|
||||
selectedRecord,
|
||||
isSubmitting,
|
||||
uploadStatus,
|
||||
uploadedBytes,
|
||||
totalBytes,
|
||||
uploadError,
|
||||
sendRecords,
|
||||
uploadDescription,
|
||||
expirationOptions,
|
||||
|
||||
@@ -11,22 +11,22 @@
|
||||
<template #icon><Settings2Icon class="mr-2 h-4 w-4" /></template>
|
||||
配置默认清理时间
|
||||
</BaseButton>
|
||||
<BaseButton variant="secondary" :loading="isLoading" @click="loadTrash">
|
||||
<BaseButton variant="secondary" :loading="isLoading" :disabled="busyId !== null" @click="loadTrash">
|
||||
<template #icon><RefreshCwIcon class="mr-2 h-4 w-4" /></template>
|
||||
刷新回收站
|
||||
</BaseButton>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="mb-5 grid gap-3 sm:mb-6 sm:grid-cols-3">
|
||||
<section class="mb-5 grid grid-cols-3 gap-2 sm:mb-6 sm:gap-3">
|
||||
<div class="theme-2026-card rounded-[20px] border p-3.5 shadow-sm sm:rounded-[24px] sm:p-4" :class="panelClass">
|
||||
<p class="text-xs" :class="mutedTextClass">回收站记录</p><strong class="mt-1 block text-2xl" :class="primaryTextClass">{{ total }}</strong>
|
||||
<p class="text-[11px] leading-4 sm:text-xs" :class="mutedTextClass">全部记录</p><strong class="mt-1 block text-xl sm:text-2xl" :class="primaryTextClass">{{ total }}</strong>
|
||||
</div>
|
||||
<div class="theme-2026-card rounded-[20px] border p-3.5 shadow-sm sm:rounded-[24px] sm:p-4" :class="panelClass">
|
||||
<p class="text-xs" :class="mutedTextClass">可恢复</p><strong class="mt-1 block text-2xl" :class="primaryTextClass">{{ recoverableCount }}</strong>
|
||||
<p class="text-[11px] leading-4 sm:text-xs" :class="mutedTextClass">本页可恢复</p><strong class="mt-1 block text-xl sm:text-2xl" :class="primaryTextClass">{{ recoverableCount }}</strong>
|
||||
</div>
|
||||
<div class="theme-2026-card rounded-[20px] border p-3.5 shadow-sm sm:rounded-[24px] sm:p-4" :class="panelClass">
|
||||
<p class="text-xs" :class="mutedTextClass">仅审计记录</p><strong class="mt-1 block text-2xl" :class="primaryTextClass">{{ purgedCount }}</strong>
|
||||
<p class="text-[11px] leading-4 sm:text-xs" :class="mutedTextClass">本页仅审计</p><strong class="mt-1 block text-xl sm:text-2xl" :class="primaryTextClass">{{ purgedCount }}</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -37,10 +37,11 @@
|
||||
</div>
|
||||
|
||||
<div v-if="isLoading" class="flex min-h-64 items-center justify-center text-sm" :class="mutedTextClass"><RefreshCwIcon class="mr-2 h-4 w-4 animate-spin" />正在加载回收站…</div>
|
||||
<div v-else-if="errorText" class="px-4 py-12 text-center sm:px-6"><p class="text-sm font-medium text-red-600">{{ errorText }}</p><BaseButton class="mt-3" variant="secondary" @click="loadTrash">重新加载</BaseButton></div>
|
||||
<div v-else-if="items.length === 0" class="px-4 py-14 text-center sm:px-6"><Trash2Icon class="mx-auto h-9 w-9" :class="mutedTextClass" /><p class="mt-3 text-sm" :class="mutedTextClass">回收站目前为空</p></div>
|
||||
<div v-else-if="errorText && items.length === 0" class="px-4 py-12 text-center sm:px-6"><p class="text-sm font-medium text-red-600">{{ errorText }}</p><BaseButton class="mt-3" variant="secondary" @click="loadTrash">重新加载</BaseButton></div>
|
||||
<div v-if="errorText && items.length > 0" class="border-b px-4 py-3 text-sm text-red-600 sm:px-6" :class="dividerClass">{{ errorText }}</div>
|
||||
<div v-if="!errorText && items.length === 0" class="px-4 py-14 text-center sm:px-6"><Trash2Icon class="mx-auto h-9 w-9" :class="mutedTextClass" /><p class="mt-3 text-sm" :class="mutedTextClass">回收站目前为空</p></div>
|
||||
|
||||
<div v-else class="divide-y" :class="dividerClass">
|
||||
<div v-if="!errorText && items.length > 0" class="divide-y" :class="dividerClass">
|
||||
<article
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
@@ -63,6 +64,14 @@
|
||||
|
||||
<DataPagination v-if="total > 0" :current-page="page" :page-size="size" :total="total" @page-change="changePage" @page-size-change="changePageSize" />
|
||||
</section>
|
||||
<BaseModal :show="showPurgeModal" title="确认物理清理" @close="closePurgeModal">
|
||||
<p class="text-sm" :class="mutedTextClass">确定清理“{{ pendingPurge ? fileName(pendingPurge) : '' }}”吗?文件本体不可恢复,但审计记录会永久保留。</p>
|
||||
<template #footer><BaseButton variant="secondary" @click="closePurgeModal">取消</BaseButton><BaseButton variant="danger" :loading="busyAction === 'purge'" @click="confirmPurge">确认物理清理</BaseButton></template>
|
||||
</BaseModal>
|
||||
<BaseModal :show="Boolean(restoredCode)" title="文件已恢复" @close="restoredCode = ''">
|
||||
<p class="text-sm" :class="mutedTextClass">恢复成功,新的取件码:</p>
|
||||
<div class="mt-3 flex items-center justify-between gap-3 rounded-xl border px-4 py-3" :class="panelClass"><strong class="text-xl tracking-[0.2em]" :class="primaryTextClass">{{ restoredCode }}</strong><BaseButton size="sm" variant="outline" @click="copyCode">复制</BaseButton></div>
|
||||
</BaseModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -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<number | null>(null)
|
||||
const busyAction = ref('')
|
||||
const showPurgeModal = ref(false)
|
||||
const pendingPurge = ref<TrashFileItem | null>(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<unknown>) => { 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<unknown>) => { 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()
|
||||
|
||||
Reference in new issue
Block a user