* 默认关闭定时检测,取消页面加载、翻页和刷新列表触发检测 * 提供明确的检测可下载状态入口,支持全量跨分页和选中文件 * 逐个读取文件并显示进度,支持取消及过期响应隔离 * 保持检测结果标签与时间展示,验证桌面和移动端交互 * 补充手动范围、失败重试、取消及跨页全量检测的集成验收
2604 lines
100 KiB
Vue
2604 lines
100 KiB
Vue
<template>
|
||
<div
|
||
class="p-4 sm:p-6"
|
||
:class="hasSelectedFiles ? (showMobilePolicyActions ? 'pb-[22rem] md:pb-6' : 'pb-44 md:pb-6') : ''"
|
||
>
|
||
<div class="mb-6 flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
|
||
<div>
|
||
<h2 class="text-2xl font-bold" :class="[primaryTextClass]">
|
||
{{ t('fileManage.title') }}
|
||
</h2>
|
||
<p class="mt-1 text-sm" :class="[mutedTextClass]">
|
||
{{ t('fileManage.subtitle', { count: summary.totalFiles }) }}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mb-4 flex flex-wrap items-center gap-3 text-sm" :class="mutedTextClass">
|
||
<label class="flex items-center gap-2">
|
||
自动检测当前页
|
||
<select :value="downloadCheckInterval" :disabled="savingCheckInterval" class="min-h-11 rounded-lg border px-3" :class="fieldClass" @change="handleCheckIntervalChange">
|
||
<option :value="0">仅手动检测</option>
|
||
<option :value="30">每 30 秒</option>
|
||
<option :value="60">每分钟</option>
|
||
<option :value="300">每 5 分钟</option>
|
||
<option :value="600">每 10 分钟</option>
|
||
<option :value="1800">每 30 分钟</option>
|
||
</select>
|
||
</label>
|
||
<BaseButton variant="secondary" :disabled="!hasSelectedFiles || checkingDownloads" @click="checkDownloadIds([...selectedFileIds])">检测选中可下载状态({{ selectedCount }})</BaseButton>
|
||
<BaseButton variant="secondary" :disabled="checkingDownloads" @click="checkAllDownloads" title="检测全部文件,包括未显示的分页">检测可下载状态</BaseButton>
|
||
<BaseButton v-if="checkingDownloads" variant="outline" @click="cancelDownloadChecks">取消检测</BaseButton>
|
||
<span v-if="downloadProgressText" role="status">{{ downloadProgressText }} {{ downloadProgress.completed }}/{{ downloadProgress.total }}</span>
|
||
<span v-if="checkIntervalError" role="alert" class="text-red-500">{{ checkIntervalError }}</span>
|
||
</div>
|
||
|
||
<div v-if="!hasSelectedFiles" class="mb-5 grid grid-cols-2 gap-3 sm:mb-6 sm:gap-4 xl:grid-cols-4">
|
||
<div
|
||
v-for="card in summaryCards"
|
||
:key="card.label"
|
||
class="theme-2026-card theme-2026-card-hover group rounded-[24px] border p-3.5 shadow-md transition-all duration-200 hover:shadow-lg sm:rounded-[30px] sm:p-4"
|
||
:class="[panelClass, cardHoverClass]"
|
||
>
|
||
<div class="relative">
|
||
<div class="min-w-0">
|
||
<p class="pr-8 text-xs sm:text-sm" :class="[mutedTextClass]">{{ card.label }}</p>
|
||
<AdaptiveValue :value="card.value" class="mt-3 font-semibold leading-tight sm:mt-3" :class="primaryTextClass" />
|
||
</div>
|
||
<div
|
||
class="absolute right-0 top-0 rounded-lg p-1.5 transition-transform duration-200"
|
||
:class="[card.iconClass]"
|
||
>
|
||
<component :is="card.icon" class="h-5 w-5" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<section
|
||
v-if="!hasSelectedFiles"
|
||
class="theme-2026-card mb-4 rounded-[24px] border p-3 shadow-md transition-all duration-200 hover:shadow-lg sm:mb-6 sm:rounded-[30px] sm:p-4"
|
||
:class="[panelClass, cardHoverClass]"
|
||
>
|
||
<div class="flex items-center justify-between gap-3 sm:flex-row">
|
||
<div>
|
||
<h3 class="text-base font-semibold" :class="[primaryTextClass]">条件筛选</h3>
|
||
<p class="mt-1 hidden text-xs min-[360px]:block" :class="[mutedTextClass]">
|
||
{{ hasActiveFilters ? '已应用筛选条件' : '默认收起,需要时展开' }}
|
||
</p>
|
||
</div>
|
||
<div class="flex shrink-0 flex-wrap items-center gap-2 sm:justify-end">
|
||
<BaseButton
|
||
v-if="hasActiveFilters"
|
||
variant="outline"
|
||
:disabled="isLoading"
|
||
@click="handleResetFilters"
|
||
>
|
||
<template #icon>
|
||
<XIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.resetFilters') }}
|
||
</BaseButton>
|
||
<BaseButton variant="secondary" :aria-expanded="filterBodyVisible" aria-controls="file-filter-panel" @click="isFilterPanelOpen = !isFilterPanelOpen">
|
||
<template #icon>
|
||
<FilterIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ filterBodyVisible ? '收起筛选' : '展开筛选' }}
|
||
</BaseButton>
|
||
</div>
|
||
</div>
|
||
|
||
<Transition :css="false" @before-enter="beforeExpandPanelEnter" @enter="enterExpandPanel" @after-enter="afterExpandPanelEnter" @before-leave="beforeExpandPanelLeave" @leave="leaveExpandPanel">
|
||
<div id="file-filter-panel" v-show="filterBodyVisible" class="fcb-expand-content">
|
||
<div class="grid gap-4 pt-4">
|
||
<div class="flex flex-col gap-3 lg:flex-row lg:items-center">
|
||
<label class="min-w-0 flex-1">
|
||
<span class="sr-only">{{ t('fileManage.searchPlaceholder') }}</span>
|
||
<span class="relative block">
|
||
<SearchIcon
|
||
class="absolute left-3 top-3 h-4 w-4"
|
||
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
|
||
/>
|
||
<input
|
||
v-model="params.keyword"
|
||
type="text"
|
||
:placeholder="t('fileManage.searchPlaceholder')"
|
||
class="min-h-11 w-full rounded-lg border py-2.5 pl-10 pr-4 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[
|
||
isDarkMode
|
||
? 'border-gray-600 bg-gray-700 text-white placeholder-gray-400'
|
||
: 'border-gray-300 bg-white text-gray-900 placeholder-gray-400'
|
||
]"
|
||
@keyup.enter="handleSearch"
|
||
/>
|
||
</span>
|
||
</label>
|
||
<BaseButton :loading="isLoading" @click="handleSearch">
|
||
<template #icon>
|
||
<SearchIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('common.search') }}
|
||
</BaseButton>
|
||
</div>
|
||
|
||
<div class="grid gap-3 md:grid-cols-2 xl:grid-cols-6">
|
||
<label class="space-y-1">
|
||
<span class="flex items-center text-xs font-medium" :class="[mutedTextClass]">
|
||
<FilterIcon class="mr-1 h-3.5 w-3.5" />
|
||
{{ t('fileManage.statusLabel') }}
|
||
</span>
|
||
<select
|
||
:value="params.status"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
@change="handleStatusFilterChange"
|
||
>
|
||
<option
|
||
v-for="option in statusFilterOptions"
|
||
:key="option.value"
|
||
:value="option.value"
|
||
>
|
||
{{ option.label }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
|
||
<label class="space-y-1">
|
||
<span class="flex items-center text-xs font-medium" :class="[mutedTextClass]">
|
||
<ActivityIcon class="mr-1 h-3.5 w-3.5" />
|
||
{{ t('fileManage.healthLabel') }}
|
||
</span>
|
||
<select
|
||
:value="params.health"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
@change="handleHealthFilterSelect"
|
||
>
|
||
<option
|
||
v-for="option in healthFilterOptions"
|
||
:key="option.value"
|
||
:value="option.value"
|
||
>
|
||
{{ formatFilterOptionLabel(option) }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
|
||
<label class="space-y-1">
|
||
<span class="flex items-center text-xs font-medium" :class="[mutedTextClass]">
|
||
<ArchiveIcon class="mr-1 h-3.5 w-3.5" />
|
||
{{ t('fileManage.typeLabel') }}
|
||
</span>
|
||
<select
|
||
:value="params.type"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
@change="handleTypeFilterChange"
|
||
>
|
||
<option v-for="option in typeFilterOptions" :key="option.value" :value="option.value">
|
||
{{ option.label }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
|
||
<label class="space-y-1">
|
||
<span class="flex items-center text-xs font-medium" :class="[mutedTextClass]">
|
||
<ClockIcon class="mr-1 h-3.5 w-3.5" />
|
||
{{ t('fileManage.sortBy') }}
|
||
</span>
|
||
<select
|
||
v-model="params.sortBy"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
@change="handleSearch"
|
||
>
|
||
<option v-for="option in sortOptions" :key="option.value" :value="option.value">
|
||
{{ option.label }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
|
||
<label class="space-y-1">
|
||
<span class="flex items-center text-xs font-medium" :class="[mutedTextClass]">
|
||
<ArrowDownUpIcon class="mr-1 h-3.5 w-3.5" />
|
||
{{ t('fileManage.sortOrder') }}
|
||
</span>
|
||
<select
|
||
v-model="params.sortOrder"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
@change="handleSearch"
|
||
>
|
||
<option v-for="option in sortOrderOptions" :key="option.value" :value="option.value">
|
||
{{ option.label }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
|
||
<label class="space-y-1">
|
||
<span class="flex items-center text-xs font-medium" :class="[mutedTextClass]">
|
||
<FilterIcon class="mr-1 h-3.5 w-3.5" />
|
||
{{ t('fileManage.viewPreset') }}
|
||
</span>
|
||
<select
|
||
:value="selectedViewPresetId"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
:disabled="isViewPresetLoading"
|
||
@change="handleViewPresetChange"
|
||
>
|
||
<option value="">{{ t('fileManage.viewPresetCustom') }}</option>
|
||
<option v-for="preset in viewPresets" :key="preset.id" :value="preset.id">
|
||
{{ preset.name }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
</div>
|
||
|
||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||
<BaseButton
|
||
size="sm"
|
||
variant="secondary"
|
||
:title="t('fileManage.saveViewPreset')"
|
||
:loading="isViewPresetSaving"
|
||
@click="handleSaveViewPreset"
|
||
>
|
||
<template #icon>
|
||
<CheckIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.saveViewPreset') }}
|
||
</BaseButton>
|
||
<BaseButton
|
||
size="sm"
|
||
variant="outline"
|
||
:title="t('fileManage.updateViewPreset')"
|
||
:disabled="!canModifySelectedViewPreset"
|
||
:loading="isViewPresetSaving"
|
||
@click="updateSelectedViewPreset"
|
||
>
|
||
<template #icon>
|
||
<PencilIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.updateViewPreset') }}
|
||
</BaseButton>
|
||
<BaseButton
|
||
size="sm"
|
||
variant="danger"
|
||
:title="t('fileManage.deleteViewPreset')"
|
||
:disabled="!canModifySelectedViewPreset"
|
||
:loading="isViewPresetDeleting"
|
||
@click="deleteSelectedViewPreset"
|
||
>
|
||
<template #icon>
|
||
<TrashIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.deleteViewPreset') }}
|
||
</BaseButton>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Transition>
|
||
</section>
|
||
|
||
<section
|
||
v-if="isMobileViewport"
|
||
class="theme-2026-card mb-5 overflow-hidden rounded-[24px] shadow-md md:hidden"
|
||
>
|
||
<div class="flex items-center justify-between gap-3 border-b px-4 py-3" :class="[isDarkMode ? 'border-gray-700' : 'border-[#d9e4e6]']">
|
||
<div>
|
||
<h3 class="text-base font-semibold" :class="[primaryTextClass]">{{ t('fileManage.allFiles') }}</h3>
|
||
<p class="mt-0.5 text-xs" :class="[mutedTextClass]">{{ t('fileManage.subtitle', { count: summary.totalFiles }) }}</p>
|
||
</div>
|
||
<button
|
||
type="button"
|
||
class="fcb-action fcb-icon-action flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border"
|
||
:class="detailActionClass"
|
||
:disabled="isLoading"
|
||
:aria-label="t('fileManage.refresh')"
|
||
@click="refreshFileList"
|
||
>
|
||
<RefreshCwIcon class="h-5 w-5" :class="isLoading ? 'animate-spin' : ''" />
|
||
</button>
|
||
</div>
|
||
|
||
<div
|
||
v-if="tableData.length > 0"
|
||
class="flex min-h-14 items-center justify-between gap-3 border-b px-4 py-2 md:hidden"
|
||
:class="[isDarkMode ? 'border-gray-700 bg-[#2c3440]/70' : 'border-[#d9e4e6] bg-[#f4f8f8]']"
|
||
>
|
||
<label class="flex min-h-11 min-w-0 cursor-pointer items-center gap-3 text-sm font-medium" :class="[primaryTextClass]">
|
||
<span class="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl">
|
||
<input
|
||
type="checkbox"
|
||
class="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||
:checked="isAllCurrentPageSelected"
|
||
:disabled="isBatchActionRunning"
|
||
:indeterminate="isCurrentPagePartiallySelected"
|
||
@change="toggleCurrentPageSelection"
|
||
/>
|
||
</span>
|
||
<span class="truncate">
|
||
{{ hasSelectedFiles ? t('fileManage.selectedCount', { count: selectedCount }) : t('fileManage.selectCurrentPage') }}
|
||
</span>
|
||
</label>
|
||
<button
|
||
v-if="hasSelectedFiles"
|
||
type="button"
|
||
class="fcb-action min-h-11 shrink-0 rounded-xl px-3 text-sm font-medium"
|
||
:class="detailActionClass"
|
||
:disabled="isBatchActionRunning"
|
||
@click="clearSelection"
|
||
>
|
||
{{ t('fileManage.clearSelection') }}
|
||
</button>
|
||
</div>
|
||
|
||
<div v-if="isLoading" class="flex items-center justify-center px-4 py-10 text-sm" :class="[mutedTextClass]">
|
||
<RefreshCwIcon class="mr-2 h-4 w-4 animate-spin" />
|
||
{{ t('common.loading') }}
|
||
</div>
|
||
<div v-else-if="hasLoadError" class="px-4 py-10 text-center">
|
||
<p class="text-sm font-medium" :class="[primaryTextClass]">{{ t('fileManage.loadError') }}</p>
|
||
<BaseButton class="fcb-refresh-button mt-3" variant="secondary" @click="refreshFileList">{{ t('fileManage.refresh') }}</BaseButton>
|
||
</div>
|
||
<div v-else-if="tableData.length === 0" class="px-4 py-10 text-center text-sm" :class="[mutedTextClass]">
|
||
<p>{{ hasActiveFilters ? t('fileManage.noMatches') : t('common.noData') }}</p>
|
||
<BaseButton v-if="hasActiveFilters" class="mt-3" variant="secondary" @click="handleResetFilters">
|
||
{{ t('fileManage.resetFilters') }}
|
||
</BaseButton>
|
||
</div>
|
||
<div v-else class="divide-y" :class="[isDarkMode ? 'divide-gray-700' : 'divide-[#d9e4e6]']">
|
||
<article
|
||
v-for="file in tableData"
|
||
:key="file.id"
|
||
class="px-4 py-4"
|
||
:class="selectedFileIds.has(file.id) ? (isDarkMode ? 'bg-[#333d49]/50' : 'bg-[#e5eeee]') : ''"
|
||
>
|
||
<div class="flex items-start gap-3">
|
||
<label class="flex h-11 w-11 shrink-0 cursor-pointer items-start justify-center pt-1">
|
||
<input
|
||
type="checkbox"
|
||
class="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||
:checked="selectedFileIds.has(file.id)"
|
||
:disabled="isBatchActionRunning"
|
||
:aria-label="t('fileManage.selectFile', { name: file.displayName })"
|
||
@change="toggleFileSelection(file.id)"
|
||
/>
|
||
</label>
|
||
<button type="button" class="fcb-action fcb-content-action min-w-0 flex-1 text-left" @click="openFileDetail(file)">
|
||
<p class="line-clamp-2 break-all text-sm font-semibold leading-5" :class="[primaryTextClass]">
|
||
{{ file.displayName }}
|
||
</p>
|
||
<div class="mt-2 flex flex-wrap items-center gap-1.5">
|
||
<span
|
||
class="inline-flex items-center rounded-full px-2 py-1 text-xs font-medium"
|
||
:class="getStatusBadgeClass(file)"
|
||
>
|
||
{{ file.isExpiredFile ? t('fileManage.expired') : t('fileManage.active') }}
|
||
</span>
|
||
<span class="rounded-full px-2 py-0.5 text-xs font-medium" :class="getTypeBadgeClass(file)">
|
||
{{ getTypeLabel(file) }}
|
||
</span>
|
||
<span class="rounded-full px-2 py-0.5 text-xs font-medium" :class="getInsightBadgeClass(file.statusInsightSeverity)">
|
||
{{ file.displayHealthState }}
|
||
</span>
|
||
</div>
|
||
<div class="mt-2 flex items-center justify-between gap-2">
|
||
<DownloadCheckStatus :result="downloadStatusFor(file.id)" :dark="isDarkMode" />
|
||
<BaseButton variant="outline" size="sm" :disabled="checkingDownloads" @click="checkDownloadIds([file.id])">检测可下载状态</BaseButton>
|
||
</div>
|
||
<div class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-xs" :class="[mutedTextClass]">
|
||
<span>{{ file.code }} · {{ file.displaySize }}</span>
|
||
<span class="text-right">{{ file.displayUsage }}</span>
|
||
<span class="col-span-2">{{ file.displayExpiredAt }}</span>
|
||
</div>
|
||
</button>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
|
||
<div v-if="params.total > 0" class="border-t" :class="[isDarkMode ? 'border-gray-700' : 'border-[#d9e4e6]']">
|
||
<DataPagination
|
||
:current-page="params.page"
|
||
:page-size="params.size"
|
||
:total="params.total"
|
||
@page-change="handlePageChange"
|
||
@page-size-change="handlePageSizeChange"
|
||
/>
|
||
</div>
|
||
</section>
|
||
|
||
<aside
|
||
v-if="hasSelectedFiles"
|
||
class="pointer-events-auto fixed inset-x-0 bottom-0 z-[60] border-t px-3 pt-3 shadow-2xl backdrop-blur-xl md:hidden"
|
||
:class="isDarkMode ? 'border-[#495765] bg-[#252b34]/95' : 'border-[#c8d7da] bg-[#f2f6f5]/95'"
|
||
:style="{ paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom))', touchAction: 'manipulation' }"
|
||
:aria-label="t('fileManage.mobileBatchActions')"
|
||
>
|
||
<div class="mx-auto max-w-lg space-y-2">
|
||
<div
|
||
v-if="showMobilePolicyActions"
|
||
class="grid grid-cols-2 gap-2 rounded-2xl border p-2"
|
||
:class="isDarkMode ? 'border-[#495765] bg-[#2c3440]' : 'border-[#c8d7da] bg-white'"
|
||
>
|
||
<button
|
||
v-for="option in batchPolicyActionOptions"
|
||
:key="option.action"
|
||
type="button"
|
||
class="fcb-action min-h-11 rounded-xl border px-2 py-2 text-xs font-medium"
|
||
:class="detailActionClass"
|
||
:title="option.description"
|
||
:disabled="option.disabled || isBatchDeleting || isBatchUpdating || isBatchPolicyActionRunning"
|
||
@click="applySelectedPolicyActionAndRefreshHistory(option.action)"
|
||
>
|
||
{{ option.label }}
|
||
</button>
|
||
</div>
|
||
|
||
<div class="flex items-center justify-between gap-3 px-1">
|
||
<p class="text-sm font-semibold" :class="primaryTextClass">
|
||
{{ t('fileManage.selectedCount', { count: selectedCount }) }}
|
||
</p>
|
||
<button
|
||
type="button"
|
||
class="fcb-action min-h-11 rounded-xl px-3 text-sm font-medium"
|
||
:class="detailActionClass"
|
||
:disabled="isBatchActionRunning"
|
||
@click="clearSelection"
|
||
>
|
||
{{ t('common.cancel') }}
|
||
</button>
|
||
</div>
|
||
|
||
<div class="grid grid-cols-3 gap-2">
|
||
<button
|
||
type="button"
|
||
class="fcb-action flex min-h-12 items-center justify-center rounded-xl border px-2 text-sm font-medium"
|
||
:class="detailActionClass"
|
||
:disabled="isBatchDeleting || isBatchPolicyActionRunning"
|
||
@click="openBatchEditModal"
|
||
>
|
||
<ClockIcon class="mr-1.5 h-4 w-4" aria-hidden="true" />
|
||
<span>{{ t('common.edit') }}</span>
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="fcb-action flex min-h-12 items-center justify-center rounded-xl border px-2 text-sm font-medium"
|
||
:class="detailActionClass"
|
||
:aria-expanded="showMobilePolicyActions"
|
||
:disabled="isBatchDeleting || isBatchUpdating"
|
||
@click="showMobilePolicyActions = !showMobilePolicyActions"
|
||
>
|
||
<TimerResetIcon class="mr-1.5 h-4 w-4" aria-hidden="true" />
|
||
{{ t('fileManage.policyActionsLabel') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="fcb-action flex min-h-12 items-center justify-center rounded-xl bg-red-600 px-2 text-sm font-medium text-white shadow-sm disabled:opacity-50"
|
||
:disabled="isBatchUpdating || isBatchPolicyActionRunning || isBatchDeleting"
|
||
@click="deleteSelectedFilesAndRefreshHistory"
|
||
>
|
||
<TrashIcon class="mr-1.5 h-4 w-4" aria-hidden="true" />
|
||
{{ t('common.delete') }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
<div v-if="!isMobileViewport" class="hidden md:block">
|
||
<DataTable :title="t('fileManage.allFiles')" :headers="fileTableHeaders" table-class="min-w-[1120px]">
|
||
<template #actions>
|
||
<BaseButton class="fcb-refresh-button" variant="secondary" :loading="isLoading" @click="refreshFileList">
|
||
<template #icon>
|
||
<RefreshCwIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.refresh') }}
|
||
</BaseButton>
|
||
</template>
|
||
<template #toolbar>
|
||
<div
|
||
v-if="tableData.length > 0"
|
||
class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||
>
|
||
<label class="inline-flex min-h-11 cursor-pointer items-center gap-2 text-sm sm:min-h-0" :class="[primaryTextClass]">
|
||
<input
|
||
type="checkbox"
|
||
class="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||
:checked="isAllCurrentPageSelected"
|
||
:disabled="isBatchActionRunning"
|
||
:indeterminate="isCurrentPagePartiallySelected"
|
||
@change="toggleCurrentPageSelection"
|
||
/>
|
||
<span>
|
||
{{
|
||
hasSelectedFiles
|
||
? t('fileManage.selectedCount', { count: selectedCount })
|
||
: t('fileManage.selectCurrentPage')
|
||
}}
|
||
</span>
|
||
</label>
|
||
|
||
<div v-if="hasSelectedFiles" class="flex flex-wrap items-center gap-2">
|
||
<BaseButton
|
||
v-if="hasSelectedFiles"
|
||
variant="outline"
|
||
size="sm"
|
||
:disabled="isBatchActionRunning"
|
||
@click="clearSelection"
|
||
>
|
||
<template #icon>
|
||
<XIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.clearSelection') }}
|
||
</BaseButton>
|
||
<BaseButton
|
||
v-for="option in batchPolicyActionOptions"
|
||
:key="option.action"
|
||
variant="outline"
|
||
size="sm"
|
||
:title="option.description"
|
||
:disabled="option.disabled || !hasSelectedFiles || isBatchDeleting || isBatchUpdating"
|
||
:loading="isBatchPolicyActionRunning"
|
||
@click="applySelectedPolicyActionAndRefreshHistory(option.action)"
|
||
>
|
||
<template #icon>
|
||
<component :is="getDetailPolicyActionIcon(option.action)" class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ option.label }}
|
||
</BaseButton>
|
||
<BaseButton
|
||
variant="secondary"
|
||
size="sm"
|
||
:disabled="!hasSelectedFiles || isBatchDeleting || isBatchPolicyActionRunning"
|
||
:loading="isBatchUpdating"
|
||
@click="openBatchEditModal"
|
||
>
|
||
<template #icon>
|
||
<ClockIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.batchEdit') }}
|
||
</BaseButton>
|
||
<BaseButton
|
||
variant="danger"
|
||
size="sm"
|
||
:disabled="!hasSelectedFiles || isBatchUpdating || isBatchPolicyActionRunning"
|
||
:loading="isBatchDeleting"
|
||
@click="deleteSelectedFilesAndRefreshHistory"
|
||
>
|
||
<template #icon>
|
||
<TrashIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.batchDelete') }}
|
||
</BaseButton>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<template #body>
|
||
<tr v-if="isLoading">
|
||
<td :colspan="fileTableHeaders.length" class="px-6 py-12 text-center">
|
||
<div class="inline-flex items-center text-sm" :class="[mutedTextClass]">
|
||
<RefreshCwIcon class="mr-2 h-4 w-4 animate-spin" />
|
||
{{ t('common.loading') }}
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr v-else-if="hasLoadError">
|
||
<td :colspan="fileTableHeaders.length" class="px-6 py-12 text-center">
|
||
<div class="mx-auto max-w-sm">
|
||
<p class="font-medium" :class="[primaryTextClass]">
|
||
{{ t('fileManage.loadError') }}
|
||
</p>
|
||
<BaseButton class="fcb-refresh-button mt-4" variant="secondary" @click="refreshFileList">
|
||
<template #icon>
|
||
<RefreshCwIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.refresh') }}
|
||
</BaseButton>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr v-else-if="tableData.length === 0">
|
||
<td :colspan="fileTableHeaders.length" class="px-6 py-12 text-center">
|
||
<div class="mx-auto max-w-sm">
|
||
<p class="font-medium" :class="[primaryTextClass]">
|
||
{{ hasActiveFilters ? t('fileManage.noMatches') : t('common.noData') }}
|
||
</p>
|
||
<BaseButton
|
||
v-if="hasActiveFilters"
|
||
class="mt-4"
|
||
variant="secondary"
|
||
@click="handleResetFilters"
|
||
>
|
||
<template #icon>
|
||
<XIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.resetFilters') }}
|
||
</BaseButton>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<template v-else>
|
||
<tr
|
||
v-for="file in tableData"
|
||
:key="file.id"
|
||
class="fcb-list-row transition-colors duration-300"
|
||
:class="[
|
||
selectedFileIds.has(file.id)
|
||
? isDarkMode
|
||
? 'is-selected-dark'
|
||
: 'is-selected'
|
||
: '',
|
||
file.isExpiredFile ? 'is-muted' : ''
|
||
]"
|
||
>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<input
|
||
type="checkbox"
|
||
class="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||
:checked="selectedFileIds.has(file.id)"
|
||
:disabled="isBatchActionRunning"
|
||
:aria-label="t('fileManage.selectFile', { name: file.displayName })"
|
||
@change="toggleFileSelection(file.id)"
|
||
/>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<span class="font-medium select-all" :class="[primaryTextClass]">
|
||
{{ file.code }}
|
||
</span>
|
||
</td>
|
||
<td class="px-6 py-4">
|
||
<div class="flex min-w-0 items-center gap-3">
|
||
<div class="rounded-[22px] p-2" :class="[isDarkMode ? 'bg-gray-700' : 'bg-gray-100']">
|
||
<FileTextIcon v-if="file.isTextFile" class="h-4 w-4" :class="[mutedTextClass]" />
|
||
<FileIcon v-else class="h-4 w-4" :class="[mutedTextClass]" />
|
||
</div>
|
||
<div class="min-w-0">
|
||
<p class="truncate text-sm font-medium" :class="[primaryTextClass]">
|
||
{{ file.displayName }}
|
||
</p>
|
||
<p class="mt-0.5 truncate text-xs" :class="[mutedTextClass]">
|
||
{{ file.suffix || t('fileManage.textType') }}
|
||
</p>
|
||
<div class="mt-2 flex max-w-sm flex-wrap items-center gap-1.5">
|
||
<span
|
||
class="inline-flex max-w-full items-center rounded-full px-2 py-0.5 text-xs font-medium"
|
||
:class="getInsightBadgeClass(file.statusInsightSeverity)"
|
||
>
|
||
{{ file.displayHealthState }}
|
||
</span>
|
||
<span
|
||
class="inline-flex max-w-full items-center rounded-full px-2 py-0.5 text-xs font-medium"
|
||
:class="getInsightActionBadgeClass(file.statusInsightNextAction)"
|
||
>
|
||
{{ file.displayHealthAction }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<span
|
||
class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium"
|
||
:class="getTypeBadgeClass(file)"
|
||
>
|
||
{{ getTypeLabel(file) }}
|
||
</span>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<span
|
||
class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium"
|
||
:class="[isDarkMode ? 'bg-gray-700 text-gray-300' : 'bg-gray-100 text-gray-800']"
|
||
>
|
||
{{ file.displaySize }}
|
||
</span>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<div class="text-sm" :class="[primaryTextClass]">{{ file.displayUsage }}</div>
|
||
<div class="mt-0.5 text-xs" :class="[mutedTextClass]">
|
||
{{
|
||
file.remainingDownloadsValue === null
|
||
? t('fileManage.unlimited')
|
||
: t('fileManage.remaining', { count: file.remainingDownloadsValue })
|
||
}}
|
||
</div>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<span class="text-sm" :class="[primaryTextClass]">
|
||
{{ file.displayExpiredAt }}
|
||
</span>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap">
|
||
<span
|
||
class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium"
|
||
:class="getStatusBadgeClass(file)"
|
||
>
|
||
{{ file.isExpiredFile ? t('fileManage.expired') : t('fileManage.active') }}
|
||
</span>
|
||
</td>
|
||
<td class="px-6 py-4" :class="primaryTextClass">
|
||
<div class="flex items-center gap-2">
|
||
<DownloadCheckStatus :result="downloadStatusFor(file.id)" :dark="isDarkMode" />
|
||
<BaseButton variant="outline" size="sm" :disabled="checkingDownloads" @click="checkDownloadIds([file.id])">检测可下载状态</BaseButton>
|
||
</div>
|
||
</td>
|
||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||
<div class="flex items-center justify-end gap-2">
|
||
<button
|
||
type="button"
|
||
:title="t('fileManage.detail')"
|
||
class="fcb-action inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-[#333d49]/70 text-[#b8d4dc] hover:bg-[#34515a]'
|
||
: 'bg-[#dcebed] text-[#3f6a77] hover:bg-[#cfe1e4]'
|
||
]"
|
||
@click="openFileDetail(file)"
|
||
>
|
||
<FileTextIcon class="mr-1.5 h-4 w-4" />
|
||
{{ t('fileManage.detail') }}
|
||
</button>
|
||
<button
|
||
v-if="file.canPreviewText"
|
||
type="button"
|
||
:title="t('fileManage.viewText')"
|
||
class="fcb-action inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-[#2c3440] text-[#d8e3e5] hover:bg-[#384452]'
|
||
: 'bg-[#edf4f5] text-[#506972] hover:bg-[#e2ecee]'
|
||
]"
|
||
@click="openTextPreview(file)"
|
||
>
|
||
<EyeIcon class="mr-1.5 h-4 w-4" />
|
||
{{ t('fileManage.viewText') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
:title="
|
||
file.isTextFile ? t('fileManage.exportText') : t('fileManage.downloadFile')
|
||
"
|
||
:disabled="Boolean(downloadingFileId)"
|
||
class="fcb-action inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-[#31564f]/70 text-[#c4dfd5] hover:bg-[#3c675e]'
|
||
: 'bg-[#e1eee8] text-[#55796e] hover:bg-[#d4e5dd]'
|
||
]"
|
||
@click="downloadFile(file)"
|
||
>
|
||
<RefreshCwIcon
|
||
v-if="downloadingFileId === file.id"
|
||
class="mr-1.5 h-4 w-4 animate-spin"
|
||
/>
|
||
<DownloadIcon v-else class="mr-1.5 h-4 w-4" />
|
||
{{ file.isTextFile ? t('fileManage.exportText') : t('fileManage.downloadFile') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="fcb-action inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-[#2d4851]/70 text-[#bfd9df] hover:bg-[#365862]'
|
||
: 'bg-[#dce8eb] text-[#4b7380] hover:bg-[#cfdee2]'
|
||
]"
|
||
@click="openEditModal(file)"
|
||
>
|
||
<PencilIcon class="mr-1.5 h-4 w-4" />
|
||
{{ t('common.edit') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="fcb-action inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
|
||
:class="[
|
||
'fcb-button-danger'
|
||
]"
|
||
@click="deleteFileAndRefreshHistory(file.id)"
|
||
>
|
||
<TrashIcon class="mr-1.5 h-4 w-4" />
|
||
{{ t('common.delete') }}
|
||
</button>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</template>
|
||
</template>
|
||
<template #footer>
|
||
<DataPagination
|
||
v-if="params.total > 0"
|
||
:current-page="params.page"
|
||
:page-size="params.size"
|
||
:total="params.total"
|
||
@page-change="handlePageChange"
|
||
@page-size-change="handlePageSizeChange"
|
||
/>
|
||
</template>
|
||
</DataTable>
|
||
</div>
|
||
|
||
<section
|
||
class="theme-2026-card mt-6 rounded-[30px] border p-4 shadow-md transition-all duration-200 hover:shadow-lg"
|
||
:class="[panelClass, cardHoverClass]"
|
||
>
|
||
<div class="mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||
<div>
|
||
<h3 class="text-lg font-semibold" :class="[primaryTextClass]">历史文件</h3>
|
||
<p class="text-sm" :class="[mutedTextClass]">包含已删除、已过期和现存文件的下载统计</p>
|
||
</div>
|
||
<BaseButton class="fcb-refresh-button" variant="secondary" :loading="isHistoryLoading" @click="loadHistoryFiles">
|
||
<template #icon>
|
||
<RefreshCwIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
刷新历史
|
||
</BaseButton>
|
||
</div>
|
||
<div class="overflow-x-auto" tabindex="0" role="region" :aria-label="t('fileManage.history.title')">
|
||
<table
|
||
v-resizable-columns
|
||
class="min-w-full divide-y"
|
||
:class="[isDarkMode ? 'divide-gray-700' : 'divide-gray-200']"
|
||
>
|
||
<thead>
|
||
<tr>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
文件
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
大小
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
取件码
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
上传时间
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
过期时间
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
下载
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
流量
|
||
</th>
|
||
<th
|
||
class="px-4 py-3 text-center text-xs font-semibold uppercase"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
状态
|
||
</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y" :class="[isDarkMode ? 'divide-gray-700' : 'divide-gray-100']">
|
||
<tr v-if="isHistoryLoading">
|
||
<td colspan="8" class="px-4 py-8 text-center text-sm" :class="[mutedTextClass]">
|
||
<RefreshCwIcon class="mr-2 inline h-4 w-4 animate-spin" />
|
||
{{ t('common.loading') }}
|
||
</td>
|
||
</tr>
|
||
<tr v-else-if="historyPageRows.length === 0">
|
||
<td colspan="8" class="px-4 py-8 text-center text-sm" :class="[mutedTextClass]">
|
||
暂无历史文件
|
||
</td>
|
||
</tr>
|
||
<template v-else>
|
||
<tr
|
||
v-for="file in historyPageRows"
|
||
:key="file.code"
|
||
class="fcb-list-row"
|
||
:class="[
|
||
file.current ? '' : 'opacity-70',
|
||
]"
|
||
>
|
||
<td
|
||
class="max-w-xs truncate px-4 py-3 text-sm font-medium"
|
||
:class="[primaryTextClass]"
|
||
:title="file.name"
|
||
>
|
||
{{ file.name }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm" :class="[primaryTextClass]">
|
||
{{ formatHistoryBytes(file.size) }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm font-mono" :class="[primaryTextClass]">
|
||
{{ file.code }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm" :class="[mutedTextClass]">
|
||
{{ formatHistoryDate(file.uploaded_at || file.created_at) }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm" :class="[mutedTextClass]">
|
||
{{ formatHistoryDate(file.expired_at) }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm" :class="[primaryTextClass]">
|
||
{{ file.download_count || 0 }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm" :class="[primaryTextClass]">
|
||
{{ formatHistoryBytes(file.download_traffic) }}
|
||
</td>
|
||
<td class="px-4 py-3 text-sm" :class="[mutedTextClass]">
|
||
{{ getHistoryStatusLabel(file) }}
|
||
</td>
|
||
</tr>
|
||
</template>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<DataPagination
|
||
v-if="historyRows.length > 0"
|
||
:current-page="historyPage"
|
||
:page-size="historyPageSize"
|
||
:total="historyRows.length"
|
||
:page-size-options="[5, 10, 20, 50, 100]"
|
||
@page-change="historyPage = $event"
|
||
@page-size-change="handleHistoryPageSizeChange"
|
||
/>
|
||
</section>
|
||
|
||
<BaseModal :show="showFileDetailModal" size="xl" @close="closeFileDetail">
|
||
<template #header>
|
||
<div class="flex min-w-0 items-center space-x-3">
|
||
<div class="rounded-lg p-2" :class="[isDarkMode ? 'bg-indigo-500/10' : 'bg-indigo-50']">
|
||
<FileTextIcon
|
||
class="h-5 w-5"
|
||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||
/>
|
||
</div>
|
||
<div class="min-w-0">
|
||
<h3
|
||
class="truncate text-xl font-semibold leading-6"
|
||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||
>
|
||
{{ t('fileManage.detailTitle') }}
|
||
</h3>
|
||
<p v-if="selectedFileDetail" class="mt-1 truncate text-sm" :class="[mutedTextClass]">
|
||
{{ selectedFileDetail.displayName }}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<div v-if="selectedFileDetail" class="space-y-2.5 sm:space-y-4">
|
||
<div class="flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between">
|
||
<div class="flex min-w-0 items-start gap-2.5">
|
||
<div
|
||
class="rounded-lg p-2.5"
|
||
:class="[isDarkMode ? 'bg-gray-700 text-gray-300' : 'bg-gray-100 text-gray-700']"
|
||
>
|
||
<FileTextIcon v-if="selectedFileDetail.isTextFile" class="h-4.5 w-4.5" />
|
||
<FileIcon v-else class="h-4.5 w-4.5" />
|
||
</div>
|
||
<div class="min-w-0">
|
||
<h4 class="break-words text-base font-semibold leading-5 sm:text-lg" :class="[primaryTextClass]">
|
||
{{ selectedFileDetail.displayName }}
|
||
</h4>
|
||
<div class="mt-1.5 flex flex-wrap items-center gap-1.5">
|
||
<span
|
||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||
:class="getTypeBadgeClass(selectedFileDetail)"
|
||
>
|
||
{{ getTypeLabel(selectedFileDetail) }}
|
||
</span>
|
||
<span
|
||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||
:class="getStatusBadgeClass(selectedFileDetail)"
|
||
>
|
||
{{
|
||
selectedFileDetail.isExpiredFile
|
||
? t('fileManage.expired')
|
||
: t('fileManage.active')
|
||
}}
|
||
</span>
|
||
<span
|
||
v-if="selectedFileDetail.isPermanentFile"
|
||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||
:class="
|
||
isDarkMode
|
||
? 'bg-emerald-900/30 text-emerald-300'
|
||
: 'bg-emerald-100 text-emerald-700'
|
||
"
|
||
>
|
||
{{ t('fileManage.permanent') }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div
|
||
v-if="isDetailLoading"
|
||
class="inline-flex items-center text-sm"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
<RefreshCwIcon class="mr-2 h-4 w-4 animate-spin" />
|
||
{{ t('fileManage.detailLoading') }}
|
||
</div>
|
||
</div>
|
||
|
||
<div
|
||
class="theme-2026-card-hover rounded-[24px] border px-3 py-2.5 shadow-md transition-all duration-200 hover:shadow-lg sm:px-4 sm:py-3"
|
||
:class="[isDarkMode ? 'border-gray-700 bg-gray-700/30' : 'border-gray-200 bg-gray-50']"
|
||
>
|
||
<div class="grid gap-2.5 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center">
|
||
<div class="min-w-0">
|
||
<p class="text-[11px] font-medium uppercase leading-4" :class="[mutedTextClass]">
|
||
{{ t('fileManage.form.code') }}
|
||
</p>
|
||
<p class="mt-1 select-all text-base font-semibold leading-5" :class="[primaryTextClass]">
|
||
{{ selectedFileDetail.code }}
|
||
</p>
|
||
<p class="mt-0.5 truncate text-xs leading-4" :class="[mutedTextClass]">
|
||
{{ selectedFileDetail.displayRetrieveUrl }}
|
||
</p>
|
||
</div>
|
||
<div class="flex flex-wrap items-center gap-2">
|
||
<BaseButton size="sm" variant="secondary" @click="copyDetailRetrieveCode">
|
||
<template #icon>
|
||
<CopyIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.copyCode') }}
|
||
</BaseButton>
|
||
<BaseButton size="sm" variant="secondary" @click="copyDetailRetrieveLink">
|
||
<template #icon>
|
||
<CopyIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.copyLink') }}
|
||
</BaseButton>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="grid grid-cols-2 gap-2.5 xl:grid-cols-4">
|
||
<button
|
||
type="button"
|
||
class="fcb-action flex min-h-11 items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60"
|
||
:class="detailActionClass"
|
||
@click="openDetailEditModal"
|
||
>
|
||
<PencilIcon class="mr-2 h-4 w-4" />
|
||
{{ t('common.edit') }}
|
||
</button>
|
||
<button
|
||
v-if="selectedFileDetail.canPreviewText"
|
||
type="button"
|
||
class="fcb-action flex min-h-11 items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors"
|
||
:class="detailActionClass"
|
||
@click="openDetailTextPreview"
|
||
>
|
||
<EyeIcon class="mr-2 h-4 w-4" />
|
||
{{ t('fileManage.viewText') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="fcb-action flex min-h-11 items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60"
|
||
:class="detailActionClass"
|
||
:disabled="!selectedFileDetail.canDownloadFile || Boolean(downloadingFileId)"
|
||
@click="downloadFile(selectedFileDetail)"
|
||
>
|
||
<RefreshCwIcon
|
||
v-if="downloadingFileId === selectedFileDetail.id"
|
||
class="mr-2 h-4 w-4 animate-spin"
|
||
/>
|
||
<DownloadIcon v-else class="mr-2 h-4 w-4" />
|
||
{{
|
||
selectedFileDetail.isTextFile
|
||
? t('fileManage.exportText')
|
||
: t('fileManage.downloadFile')
|
||
}}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="fcb-action flex min-h-11 items-center justify-center rounded-lg bg-red-600 px-3 py-2 text-sm font-medium text-white shadow-sm transition-colors hover:bg-red-700"
|
||
@click="deleteDetailFileAndRefreshHistory"
|
||
>
|
||
<TrashIcon class="mr-2 h-4 w-4" aria-hidden="true" />
|
||
{{ t('common.delete') }}
|
||
</button>
|
||
</div>
|
||
|
||
<section
|
||
class="theme-2026-card rounded-[24px] border px-3 py-3 shadow-md transition-all duration-200 hover:shadow-lg sm:px-4 sm:py-4"
|
||
:class="getInsightPanelClass(selectedFileDetail.statusInsightSeverity)"
|
||
>
|
||
<div class="flex flex-col gap-2.5 md:flex-row md:items-start md:justify-between">
|
||
<div class="min-w-0">
|
||
<p class="text-[11px] font-medium uppercase leading-4" :class="[mutedTextClass]">
|
||
{{ t('fileManage.statusInsight') }}
|
||
</p>
|
||
<h4 class="mt-1 text-sm font-semibold sm:text-base" :class="[primaryTextClass]">
|
||
{{ getInsightStateLabel(selectedFileDetail.statusInsightState) }}
|
||
</h4>
|
||
</div>
|
||
<div class="flex flex-wrap items-center gap-1.5">
|
||
<span
|
||
class="inline-flex w-fit items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||
:class="getInsightBadgeClass(selectedFileDetail.statusInsightSeverity)"
|
||
>
|
||
{{ getInsightSeverityLabel(selectedFileDetail.statusInsightSeverity) }}
|
||
</span>
|
||
<span
|
||
class="inline-flex w-fit items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||
:class="getInsightActionBadgeClass(selectedFileDetail.statusInsightNextAction)"
|
||
>
|
||
{{ selectedFileDetail.displayHealthAction }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="detailInsightReasonLabels.length > 0" class="mt-2.5 flex flex-wrap gap-1.5">
|
||
<span
|
||
v-for="reason in detailInsightReasonLabels"
|
||
:key="reason"
|
||
class="rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||
:class="isDarkMode ? 'bg-gray-700 text-gray-300' : 'bg-white text-gray-600 shadow-sm'"
|
||
>
|
||
{{ reason }}
|
||
</span>
|
||
</div>
|
||
|
||
<div class="mt-3 grid gap-1.5 sm:grid-cols-2 xl:grid-cols-4">
|
||
<button
|
||
v-for="action in detailPolicyActionOptions"
|
||
:key="action.action"
|
||
type="button"
|
||
class="theme-2026-card-hover flex min-h-14 items-start gap-2 rounded-[22px] border px-3 py-2 text-left shadow-md transition-all duration-200 hover:shadow-lg disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:shadow-md"
|
||
:class="[detailPolicyActionClass, cardHoverClass]"
|
||
:disabled="isDetailPolicyActionRunning || isDetailLoading || action.disabled"
|
||
:title="action.description"
|
||
@click="applyDetailPolicyActionAndRefreshHistory(action.action)"
|
||
>
|
||
<RefreshCwIcon
|
||
v-if="isDetailPolicyActionRunning"
|
||
class="mt-0.5 h-4 w-4 shrink-0 animate-spin"
|
||
/>
|
||
<component
|
||
:is="getDetailPolicyActionIcon(action.action)"
|
||
v-else
|
||
class="mt-0.5 h-4 w-4 shrink-0"
|
||
/>
|
||
<span class="min-w-0">
|
||
<span class="block text-sm font-medium">{{ action.label }}</span>
|
||
<span class="mt-0.5 block text-xs leading-4" :class="[mutedTextClass]">
|
||
{{ action.description }}
|
||
</span>
|
||
</span>
|
||
</button>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="space-y-2.5">
|
||
<h4 class="text-sm font-semibold" :class="[primaryTextClass]">
|
||
{{ t('fileManage.overview') }}
|
||
</h4>
|
||
<div class="grid grid-cols-2 gap-2.5 xl:grid-cols-3">
|
||
<div
|
||
v-for="item in detailOverviewItems"
|
||
:key="item.label"
|
||
class="theme-2026-card-hover rounded-[18px] border px-3 py-2 shadow-md transition-all duration-200 hover:shadow-lg sm:rounded-[22px] sm:px-3.5 sm:py-2.5"
|
||
:class="[isDarkMode ? 'border-gray-700 bg-gray-700/30' : 'border-gray-200 bg-white']"
|
||
>
|
||
<p class="text-xs leading-4" :class="[mutedTextClass]">{{ item.label }}</p>
|
||
<p class="mt-0.5 break-words text-sm font-medium leading-5" :class="[primaryTextClass]">
|
||
{{ item.value }}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="space-y-2.5">
|
||
<h4 class="text-sm font-semibold" :class="[primaryTextClass]">
|
||
{{ t('fileManage.policyInfo') }}
|
||
</h4>
|
||
<div class="grid grid-cols-2 gap-2.5 xl:grid-cols-3">
|
||
<div
|
||
v-for="item in detailPolicyItems"
|
||
:key="item.label"
|
||
class="theme-2026-card-hover rounded-[18px] border px-3 py-2 shadow-md transition-all duration-200 hover:shadow-lg sm:rounded-[22px] sm:px-3.5 sm:py-2.5"
|
||
:class="[isDarkMode ? 'border-gray-700 bg-gray-700/30' : 'border-gray-200 bg-white']"
|
||
>
|
||
<p class="text-xs leading-4" :class="[mutedTextClass]">{{ item.label }}</p>
|
||
<p class="mt-0.5 break-words text-sm font-medium leading-5" :class="[primaryTextClass]">
|
||
{{ item.value }}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section v-if="selectedFileDetail.detailTimeline.length > 0" class="space-y-2.5">
|
||
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||
<h4 class="text-sm font-semibold" :class="[primaryTextClass]">
|
||
{{ t('fileManage.lifecycle') }}
|
||
</h4>
|
||
<button
|
||
v-if="detailTimelineRows.length > 3"
|
||
type="button"
|
||
class="fcb-action inline-flex min-h-10 items-center self-start rounded-[30px] border px-3 py-2 text-sm font-medium transition-colors sm:min-h-0 sm:self-auto"
|
||
:class="detailActionClass"
|
||
@click="isLifecycleExpanded = !isLifecycleExpanded"
|
||
>
|
||
{{
|
||
isLifecycleExpanded
|
||
? t('fileManage.collapseLifecycle')
|
||
: t('fileManage.expandLifecycle', {
|
||
count: detailTimelineRows.length
|
||
})
|
||
}}
|
||
</button>
|
||
</div>
|
||
<div
|
||
class="rounded-[24px] border px-3 py-3 shadow-md sm:px-4 sm:py-4"
|
||
:class="[isDarkMode ? 'border-gray-700 bg-gray-700/30' : 'border-gray-200 bg-white']"
|
||
>
|
||
<div ref="lifecycleViewportRef" class="fcb-lifecycle-viewport">
|
||
<TransitionGroup
|
||
:css="false"
|
||
tag="div"
|
||
class="fcb-lifecycle-list"
|
||
@before-enter="beforeLifecycleRowEnter"
|
||
@enter="enterLifecycleRow"
|
||
@leave="leaveLifecycleRow"
|
||
>
|
||
<template v-for="(item, index) in visibleDetailTimeline" :key="`${item.key}-${index}`">
|
||
<div class="fcb-lifecycle-row grid grid-cols-[auto_minmax(0,1fr)] gap-3">
|
||
<div class="flex flex-col items-center">
|
||
<span
|
||
class="mt-1 h-3 w-3 rounded-full"
|
||
:class="getTimelineDotClass(item.severity)"
|
||
/>
|
||
<span
|
||
v-if="index < visibleDetailTimeline.length - 1"
|
||
class="my-1 w-px flex-1"
|
||
:class="[isDarkMode ? 'bg-gray-600' : 'bg-gray-200']"
|
||
/>
|
||
</div>
|
||
<div
|
||
class="fcb-lifecycle-card theme-2026-card-hover rounded-[16px] border px-3 py-2 shadow-sm transition-all duration-200 hover:shadow-md sm:rounded-[20px]"
|
||
:class="[
|
||
isDarkMode ? 'border-gray-700 bg-gray-800/60' : 'border-gray-100 bg-gray-50'
|
||
]"
|
||
>
|
||
<div class="flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between">
|
||
<p class="text-sm font-medium" :class="[primaryTextClass]">
|
||
{{ item.displayTitle }}
|
||
</p>
|
||
<p class="text-xs" :class="[mutedTextClass]">
|
||
{{ item.displayMeta }}
|
||
</p>
|
||
</div>
|
||
<p class="mt-1 text-sm leading-5" :class="[mutedTextClass]">
|
||
{{ item.displayDescription }}
|
||
</p>
|
||
<div v-if="item.key === 'retrieved' && retrievalTimelineCount > 0" class="mt-2.5 border-t pt-2.5" :class="isDarkMode ? 'border-gray-700' : 'border-gray-200'">
|
||
<button
|
||
type="button"
|
||
class="fcb-action inline-flex min-h-9 items-center rounded-[30px] border px-3 py-1.5 text-sm font-medium transition-colors"
|
||
:class="detailActionClass"
|
||
@click="isRetrievalHistoryExpanded = !isRetrievalHistoryExpanded"
|
||
>
|
||
{{
|
||
isRetrievalHistoryExpanded
|
||
? t('fileManage.collapseRetrievalHistory')
|
||
: t('fileManage.expandRetrievalHistory', { count: retrievalTimelineCount })
|
||
}}
|
||
</button>
|
||
<Transition
|
||
:css="false"
|
||
@before-enter="beforeRetrievalPanelEnter"
|
||
@enter="enterRetrievalPanel"
|
||
@after-enter="afterRetrievalPanelEnter"
|
||
@before-leave="beforeRetrievalPanelLeave"
|
||
@leave="leaveRetrievalPanel"
|
||
>
|
||
<div v-show="isRetrievalHistoryExpanded" class="fcb-retrieval-panel">
|
||
<div class="space-y-1.5 pt-2.5">
|
||
<div
|
||
v-for="(event, eventIndex) in retrievalTimelineEvents"
|
||
:key="`${event.key}-${eventIndex}-${event.displayMeta}`"
|
||
class="rounded-[14px] border px-2.5 py-1.5 text-xs sm:text-sm"
|
||
:class="isDarkMode ? 'border-gray-700 bg-gray-900/40' : 'border-gray-200 bg-white/70'"
|
||
>
|
||
<div class="flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between">
|
||
<p class="font-medium" :class="primaryTextClass">{{ event.displayTitle }}</p>
|
||
<p class="text-xs" :class="mutedTextClass">{{ event.displayMeta }}</p>
|
||
</div>
|
||
<p class="mt-1 leading-5" :class="mutedTextClass">{{ event.displayDescription }}</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Transition>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</TransitionGroup>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section
|
||
class="theme-2026-card space-y-2.5 rounded-[24px] border px-3 py-3 shadow-md transition-all duration-200 hover:shadow-lg sm:px-4 sm:py-4"
|
||
:class="[subtleSectionClass, cardHoverClass]"
|
||
>
|
||
<div class="flex flex-col gap-2.5 sm:flex-row sm:items-start sm:justify-between">
|
||
<div>
|
||
<h4 class="text-sm font-semibold" :class="[primaryTextClass]">
|
||
{{ t('fileManage.metadataInfo') }}
|
||
</h4>
|
||
<p class="mt-1 text-xs" :class="[mutedTextClass]">
|
||
{{ t('fileManage.metadataHint') }}
|
||
</p>
|
||
</div>
|
||
<BaseButton
|
||
size="sm"
|
||
:loading="isDetailMetadataSaving"
|
||
:disabled="isDetailLoading"
|
||
@click="updateDetailMetadata"
|
||
>
|
||
<template #icon>
|
||
<CheckIcon class="mr-2 h-4 w-4" />
|
||
</template>
|
||
{{ t('fileManage.saveMetadata') }}
|
||
</BaseButton>
|
||
</div>
|
||
|
||
<div class="grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(220px,0.55fr)]">
|
||
<label class="space-y-1">
|
||
<span class="text-xs font-medium" :class="[mutedTextClass]">
|
||
{{ t('fileManage.metadataNote') }}
|
||
</span>
|
||
<textarea
|
||
v-model="detailMetadataForm.note"
|
||
rows="3"
|
||
maxlength="2000"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
:placeholder="t('fileManage.metadataNotePlaceholder')"
|
||
></textarea>
|
||
</label>
|
||
<label class="space-y-1">
|
||
<span class="text-xs font-medium" :class="[mutedTextClass]">
|
||
{{ t('fileManage.metadataTags') }}
|
||
</span>
|
||
<input
|
||
v-model="detailMetadataForm.tagsText"
|
||
type="text"
|
||
class="min-h-11 w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-indigo-500"
|
||
:class="[fieldClass]"
|
||
:placeholder="t('fileManage.metadataTagsPlaceholder')"
|
||
/>
|
||
<span class="block text-xs" :class="[mutedTextClass]">
|
||
{{
|
||
selectedFileDetail.metadataUpdatedAt
|
||
? t('fileManage.metadataUpdatedAt', {
|
||
time: formatMetadataUpdatedAt(selectedFileDetail.metadataUpdatedAt)
|
||
})
|
||
: t('fileManage.metadataNeverUpdated')
|
||
}}
|
||
</span>
|
||
</label>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="space-y-2.5">
|
||
<h4 class="text-sm font-semibold" :class="[primaryTextClass]">
|
||
{{ t('fileManage.storageInfo') }}
|
||
</h4>
|
||
<div class="grid gap-2.5">
|
||
<div
|
||
v-for="item in detailStorageItems"
|
||
:key="item.label"
|
||
class="theme-2026-card-hover grid gap-1 rounded-[22px] border px-3 py-2.5 shadow-md transition-all duration-200 hover:shadow-lg sm:grid-cols-[160px_minmax(0,1fr)] sm:items-center"
|
||
:class="[isDarkMode ? 'border-gray-700 bg-gray-700/30' : 'border-gray-200 bg-white']"
|
||
>
|
||
<p class="text-xs leading-4" :class="[mutedTextClass]">{{ item.label }}</p>
|
||
<p
|
||
class="break-all text-sm font-medium leading-5"
|
||
:class="[item.mono ? 'font-mono' : '', primaryTextClass]"
|
||
>
|
||
{{ item.value }}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<div
|
||
v-else
|
||
class="flex min-h-32 items-center justify-center text-sm"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
<RefreshCwIcon class="mr-2 h-4 w-4 animate-spin" />
|
||
{{ t('fileManage.detailLoading') }}
|
||
</div>
|
||
|
||
<template #footer>
|
||
<BaseButton variant="secondary" @click="closeFileDetail">
|
||
{{ t('common.close') }}
|
||
</BaseButton>
|
||
</template>
|
||
</BaseModal>
|
||
|
||
<BaseModal :show="showEditModal" size="lg" @close="closeEditModal">
|
||
<template #header>
|
||
<div class="flex items-center space-x-3">
|
||
<div class="p-2 rounded-lg" :class="[isDarkMode ? 'bg-indigo-500/10' : 'bg-indigo-50']">
|
||
<PencilIcon
|
||
class="w-5 h-5"
|
||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||
/>
|
||
</div>
|
||
<h3
|
||
class="text-xl font-semibold leading-6"
|
||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||
>
|
||
{{ t('fileManage.editFileInfo') }}
|
||
</h3>
|
||
</div>
|
||
</template>
|
||
|
||
<div class="grid gap-6">
|
||
<FileEditField
|
||
v-model="editForm.code"
|
||
:label="t('fileManage.form.code')"
|
||
:placeholder="t('fileManage.form.codePlaceholder')"
|
||
/>
|
||
<FileEditField
|
||
v-model="editForm.prefix"
|
||
:label="t('fileManage.form.filename')"
|
||
:placeholder="t('fileManage.form.filenamePlaceholder')"
|
||
/>
|
||
<FileEditField
|
||
v-model="editForm.suffix"
|
||
:label="t('fileManage.form.suffix')"
|
||
:placeholder="t('fileManage.form.suffixPlaceholder')"
|
||
/>
|
||
<div class="space-y-2 group">
|
||
<label
|
||
class="flex items-center space-x-2 text-sm font-medium transition-colors duration-200"
|
||
:class="[
|
||
isDarkMode
|
||
? 'text-gray-300 group-focus-within:text-indigo-400'
|
||
: 'text-gray-700 group-focus-within:text-indigo-600'
|
||
]"
|
||
>
|
||
<span>{{ t('send.expiration.label') }}</span>
|
||
<div
|
||
class="h-px flex-1 transition-colors duration-200"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-gray-700 group-focus-within:bg-indigo-500/50'
|
||
: 'bg-gray-200 group-focus-within:bg-indigo-500/30'
|
||
]"
|
||
></div>
|
||
</label>
|
||
<NativeDateSelect
|
||
v-model="editForm.expired_at"
|
||
include-time
|
||
:field-class="fieldClass"
|
||
:aria-label="t('send.expiration.label')"
|
||
/>
|
||
</div>
|
||
<FileEditField
|
||
v-model="editForm.expired_count"
|
||
type="number"
|
||
:label="t('fileManage.form.downloadLimit')"
|
||
:placeholder="t('fileManage.form.downloadLimitPlaceholder')"
|
||
/>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<BaseButton variant="secondary" :disabled="isSaving" @click="closeEditModal">
|
||
{{ t('common.cancel') }}
|
||
</BaseButton>
|
||
<BaseButton :loading="isSaving" @click="handleUpdateAndRefreshHistory">
|
||
<template #icon>
|
||
<CheckIcon class="w-4 h-4 mr-2" />
|
||
</template>
|
||
{{ t('fileManage.saveChanges') }}
|
||
</BaseButton>
|
||
</template>
|
||
</BaseModal>
|
||
|
||
<BaseModal :show="showBatchEditModal" size="lg" @close="closeBatchEditModal()">
|
||
<template #header>
|
||
<div class="flex items-center space-x-3">
|
||
<div class="p-2 rounded-lg" :class="[isDarkMode ? 'bg-indigo-500/10' : 'bg-indigo-50']">
|
||
<ClockIcon
|
||
class="w-5 h-5"
|
||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||
/>
|
||
</div>
|
||
<h3
|
||
class="text-xl font-semibold leading-6"
|
||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||
>
|
||
{{ t('fileManage.batchEditTitle') }}
|
||
</h3>
|
||
</div>
|
||
</template>
|
||
|
||
<div class="space-y-5">
|
||
<div
|
||
class="rounded-[30px] border px-4 py-3 text-sm"
|
||
:class="[
|
||
isDarkMode
|
||
? 'border-indigo-500/20 bg-indigo-500/10 text-indigo-200'
|
||
: 'border-indigo-100 bg-indigo-50 text-indigo-700'
|
||
]"
|
||
>
|
||
{{ t('fileManage.batchEditSelected', { count: selectedCount }) }}
|
||
</div>
|
||
|
||
<div class="space-y-3">
|
||
<p class="text-sm font-medium" :class="[primaryTextClass]">
|
||
{{ t('fileManage.batchEditMode') }}
|
||
</p>
|
||
<div class="grid gap-2 sm:grid-cols-2 xl:grid-cols-4">
|
||
<button
|
||
v-for="option in batchEditModeOptions"
|
||
:key="option.value"
|
||
type="button"
|
||
class="fcb-action flex min-h-12 items-center justify-center rounded-[30px] border px-3 py-2 text-sm font-medium transition-colors"
|
||
:class="getBatchEditModeClass(option.value)"
|
||
:disabled="isBatchUpdating"
|
||
@click="batchEditForm.mode = option.value"
|
||
>
|
||
<component :is="option.icon" class="mr-2 h-4 w-4" />
|
||
<span>{{ option.label }}</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="batchEditForm.mode === 'expiresAt'" class="space-y-2 group">
|
||
<label
|
||
class="flex items-center space-x-2 text-sm font-medium transition-colors duration-200"
|
||
:class="[
|
||
isDarkMode
|
||
? 'text-gray-300 group-focus-within:text-indigo-400'
|
||
: 'text-gray-700 group-focus-within:text-indigo-600'
|
||
]"
|
||
>
|
||
<span>{{ t('fileManage.batchEditExpiresAt') }}</span>
|
||
<div
|
||
class="h-px flex-1 transition-colors duration-200"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-gray-700 group-focus-within:bg-indigo-500/50'
|
||
: 'bg-gray-200 group-focus-within:bg-indigo-500/30'
|
||
]"
|
||
></div>
|
||
</label>
|
||
<NativeDateSelect
|
||
v-model="batchEditForm.expired_at"
|
||
include-time
|
||
:field-class="fieldClass"
|
||
:aria-label="t('fileManage.batchEditExpiresAt')"
|
||
/>
|
||
</div>
|
||
<div v-else-if="batchEditForm.mode === 'relativeExpire'" class="grid gap-3 sm:grid-cols-[1fr_10rem]">
|
||
<FileEditField
|
||
v-model="batchEditForm.relative_expire_value"
|
||
type="number"
|
||
:label="t('fileManage.batchEditRelativeExpireValue')"
|
||
:placeholder="t('fileManage.batchEditRelativeExpirePlaceholder')"
|
||
/>
|
||
<div class="space-y-2 group">
|
||
<label
|
||
class="flex items-center space-x-2 text-sm font-medium transition-colors duration-200"
|
||
:class="[
|
||
isDarkMode
|
||
? 'text-gray-300 group-focus-within:text-indigo-400'
|
||
: 'text-gray-700 group-focus-within:text-indigo-600'
|
||
]"
|
||
>
|
||
<span>{{ t('fileManage.batchEditRelativeExpireUnit') }}</span>
|
||
<div
|
||
class="h-px flex-1 transition-colors duration-200"
|
||
:class="[
|
||
isDarkMode
|
||
? 'bg-gray-700 group-focus-within:bg-indigo-500/50'
|
||
: 'bg-gray-200 group-focus-within:bg-indigo-500/30'
|
||
]"
|
||
></div>
|
||
</label>
|
||
<select
|
||
v-model="batchEditForm.relative_expire_unit"
|
||
class="block min-h-12 w-full rounded-[30px] border px-4 py-2.5 text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2"
|
||
:class="fieldClass"
|
||
>
|
||
<option value="hours">{{ t('fileManage.batchEditRelativeExpireHours') }}</option>
|
||
<option value="days">{{ t('fileManage.batchEditRelativeExpireDays') }}</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<FileEditField
|
||
v-else-if="batchEditForm.mode === 'downloadLimit'"
|
||
v-model="batchEditForm.expired_count"
|
||
type="number"
|
||
:label="t('fileManage.batchEditDownloadLimit')"
|
||
:placeholder="t('fileManage.form.downloadLimitPlaceholder')"
|
||
/>
|
||
<div
|
||
v-else
|
||
class="rounded-[30px] border px-4 py-3 text-sm"
|
||
:class="[
|
||
isDarkMode
|
||
? 'border-gray-700 bg-gray-700/50 text-gray-300'
|
||
: 'border-gray-200 bg-gray-50 text-gray-600'
|
||
]"
|
||
>
|
||
{{ t('fileManage.batchEditForeverHint') }}
|
||
</div>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<BaseButton variant="secondary" :disabled="isBatchUpdating" @click="closeBatchEditModal()">
|
||
{{ t('common.cancel') }}
|
||
</BaseButton>
|
||
<BaseButton :loading="isBatchUpdating" @click="handleBatchUpdateAndRefreshHistory">
|
||
<template #icon>
|
||
<CheckIcon class="w-4 h-4 mr-2" />
|
||
</template>
|
||
{{ t('fileManage.applyBatchEdit') }}
|
||
</BaseButton>
|
||
</template>
|
||
</BaseModal>
|
||
|
||
<BaseModal :show="showTextPreview" size="lg" @close="closeTextPreview">
|
||
<template #header>
|
||
<div class="flex items-center space-x-3">
|
||
<div class="p-2 rounded-lg" :class="[isDarkMode ? 'bg-indigo-500/10' : 'bg-indigo-50']">
|
||
<FileTextIcon
|
||
class="w-5 h-5"
|
||
:class="[isDarkMode ? 'text-indigo-400' : 'text-indigo-600']"
|
||
/>
|
||
</div>
|
||
<h3
|
||
class="text-xl font-semibold leading-6"
|
||
:class="[isDarkMode ? 'text-white' : 'text-gray-900']"
|
||
>
|
||
{{ previewFile?.displayName || t('fileManage.textPreview') }}
|
||
</h3>
|
||
</div>
|
||
</template>
|
||
|
||
<div
|
||
class="max-h-[60vh] overflow-y-auto rounded-lg p-4 custom-scrollbar"
|
||
:class="[isDarkMode ? 'bg-gray-700/50' : 'bg-gray-50']"
|
||
>
|
||
<div
|
||
v-if="isPreviewLoading"
|
||
class="flex min-h-32 items-center justify-center text-sm"
|
||
:class="[mutedTextClass]"
|
||
>
|
||
<RefreshCwIcon class="mr-2 h-4 w-4 animate-spin" />
|
||
{{ t('fileManage.loadingPreview') }}
|
||
</div>
|
||
<pre
|
||
v-else
|
||
class="whitespace-pre-wrap break-words text-sm font-mono"
|
||
:class="[isDarkMode ? 'text-gray-200' : 'text-gray-700']"
|
||
>{{ previewText }}</pre
|
||
>
|
||
</div>
|
||
<div class="mt-2 text-xs" :class="[isDarkMode ? 'text-gray-500' : 'text-gray-400']">
|
||
{{ previewMetaText || t('fileManage.charCount', { count: previewText.length }) }}
|
||
</div>
|
||
|
||
<template #footer>
|
||
<BaseButton
|
||
variant="secondary"
|
||
:disabled="isPreviewLoading || !previewText"
|
||
@click="exportPreviewText"
|
||
>
|
||
<template #icon>
|
||
<DownloadIcon class="w-4 h-4 mr-2" />
|
||
</template>
|
||
{{ t('fileManage.exportText') }}
|
||
</BaseButton>
|
||
<BaseButton
|
||
variant="secondary"
|
||
:disabled="isPreviewLoading || !previewText"
|
||
@click="copyText"
|
||
>
|
||
<template #icon>
|
||
<CopyIcon class="w-4 h-4 mr-2" />
|
||
</template>
|
||
{{ t('fileManage.copyText') }}
|
||
</BaseButton>
|
||
<BaseButton @click="closeTextPreview">
|
||
{{ t('common.close') }}
|
||
</BaseButton>
|
||
</template>
|
||
</BaseModal>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { vResizableColumns } from '@/directives/resizable-columns'
|
||
import DownloadCheckStatus from '@/components/manage/DownloadCheckStatus.vue'
|
||
import { getHistoryStatusLabel } from '@/utils/history-status'
|
||
import { computed, nextTick, onMounted, onUnmounted, ref, watch, type Component } from 'vue'
|
||
import { useI18n } from 'vue-i18n'
|
||
import { useRoute, useRouter } from 'vue-router'
|
||
import type {
|
||
AnalyticsFileRow,
|
||
AdminBatchEditMode,
|
||
AdminFileHealthFilter,
|
||
AdminFileInsightSeverity,
|
||
AdminFilePolicyAction,
|
||
AdminFileSortBy,
|
||
AdminFileSortOrder,
|
||
AdminFileStatusFilter,
|
||
AdminFileTypeFilter,
|
||
AdminFileViewItem
|
||
} from '@/types'
|
||
import {
|
||
ActivityIcon,
|
||
ArchiveIcon,
|
||
ArrowDownUpIcon,
|
||
CheckIcon,
|
||
ClockIcon,
|
||
CopyIcon,
|
||
DownloadIcon,
|
||
EyeIcon,
|
||
FileIcon,
|
||
FileTextIcon,
|
||
FilterIcon,
|
||
HardDriveIcon,
|
||
InfinityIcon,
|
||
PencilIcon,
|
||
RefreshCwIcon,
|
||
RotateCcwIcon,
|
||
SearchIcon,
|
||
TimerResetIcon,
|
||
TrashIcon,
|
||
XIcon
|
||
} from 'lucide-vue-next'
|
||
import DataTable from '@/components/common/DataTable.vue'
|
||
import DataPagination from '@/components/common/DataPagination.vue'
|
||
import FileEditField from '@/components/common/FileEditField.vue'
|
||
import NativeDateSelect from '@/components/common/NativeDateSelect.vue'
|
||
import BaseModal from '@/components/common/BaseModal.vue'
|
||
import BaseButton from '@/components/common/BaseButton.vue'
|
||
import AdaptiveValue from '@/components/common/AdaptiveValue.vue'
|
||
import { useAdminFiles, useInjectedDarkMode, useTransferAnalytics, useDownloadChecks } from '@/composables'
|
||
import { formatFileSize, formatTimestamp } from '@/utils/common'
|
||
import { createDetailMotion } from '@/utils/detailMotion'
|
||
|
||
const { t } = useI18n()
|
||
const isDarkMode = useInjectedDarkMode()
|
||
const route = useRoute()
|
||
const router = useRouter()
|
||
const { fetchAnalytics } = useTransferAnalytics()
|
||
|
||
const fileTableHeaders = computed(() => [
|
||
t('fileManage.headers.select'),
|
||
t('fileManage.headers.code'),
|
||
t('fileManage.headers.name'),
|
||
t('fileManage.headers.type'),
|
||
t('fileManage.headers.size'),
|
||
t('fileManage.headers.usage'),
|
||
t('fileManage.headers.expiration'),
|
||
t('fileManage.headers.status'),
|
||
'可下载状态',
|
||
t('fileManage.headers.actions')
|
||
])
|
||
|
||
const {
|
||
tableData,
|
||
hasActiveFilters,
|
||
hasLoadError,
|
||
isLoading,
|
||
isAllCurrentPageSelected,
|
||
isBatchActionRunning,
|
||
isBatchDeleting,
|
||
isBatchPolicyActionRunning,
|
||
isBatchUpdating,
|
||
isCurrentPagePartiallySelected,
|
||
isDetailLoading,
|
||
isDetailMetadataSaving,
|
||
isDetailPolicyActionRunning,
|
||
isPreviewLoading,
|
||
isSaving,
|
||
isViewPresetDeleting,
|
||
isViewPresetLoading,
|
||
isViewPresetSaving,
|
||
batchEditForm,
|
||
batchPolicyActionOptions,
|
||
detailPolicyActionOptions,
|
||
detailMetadataForm,
|
||
downloadingFileId,
|
||
healthFilterOptions,
|
||
hasSelectedFiles,
|
||
params,
|
||
previewFile,
|
||
previewMetaText,
|
||
selectedFileDetail,
|
||
selectedCount,
|
||
selectedFileIds,
|
||
selectedViewPresetId,
|
||
storageUsedText,
|
||
summary,
|
||
showBatchEditModal,
|
||
showEditModal,
|
||
showFileDetailModal,
|
||
editForm,
|
||
showTextPreview,
|
||
previewText,
|
||
viewPresets,
|
||
applyViewPreset,
|
||
closeBatchEditModal,
|
||
closeEditModal,
|
||
closeFileDetail,
|
||
closeTextPreview,
|
||
copyDetailRetrieveCode,
|
||
copyDetailRetrieveLink,
|
||
copyText,
|
||
clearSelection,
|
||
deleteFile: deleteFileRaw,
|
||
deleteSelectedFiles: deleteSelectedFilesRaw,
|
||
deleteSelectedViewPreset,
|
||
downloadFile,
|
||
exportPreviewText,
|
||
handlePageChange,
|
||
handlePageSizeChange,
|
||
handleSearch,
|
||
applyDetailPolicyAction: applyDetailPolicyActionRaw,
|
||
applySelectedPolicyAction: applySelectedPolicyActionRaw,
|
||
handleBatchUpdate: handleBatchUpdateRaw,
|
||
handleUpdate: handleUpdateRaw,
|
||
loadViewPresets,
|
||
loadFiles,
|
||
openBatchEditModal,
|
||
openEditModal,
|
||
openFileDetail,
|
||
openTextPreview,
|
||
refreshFiles: refreshFileList,
|
||
resetFilters,
|
||
saveCurrentViewPreset,
|
||
setHealthFilter,
|
||
setStatusFilter,
|
||
setTypeFilter,
|
||
updateSelectedViewPreset,
|
||
updateDetailMetadata,
|
||
toggleCurrentPageSelection,
|
||
toggleFileSelection
|
||
} = useAdminFiles()
|
||
|
||
const {
|
||
interval: downloadCheckInterval, saving: savingCheckInterval, error: checkIntervalError,
|
||
statusFor: downloadStatusFor, loadInterval: loadCheckInterval, saveInterval: saveCheckInterval,
|
||
checking: checkingDownloads, progress: downloadProgress, progressText: downloadProgressText,
|
||
checkIds: checkDownloadIds, checkAll: checkAllDownloads, cancel: cancelDownloadChecks
|
||
} = useDownloadChecks(tableData)
|
||
const handleCheckIntervalChange = (event: Event) => {
|
||
void saveCheckInterval(Number((event.target as HTMLSelectElement).value))
|
||
}
|
||
|
||
|
||
const isFilterPanelOpen = ref(false)
|
||
const showMobilePolicyActions = ref(false)
|
||
const mobileMediaQuery = window.matchMedia('(max-width: 767px)')
|
||
const isMobileViewport = ref(mobileMediaQuery.matches)
|
||
const syncMobileViewport = (event: MediaQueryListEvent) => {
|
||
isMobileViewport.value = event.matches
|
||
}
|
||
const isLifecycleExpanded = ref(false)
|
||
const lifecycleViewportRef = ref<HTMLElement | null>(null)
|
||
let lifecycleHeightRevision = 0
|
||
const isRetrievalHistoryExpanded = ref(false)
|
||
const retrievalTimelineEvents = computed(() =>
|
||
(selectedFileDetail.value?.detailTimeline || []).filter((item) => item.key === 'retrieved_event' || item.key === 'queried_event')
|
||
)
|
||
const retrievalTimelineCount = computed(() => retrievalTimelineEvents.value.length)
|
||
const detailTimelineRows = computed(() => {
|
||
const timeline = selectedFileDetail.value?.detailTimeline || []
|
||
return timeline.filter((item) => item.key !== 'retrieved_event' && item.key !== 'queried_event')
|
||
})
|
||
const visibleDetailTimeline = computed(() =>
|
||
isLifecycleExpanded.value ? detailTimelineRows.value : detailTimelineRows.value.slice(0, 3)
|
||
)
|
||
|
||
const reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)')
|
||
const detailMotion = createDetailMotion(() => reducedMotionQuery.matches)
|
||
const playDetailAnimation = detailMotion.play
|
||
const PANEL_DURATION_MS = 420
|
||
const lifecycleEasing = 'cubic-bezier(0.32, 0.72, 0, 1)'
|
||
const LIFECYCLE_ENTER_MS = 180
|
||
const LIFECYCLE_LEAVE_MS = 120
|
||
|
||
// This watcher runs before Vue patches the rows: capture the visible starting
|
||
// height now, then measure the natural list height after leaving rows exit flow.
|
||
watch(isLifecycleExpanded, async () => {
|
||
const revision = ++lifecycleHeightRevision
|
||
const viewport = lifecycleViewportRef.value
|
||
if (!viewport) return
|
||
const from = viewport.getBoundingClientRect().height
|
||
detailMotion.cancel(viewport)
|
||
viewport.style.height = `${from}px`
|
||
viewport.style.overflow = 'hidden'
|
||
await nextTick()
|
||
if (revision !== lifecycleHeightRevision || !viewport.isConnected) return
|
||
const to = viewport.firstElementChild?.getBoundingClientRect().height ?? 0
|
||
playDetailAnimation(
|
||
viewport,
|
||
[{ height: `${from}px` }, { height: `${to}px` }],
|
||
{ duration: PANEL_DURATION_MS, easing: lifecycleEasing },
|
||
() => {
|
||
viewport.style.height = ''
|
||
viewport.style.overflow = ''
|
||
}
|
||
)
|
||
})
|
||
|
||
const beforeLifecycleRowEnter = (element: Element) => {
|
||
const row = element as HTMLElement
|
||
row.style.willChange = 'opacity'
|
||
}
|
||
const enterLifecycleRow = (element: Element, done: () => void) => {
|
||
const row = element as HTMLElement
|
||
playDetailAnimation(
|
||
row,
|
||
[
|
||
{ opacity: 0 },
|
||
{ opacity: 1 }
|
||
],
|
||
{ duration: LIFECYCLE_ENTER_MS, delay: 0, easing: lifecycleEasing },
|
||
() => {
|
||
row.style.willChange = ''
|
||
done()
|
||
}
|
||
)
|
||
}
|
||
const leaveLifecycleRow = (element: Element, done: () => void) => {
|
||
const row = element as HTMLElement
|
||
const width = row.getBoundingClientRect().width
|
||
const top = row.offsetTop
|
||
row.style.position = 'absolute'
|
||
row.style.top = `${top}px`
|
||
row.style.width = `${width}px`
|
||
row.style.willChange = 'opacity'
|
||
playDetailAnimation(
|
||
row,
|
||
[
|
||
{ opacity: 1 },
|
||
{ opacity: 0 }
|
||
],
|
||
{ duration: LIFECYCLE_LEAVE_MS, easing: lifecycleEasing },
|
||
() => {
|
||
row.style.willChange = ''
|
||
done()
|
||
}
|
||
)
|
||
}
|
||
const clearPanelStyles = (element: Element) => {
|
||
const panel = element as HTMLElement
|
||
panel.style.height = ''
|
||
panel.style.overflow = ''
|
||
panel.style.willChange = ''
|
||
}
|
||
const beforeExpandPanelEnter = (element: Element) => {
|
||
const panel = element as HTMLElement
|
||
// v-show briefly sets display:none while reversing leave; computed height
|
||
// still includes the running effect, whereas the bounding box is then zero.
|
||
const from = panel.style.height ? Number.parseFloat(getComputedStyle(panel).height) : 0
|
||
detailMotion.cancel(panel)
|
||
panel.style.height = `${from}px`
|
||
panel.style.overflow = 'hidden'
|
||
panel.style.willChange = 'height, opacity'
|
||
}
|
||
const enterExpandPanel = (element: Element, done: () => void) => {
|
||
const panel = element as HTMLElement
|
||
// Remove the frozen height while measuring: scrollHeight cannot measure a
|
||
// smaller destination when the element still has a larger explicit height.
|
||
const from = panel.getBoundingClientRect().height
|
||
panel.style.height = ''
|
||
const to = panel.getBoundingClientRect().height
|
||
panel.style.height = `${from}px`
|
||
playDetailAnimation(panel,
|
||
[{ height: `${from}px`, opacity: from > 0 ? 1 : 0 }, { height: `${to}px`, opacity: 1 }],
|
||
{ duration: PANEL_DURATION_MS, easing: lifecycleEasing },
|
||
() => { clearPanelStyles(panel); done() }
|
||
)
|
||
}
|
||
const afterExpandPanelEnter = clearPanelStyles
|
||
const beforeExpandPanelLeave = (element: Element) => {
|
||
const panel = element as HTMLElement
|
||
const from = panel.getBoundingClientRect().height
|
||
detailMotion.cancel(panel)
|
||
panel.style.height = `${from}px`
|
||
panel.style.overflow = 'hidden'
|
||
panel.style.willChange = 'height, opacity'
|
||
}
|
||
const leaveExpandPanel = (element: Element, done: () => void) => {
|
||
const panel = element as HTMLElement
|
||
const from = panel.getBoundingClientRect().height
|
||
playDetailAnimation(panel,
|
||
[{ height: `${from}px`, opacity: 1 }, { height: '0px', opacity: 0 }],
|
||
{ duration: PANEL_DURATION_MS, easing: lifecycleEasing },
|
||
() => { clearPanelStyles(panel); done() }
|
||
)
|
||
}
|
||
const beforeRetrievalPanelEnter = beforeExpandPanelEnter
|
||
const enterRetrievalPanel = enterExpandPanel
|
||
const afterRetrievalPanelEnter = afterExpandPanelEnter
|
||
const beforeRetrievalPanelLeave = beforeExpandPanelLeave
|
||
const leaveRetrievalPanel = leaveExpandPanel
|
||
watch(
|
||
() => selectedFileDetail.value?.id,
|
||
() => {
|
||
isLifecycleExpanded.value = false
|
||
isRetrievalHistoryExpanded.value = false
|
||
}
|
||
)
|
||
const filterBodyVisible = computed(() => isFilterPanelOpen.value || hasActiveFilters.value)
|
||
|
||
watch(hasSelectedFiles, (selected) => {
|
||
if (!selected) showMobilePolicyActions.value = false
|
||
})
|
||
const isHistoryLoading = ref(false)
|
||
const historyRows = ref<AnalyticsFileRow[]>([])
|
||
const historyPage = ref(1)
|
||
const historyPageSize = ref(10)
|
||
const historyPageRows = computed(() => {
|
||
const start = (historyPage.value - 1) * historyPageSize.value
|
||
return historyRows.value.slice(start, start + historyPageSize.value)
|
||
})
|
||
const loadHistoryFiles = async () => {
|
||
isHistoryLoading.value = true
|
||
try {
|
||
const analytics = await fetchAnalytics()
|
||
historyRows.value = analytics?.historyFiles || []
|
||
historyPage.value = 1
|
||
} finally {
|
||
isHistoryLoading.value = false
|
||
}
|
||
}
|
||
const runFileMutationAndRefreshHistory = async (operation: () => Promise<void>) => {
|
||
await operation()
|
||
await loadHistoryFiles()
|
||
}
|
||
const handleUpdateAndRefreshHistory = () => runFileMutationAndRefreshHistory(handleUpdateRaw)
|
||
const handleBatchUpdateAndRefreshHistory = () =>
|
||
runFileMutationAndRefreshHistory(handleBatchUpdateRaw)
|
||
const deleteFileAndRefreshHistory = (id: number) =>
|
||
runFileMutationAndRefreshHistory(() => deleteFileRaw(id))
|
||
const deleteDetailFileAndRefreshHistory = async () => {
|
||
if (!selectedFileDetail.value) return
|
||
const id = selectedFileDetail.value.id
|
||
await deleteFileAndRefreshHistory(id)
|
||
closeFileDetail()
|
||
}
|
||
const deleteSelectedFilesAndRefreshHistory = () =>
|
||
runFileMutationAndRefreshHistory(deleteSelectedFilesRaw)
|
||
const applySelectedPolicyActionAndRefreshHistory = (action: AdminFilePolicyAction) =>
|
||
runFileMutationAndRefreshHistory(() => applySelectedPolicyActionRaw(action))
|
||
const applyDetailPolicyActionAndRefreshHistory = (action: AdminFilePolicyAction) =>
|
||
runFileMutationAndRefreshHistory(() => applyDetailPolicyActionRaw(action))
|
||
const handleHistoryPageSizeChange = (size: number) => {
|
||
historyPageSize.value = size
|
||
historyPage.value = 1
|
||
}
|
||
const formatHistoryBytes = (value: number | string | undefined) =>
|
||
formatFileSize(Number(value || 0), 1)
|
||
const formatHistoryDate = (value?: string) => (value ? formatTimestamp(value) : '-')
|
||
|
||
const primaryTextClass = computed(() => (isDarkMode.value ? 'text-white' : 'text-gray-900'))
|
||
const mutedTextClass = computed(() => (isDarkMode.value ? 'text-gray-400' : 'text-gray-500'))
|
||
const panelClass = computed(() =>
|
||
isDarkMode.value
|
||
? 'border-[#495765] bg-[#252b34]/90'
|
||
: 'border-[#d7e3e5] bg-[#f8fbfb]'
|
||
)
|
||
const fieldClass = computed(() =>
|
||
isDarkMode.value
|
||
? 'border-[#50666f] bg-[#2c3440] text-white'
|
||
: 'border-[#c8d8dc] bg-[#fbfdfd] text-[#263f48]'
|
||
)
|
||
const detailActionClass = computed(() =>
|
||
isDarkMode.value
|
||
? 'border-[#3f535c] bg-[#2c3440]/70 text-[#d8e3e5] hover:border-[#7199a8] hover:bg-[#384452]'
|
||
: 'border-[#c9d9dd] bg-[#fbfdfd] text-[#36515b] hover:border-[#8fb2bf] hover:bg-[#edf5f6]'
|
||
)
|
||
const cardHoverClass = computed(() =>
|
||
isDarkMode.value
|
||
? 'hover:border-[#7199a8] hover:bg-[#2c3440] hover:shadow-[#97aac8]/15'
|
||
: 'hover:border-[#8fb2bf] hover:shadow-[#a9bdc2]/70'
|
||
)
|
||
const detailPolicyActionClass = computed(() =>
|
||
isDarkMode.value
|
||
? 'border-[#495765] bg-[#2c3440]/80 text-[#d8e3e5] hover:border-[#7199a8] hover:bg-[#2c3440]'
|
||
: 'border-[#c9d9dd] bg-[#fbfdfd] text-[#36515b] hover:border-[#8fb2bf] hover:bg-[#edf5f6]'
|
||
)
|
||
const subtleSectionClass = computed(() =>
|
||
isDarkMode.value ? 'border-[#495765] bg-[#252b34]/50' : 'border-[#d7e3e5] bg-[#f3f8f8]'
|
||
)
|
||
|
||
type DetailInfoItem = {
|
||
label: string
|
||
value: string
|
||
mono?: boolean
|
||
}
|
||
|
||
const emptyDetailValue = '-'
|
||
const getBooleanLabel = (value: boolean) => t(value ? 'fileManage.yes' : 'fileManage.no')
|
||
const formatDetailValue = (value: string | number | null | undefined) => {
|
||
if (value === null || value === undefined || value === '') return emptyDetailValue
|
||
return String(value)
|
||
}
|
||
const formatMetadataUpdatedAt = (value: string) => formatTimestamp(value)
|
||
|
||
const detailOverviewItems = computed<DetailInfoItem[]>(() => {
|
||
const file = selectedFileDetail.value
|
||
if (!file) return []
|
||
|
||
return [
|
||
{ label: t('fileManage.form.code'), value: file.code, mono: true },
|
||
{ label: t('fileManage.createdAt'), value: file.displayCreatedAt },
|
||
{ label: t('fileManage.headers.size'), value: file.displaySize },
|
||
{ label: t('fileManage.headers.usage'), value: file.displayUsage },
|
||
{
|
||
label: t('fileManage.remainingDownloads'),
|
||
value:
|
||
file.remainingDownloadsValue === null
|
||
? t('fileManage.unlimited')
|
||
: t('fileManage.remaining', { count: file.remainingDownloadsValue })
|
||
},
|
||
{
|
||
label: t('fileManage.textLength'),
|
||
value: file.isTextFile
|
||
? t('fileManage.charCount', { count: file.textLengthValue })
|
||
: emptyDetailValue
|
||
}
|
||
]
|
||
})
|
||
|
||
const detailPolicyItems = computed<DetailInfoItem[]>(() => {
|
||
const file = selectedFileDetail.value
|
||
if (!file) return []
|
||
|
||
return [
|
||
{ label: t('fileManage.permanent'), value: getBooleanLabel(file.isPermanentFile) },
|
||
{
|
||
label: t('fileManage.hasDownloadLimit'),
|
||
value: getBooleanLabel(file.hasDownloadLimitFile)
|
||
},
|
||
{
|
||
label: t('fileManage.hasExpirationTime'),
|
||
value: getBooleanLabel(file.hasExpirationTimeFile)
|
||
},
|
||
{ label: t('fileManage.headers.expiration'), value: file.displayExpiredAt },
|
||
{
|
||
label: t('fileManage.canPreviewText'),
|
||
value: getBooleanLabel(file.canPreviewText)
|
||
},
|
||
{
|
||
label: t('fileManage.canDownload'),
|
||
value: getBooleanLabel(file.canDownloadFile)
|
||
}
|
||
]
|
||
})
|
||
|
||
const detailStorageItems = computed<DetailInfoItem[]>(() => {
|
||
const file = selectedFileDetail.value
|
||
if (!file) return []
|
||
|
||
return [
|
||
{
|
||
label: t('fileManage.storageBackend'),
|
||
value: formatDetailValue(file.storageBackendValue)
|
||
},
|
||
{
|
||
label: t('fileManage.fileHash'),
|
||
value: formatDetailValue(file.fileHashValue),
|
||
mono: true
|
||
},
|
||
{
|
||
label: t('fileManage.isChunked'),
|
||
value: getBooleanLabel(file.isChunkedStorage)
|
||
},
|
||
{
|
||
label: t('fileManage.filePath'),
|
||
value: formatDetailValue(file.filePathValue),
|
||
mono: true
|
||
},
|
||
{
|
||
label: t('fileManage.uuidFileName'),
|
||
value: formatDetailValue(file.uuidFileNameValue),
|
||
mono: true
|
||
},
|
||
{
|
||
label: t('fileManage.uploadId'),
|
||
value: formatDetailValue(file.uploadIdValue),
|
||
mono: true
|
||
}
|
||
]
|
||
})
|
||
|
||
const detailInsightReasonLabels = computed(() => {
|
||
const file = selectedFileDetail.value
|
||
if (!file) return []
|
||
|
||
return file.statusInsightReasons.map((reason) => t(`fileManage.insightReasons.${reason}`))
|
||
})
|
||
|
||
const canModifySelectedViewPreset = computed(() => {
|
||
const preset = viewPresets.value.find((item) => item.id === selectedViewPresetId.value)
|
||
return Boolean(preset && !preset.isBuiltIn)
|
||
})
|
||
|
||
const openDetailEditModal = () => {
|
||
if (!selectedFileDetail.value) return
|
||
|
||
const file = selectedFileDetail.value
|
||
closeFileDetail()
|
||
openEditModal(file)
|
||
}
|
||
|
||
const openDetailTextPreview = () => {
|
||
if (!selectedFileDetail.value) return
|
||
|
||
const file = selectedFileDetail.value
|
||
closeFileDetail()
|
||
void openTextPreview(file)
|
||
}
|
||
|
||
const summaryCards = computed(() => [
|
||
{
|
||
label: t('fileManage.totalFiles'),
|
||
value: summary.value.totalFiles,
|
||
icon: ArchiveIcon,
|
||
iconClass: isDarkMode.value
|
||
? 'bg-indigo-900/30 text-indigo-300'
|
||
: 'bg-indigo-50 text-indigo-600'
|
||
},
|
||
{
|
||
label: t('fileManage.activeFiles'),
|
||
value: summary.value.activeCount,
|
||
icon: ActivityIcon,
|
||
iconClass: isDarkMode.value ? 'bg-green-900/30 text-green-300' : 'bg-green-50 text-green-600'
|
||
},
|
||
{
|
||
label: t('fileManage.expiredFiles'),
|
||
value: summary.value.expiredCount,
|
||
icon: ClockIcon,
|
||
iconClass: isDarkMode.value ? 'bg-red-900/30 text-red-300' : 'bg-red-50 text-red-600'
|
||
},
|
||
{
|
||
label: t('fileManage.storageUsed'),
|
||
value: storageUsedText.value,
|
||
icon: HardDriveIcon,
|
||
iconClass: isDarkMode.value
|
||
? 'bg-purple-900/30 text-purple-300'
|
||
: 'bg-purple-50 text-purple-600'
|
||
}
|
||
])
|
||
|
||
const statusFilterOptions = computed<{ value: AdminFileStatusFilter; label: string }[]>(() => [
|
||
{ value: 'all', label: t('fileManage.all') },
|
||
{ value: 'active', label: t('fileManage.active') },
|
||
{ value: 'expired', label: t('fileManage.expired') }
|
||
])
|
||
|
||
const typeFilterOptions = computed<{ value: AdminFileTypeFilter; label: string }[]>(() => [
|
||
{ value: 'all', label: t('fileManage.all') },
|
||
{ value: 'file', label: t('fileManage.fileType') },
|
||
{ value: 'text', label: t('fileManage.textType') },
|
||
{ value: 'chunked', label: t('fileManage.chunkedType') }
|
||
])
|
||
|
||
const sortOptions = computed<{ value: AdminFileSortBy; label: string }[]>(() => [
|
||
{ value: 'created_at', label: t('fileManage.sort.createdAt') },
|
||
{ value: 'expired_at', label: t('fileManage.sort.expiredAt') },
|
||
{ value: 'name', label: t('fileManage.sort.name') },
|
||
{ value: 'size', label: t('fileManage.sort.size') },
|
||
{ value: 'used_count', label: t('fileManage.sort.usedCount') },
|
||
{ value: 'code', label: t('fileManage.sort.code') }
|
||
])
|
||
|
||
const sortOrderOptions = computed<{ value: AdminFileSortOrder; label: string }[]>(() => [
|
||
{ value: 'desc', label: t('fileManage.sort.desc') },
|
||
{ value: 'asc', label: t('fileManage.sort.asc') }
|
||
])
|
||
|
||
const healthFilterValues: AdminFileHealthFilter[] = [
|
||
'all',
|
||
'attention',
|
||
'danger',
|
||
'warning',
|
||
'healthy',
|
||
'expired',
|
||
'expiring_soon',
|
||
'storage_issue',
|
||
'never_retrieved',
|
||
'permanent'
|
||
]
|
||
|
||
const getRouteHealthFilter = (): AdminFileHealthFilter => {
|
||
const health = route.query.health
|
||
if (typeof health === 'string' && healthFilterValues.includes(health as AdminFileHealthFilter)) {
|
||
return health as AdminFileHealthFilter
|
||
}
|
||
return 'all'
|
||
}
|
||
|
||
const syncHealthFilterQuery = async (health: AdminFileHealthFilter) => {
|
||
const query = { ...route.query }
|
||
if (health === 'all') {
|
||
delete query.health
|
||
} else {
|
||
query.health = health
|
||
}
|
||
await router.replace({ query })
|
||
}
|
||
|
||
const handleHealthFilterChange = async (health: AdminFileHealthFilter) => {
|
||
await setHealthFilter(health)
|
||
await syncHealthFilterQuery(health)
|
||
}
|
||
|
||
const handleStatusFilterChange = async (event: Event) => {
|
||
const target = event.target as HTMLSelectElement
|
||
await setStatusFilter(target.value as AdminFileStatusFilter)
|
||
}
|
||
|
||
const handleTypeFilterChange = async (event: Event) => {
|
||
const target = event.target as HTMLSelectElement
|
||
await setTypeFilter(target.value as AdminFileTypeFilter)
|
||
}
|
||
|
||
const handleHealthFilterSelect = async (event: Event) => {
|
||
const target = event.target as HTMLSelectElement
|
||
await handleHealthFilterChange(target.value as AdminFileHealthFilter)
|
||
}
|
||
|
||
const handleResetFilters = async () => {
|
||
await resetFilters()
|
||
await syncHealthFilterQuery('all')
|
||
}
|
||
|
||
const handleViewPresetChange = async (event: Event) => {
|
||
const target = event.target as HTMLSelectElement
|
||
if (!target.value) {
|
||
selectedViewPresetId.value = ''
|
||
return
|
||
}
|
||
|
||
await applyViewPreset(target.value)
|
||
await syncHealthFilterQuery(params.value.health || 'all')
|
||
}
|
||
|
||
const handleSaveViewPreset = async () => {
|
||
const name = window.prompt(t('fileManage.viewPresetNamePrompt'))
|
||
if (!name) return
|
||
|
||
await saveCurrentViewPreset(name)
|
||
}
|
||
|
||
const batchEditModeOptions = computed<
|
||
{ value: AdminBatchEditMode; label: string; icon: Component }[]
|
||
>(() => [
|
||
{
|
||
value: 'expiresAt',
|
||
label: t('fileManage.batchEditExpiresAt'),
|
||
icon: ClockIcon
|
||
},
|
||
{
|
||
value: 'relativeExpire',
|
||
label: t('fileManage.batchEditRelativeExpire'),
|
||
icon: TimerResetIcon
|
||
},
|
||
{
|
||
value: 'downloadLimit',
|
||
label: t('fileManage.batchEditDownloadLimit'),
|
||
icon: DownloadIcon
|
||
},
|
||
{
|
||
value: 'forever',
|
||
label: t('fileManage.batchEditForever'),
|
||
icon: CheckIcon
|
||
}
|
||
])
|
||
|
||
const detailPolicyActionIconMap: Record<AdminFilePolicyAction, Component> = {
|
||
extend_24h: ClockIcon,
|
||
extend_7d: ClockIcon,
|
||
make_permanent: InfinityIcon,
|
||
reset_download_limit: RotateCcwIcon
|
||
}
|
||
|
||
const getDetailPolicyActionIcon = (action: AdminFilePolicyAction) =>
|
||
detailPolicyActionIconMap[action]
|
||
|
||
const formatFilterOptionLabel = (option: { label: string; count?: number }) => {
|
||
if (typeof option.count !== 'number') return option.label
|
||
return `${option.label} (${option.count})`
|
||
}
|
||
|
||
const getBatchEditModeClass = (value: AdminBatchEditMode) => {
|
||
if (batchEditForm.value.mode === value) {
|
||
return isDarkMode.value
|
||
? 'border-indigo-500 bg-indigo-500/20 text-indigo-200'
|
||
: 'border-indigo-500 bg-indigo-50 text-indigo-700'
|
||
}
|
||
|
||
return isDarkMode.value
|
||
? 'border-gray-700 bg-gray-700/50 text-gray-300 hover:border-gray-600 hover:bg-gray-700'
|
||
: 'border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-50'
|
||
}
|
||
|
||
const getTypeLabel = (file: AdminFileViewItem) => {
|
||
if (file.isChunkedFile) return t('fileManage.chunkedType')
|
||
return file.isTextFile ? t('fileManage.textType') : t('fileManage.fileType')
|
||
}
|
||
|
||
const getTypeBadgeClass = (file: AdminFileViewItem) => {
|
||
if (file.isChunkedFile) {
|
||
return isDarkMode.value ? 'bg-blue-900/30 text-blue-300' : 'bg-blue-100 text-blue-700'
|
||
}
|
||
if (file.isTextFile) {
|
||
return isDarkMode.value ? 'bg-purple-900/30 text-purple-300' : 'bg-purple-100 text-purple-700'
|
||
}
|
||
return isDarkMode.value ? 'bg-gray-700 text-gray-300' : 'bg-gray-100 text-gray-700'
|
||
}
|
||
|
||
const getStatusBadgeClass = (file: AdminFileViewItem) => {
|
||
if (file.isExpiredFile) {
|
||
return isDarkMode.value ? 'bg-red-900/30 text-red-300' : 'bg-red-100 text-red-700'
|
||
}
|
||
return isDarkMode.value ? 'bg-green-900/30 text-green-300' : 'bg-green-100 text-green-700'
|
||
}
|
||
|
||
const getInsightSeverityLabel = (severity: AdminFileInsightSeverity) =>
|
||
t(`fileManage.insightSeverity.${severity}`)
|
||
|
||
const getInsightStateLabel = (state: string) => t(`fileManage.insightStates.${state}`)
|
||
|
||
const getInsightPanelClass = (severity: AdminFileInsightSeverity) => {
|
||
const darkClasses: Record<AdminFileInsightSeverity, string> = {
|
||
success: 'border-emerald-500/20 bg-emerald-500/10',
|
||
warning: 'border-amber-500/20 bg-amber-500/10',
|
||
danger: 'border-red-500/20 bg-red-500/10',
|
||
info: 'border-blue-500/20 bg-blue-500/10',
|
||
neutral: 'border-gray-700 bg-gray-700/30'
|
||
}
|
||
const lightClasses: Record<AdminFileInsightSeverity, string> = {
|
||
success: 'border-emerald-100 bg-emerald-50',
|
||
warning: 'border-amber-100 bg-amber-50',
|
||
danger: 'border-red-100 bg-red-50',
|
||
info: 'border-blue-100 bg-blue-50',
|
||
neutral: 'border-gray-200 bg-gray-50'
|
||
}
|
||
|
||
return isDarkMode.value ? darkClasses[severity] : lightClasses[severity]
|
||
}
|
||
|
||
const getInsightBadgeClass = (severity: AdminFileInsightSeverity) => {
|
||
const darkClasses: Record<AdminFileInsightSeverity, string> = {
|
||
success: 'bg-emerald-900/40 text-emerald-200',
|
||
warning: 'bg-amber-900/40 text-amber-200',
|
||
danger: 'bg-red-900/40 text-red-200',
|
||
info: 'bg-blue-900/40 text-blue-200',
|
||
neutral: 'bg-gray-700 text-gray-300'
|
||
}
|
||
const lightClasses: Record<AdminFileInsightSeverity, string> = {
|
||
success: 'bg-emerald-100 text-emerald-700',
|
||
warning: 'bg-amber-100 text-amber-700',
|
||
danger: 'bg-red-100 text-red-700',
|
||
info: 'bg-blue-100 text-blue-700',
|
||
neutral: 'bg-gray-100 text-gray-700'
|
||
}
|
||
|
||
return isDarkMode.value ? darkClasses[severity] : lightClasses[severity]
|
||
}
|
||
|
||
const getInsightActionBadgeClass = (action: string) => {
|
||
if (action === 'extend_or_delete' || action === 'extend_expiration') {
|
||
return isDarkMode.value ? 'bg-amber-900/40 text-amber-200' : 'bg-amber-100 text-amber-700'
|
||
}
|
||
if (action === 'inspect_storage') {
|
||
return isDarkMode.value ? 'bg-red-900/40 text-red-200' : 'bg-red-100 text-red-700'
|
||
}
|
||
return isDarkMode.value ? 'bg-gray-700 text-gray-300' : 'bg-gray-100 text-gray-700'
|
||
}
|
||
|
||
const getTimelineDotClass = (severity: AdminFileInsightSeverity) => {
|
||
const classes: Record<AdminFileInsightSeverity, string> = {
|
||
success: 'bg-emerald-500',
|
||
warning: 'bg-amber-500',
|
||
danger: 'bg-red-500',
|
||
info: 'bg-blue-500',
|
||
neutral: isDarkMode.value ? 'bg-gray-500' : 'bg-gray-300'
|
||
}
|
||
|
||
return classes[severity]
|
||
}
|
||
|
||
watch(
|
||
() => selectedFileDetail.value?.id,
|
||
() => {
|
||
isLifecycleExpanded.value = false
|
||
}
|
||
)
|
||
|
||
watch(
|
||
() => route.query.health,
|
||
async () => {
|
||
const health = getRouteHealthFilter()
|
||
if (params.value.health === health) return
|
||
await setHealthFilter(health)
|
||
}
|
||
)
|
||
|
||
onMounted(() => {
|
||
mobileMediaQuery.addEventListener('change', syncMobileViewport)
|
||
params.value.health = getRouteHealthFilter()
|
||
void loadCheckInterval()
|
||
void loadViewPresets()
|
||
void loadFiles()
|
||
void loadHistoryFiles()
|
||
})
|
||
|
||
onUnmounted(() => {
|
||
lifecycleHeightRevision++
|
||
detailMotion.dispose()
|
||
mobileMediaQuery.removeEventListener('change', syncMobileViewport)
|
||
})
|
||
</script>
|
||
|
||
<style scoped>
|
||
.fcb-lifecycle-viewport {
|
||
overflow: visible;
|
||
}
|
||
|
||
.fcb-lifecycle-viewport > .fcb-lifecycle-list {
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
overflow: visible;
|
||
}
|
||
|
||
.fcb-lifecycle-row {
|
||
position: relative;
|
||
overflow: visible;
|
||
/* Keep transformed lifecycle cards from being clipped at their top border. */
|
||
contain: layout;
|
||
will-change: opacity;
|
||
}
|
||
|
||
.fcb-lifecycle-card {
|
||
position: relative;
|
||
overflow: visible;
|
||
border-top-width: 1px;
|
||
}
|
||
|
||
.fcb-expand-content {
|
||
overflow: clip;
|
||
will-change: grid-template-rows, opacity, transform;
|
||
}
|
||
|
||
</style>
|