✨ feat(core): 实现回收站条目展示逻辑及UI组件
* 新增 TrashItemInfo 组件以优化回收站列表项展示 * 封装 trashPresentation 工具类处理时间显示逻辑 * 调整 TrashView 布局,重构列表项渲染逻辑 * 新增回收站功能相关的集成测试与单元测试 * 更新测试文档以说明回收站日期格式化测试规则 * 更新 package.json 依赖配置
This commit is contained in:
1 parent
af009cf3c5
commit
614b9a2104
7 files changed
+243
-14
No files matched your search
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<div class="trash-item-info min-w-0" :class="{ 'trash-item-info--dark': isDarkMode }">
|
||||
<div class="flex min-w-0 items-start gap-3">
|
||||
<div class="trash-file-icon flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl" :class="`trash-tone-${info.tone}`">
|
||||
<component :is="item.isTrashPurged ? FileX2Icon : item.text != null ? FileTextIcon : FileIcon" class="h-5 w-5" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-x-2.5 gap-y-1.5">
|
||||
<p class="trash-file-name min-w-0 text-sm font-semibold leading-6 sm:text-base">{{ name }}</p>
|
||||
<span class="trash-state shrink-0 rounded-full border px-2.5 py-0.5 text-xs font-medium" :class="`trash-tone-${info.tone}`">{{ info.state }}</span>
|
||||
</div>
|
||||
<dl class="trash-file-meta mt-2 flex flex-wrap gap-x-5 gap-y-2 text-xs leading-5">
|
||||
<div class="flex flex-wrap gap-x-1.5"><dt>原取件码</dt><dd class="font-mono font-medium tracking-wide">{{ item.code || '未记录' }}</dd></div>
|
||||
<div class="flex gap-x-1.5"><dt>文件大小</dt><dd>{{ sizeText }}</dd></div>
|
||||
<div class="flex flex-wrap gap-x-1.5"><dt>移入原因</dt><dd>{{ info.reason }}</dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div class="trash-time-panel mt-3 rounded-2xl border px-3 py-2.5 sm:ml-14">
|
||||
<dl class="grid min-w-0 gap-3 text-xs sm:grid-cols-2">
|
||||
<div class="min-w-0">
|
||||
<dt class="trash-time-label flex items-center gap-1.5"><Clock3Icon class="h-3.5 w-3.5" aria-hidden="true" />移入时间</dt>
|
||||
<dd class="mt-1.5 font-medium tabular-nums"><time :datetime="item.trashedAt || undefined" :title="formatTrashTime(item.trashedAt)">{{ formatTrashTime(item.trashedAt, now) }}</time></dd>
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<dt class="trash-time-label flex items-center gap-1.5"><CalendarClockIcon class="h-3.5 w-3.5" aria-hidden="true" />{{ info.timeLabel }}</dt>
|
||||
<dd class="mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 font-medium tabular-nums">
|
||||
<span :title="item.isTrashPermanent && !item.isTrashPurged ? undefined : formatTrashTime(item.isTrashPurged ? item.trashPurgedAt : item.trashExpiresAt)">{{ info.timeText }}</span>
|
||||
<span v-if="info.reminder" class="trash-remaining rounded-full px-2 py-0.5 text-[11px]" :class="`trash-tone-${info.tone}`">{{ info.reminder }}</span>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p v-if="info.note" class="trash-time-label mt-2 text-xs leading-5">{{ info.note }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { CalendarClockIcon, Clock3Icon, FileIcon, FileTextIcon, FileX2Icon } from 'lucide-vue-next'
|
||||
import type { TrashFileItem } from '@/types'
|
||||
import { formatFileSize } from '@/utils/common'
|
||||
import { formatTrashTime, getTrashPresentation } from '@/utils/trashPresentation'
|
||||
|
||||
const props = defineProps<{ item: TrashFileItem; isDarkMode: boolean; now: number }>()
|
||||
const info = computed(() => getTrashPresentation(props.item, props.now))
|
||||
const name = computed(() => props.item.name || `${props.item.prefix || ''}${props.item.suffix || ''}` || '未命名文件')
|
||||
const sizeText = computed(() => {
|
||||
const size = Number(props.item.size)
|
||||
return Number.isFinite(size) && size >= 0 ? formatFileSize(size, 1) : '未记录'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.trash-item-info { color: #294851; --trash-muted: #617980; --trash-line: #d7e3e5; --trash-surface: #edf3f6; }
|
||||
.trash-item-info--dark { color: #dbe9ee; --trash-muted: #a9bdc2; --trash-line: #40545c; --trash-surface: #26383f; }
|
||||
.trash-file-name { overflow-wrap: anywhere; }
|
||||
.trash-file-meta dt, .trash-time-label { color: var(--trash-muted); }
|
||||
.trash-time-panel { background: var(--trash-surface); border-color: var(--trash-line); }
|
||||
.trash-state { border-color: var(--trash-line); }
|
||||
.trash-tone-normal { background: #e4f0ed; color: #355e56; }
|
||||
.trash-tone-warning { background: #fff0d8; color: #885512; }
|
||||
.trash-tone-permanent { background: #eeebf8; color: #62528e; }
|
||||
.trash-tone-muted { background: #e8edef; color: #596b73; }
|
||||
.trash-item-info--dark .trash-tone-normal { background: #29473f; color: #c0e5d8; }
|
||||
.trash-item-info--dark .trash-tone-warning { background: #514026; color: #f5d599; }
|
||||
.trash-item-info--dark .trash-tone-permanent { background: #3e3556; color: #ddd2f6; }
|
||||
.trash-item-info--dark .trash-tone-muted { background: #344249; color: #bbc9cf; }
|
||||
</style>
|
||||
Reference in new issue
Block a user