diff --git a/src/assets/style/resizable-columns.css b/src/assets/style/resizable-columns.css
new file mode 100644
index 0000000..d511e40
--- /dev/null
+++ b/src/assets/style/resizable-columns.css
@@ -0,0 +1,43 @@
+.resizable-columns th {
+ position: relative;
+ text-align: center;
+ white-space: nowrap;
+}
+
+.column-resize-handle {
+ position: absolute;
+ inset: 0 -4px 0 auto;
+ width: 9px;
+ z-index: 1;
+ cursor: col-resize;
+ touch-action: none;
+}
+
+.column-resize-handle::after {
+ content: '';
+ position: absolute;
+ inset: 25% 4px;
+ background: currentColor;
+ opacity: 0.25;
+}
+
+.column-resize-handle:hover::after,
+.column-resize-handle:focus-visible::after {
+ opacity: 1;
+}
+
+.column-resize-handle:focus-visible {
+ outline: 2px solid currentColor;
+ outline-offset: -2px;
+}
+
+.columns-resizing,
+.columns-resizing * {
+ cursor: col-resize !important;
+ user-select: none;
+}
+
+.columns-sized td {
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
diff --git a/src/components/common/DataTable.vue b/src/components/common/DataTable.vue
index 7deb168..c522d57 100644
--- a/src/components/common/DataTable.vue
+++ b/src/components/common/DataTable.vue
@@ -20,6 +20,7 @@
@@ -30,7 +31,7 @@
v-for="header in headers"
:key="header"
scope="col"
- class="px-6 py-3.5 text-left text-xs font-medium uppercase tracking-wider"
+ class="whitespace-nowrap px-6 py-3.5 text-center text-xs font-medium uppercase tracking-wider"
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
>
{{ header }}
@@ -50,6 +51,7 @@
diff --git a/src/composables/index.ts b/src/composables/index.ts
index 7828930..e3edf88 100644
--- a/src/composables/index.ts
+++ b/src/composables/index.ts
@@ -16,3 +16,5 @@ export { useTheme } from './useTheme'
export { useTransferAnalytics } from './useTransferAnalytics'
export { useLocalFiles } from './useLocalFiles'
+
+export { useDownloadChecks } from './useDownloadChecks'
diff --git a/src/composables/useAdminFiles.ts b/src/composables/useAdminFiles.ts
index 059c061..5b970c6 100644
--- a/src/composables/useAdminFiles.ts
+++ b/src/composables/useAdminFiles.ts
@@ -651,7 +651,7 @@ export function useAdminFiles() {
if (numericValue !== null) return t('fileManage.remaining', { count: numericValue })
}
- if ((item.key === 'retrieved' || item.key === 'retrieved_event') && hasNumericTimelineValue(item)) {
+ if ((item.key === 'retrieved' || item.key === 'retrieved_event' || item.key === 'queried_event') && hasNumericTimelineValue(item)) {
return `${normalizeTimelineNumber(item.value)} ${t('common.times')}`
}
@@ -673,7 +673,7 @@ export function useAdminFiles() {
}
const formatTimelineTitleValue = (item: AdminFileDetailTimelineItem, valueText: string) => {
- if (item.key === 'retrieved_event') {
+ if (item.key === 'retrieved_event' || item.key === 'queried_event') {
const numericValue = normalizeTimelineNumber(item.value)
return numericValue === null ? '' : String(numericValue)
}
diff --git a/src/composables/useDownloadChecks.ts b/src/composables/useDownloadChecks.ts
new file mode 100644
index 0000000..8130faf
--- /dev/null
+++ b/src/composables/useDownloadChecks.ts
@@ -0,0 +1,90 @@
+import { onScopeDispose, ref, watch, type Ref } from 'vue'
+import { DownloadCheckService, ConfigService } from '@/services'
+import type { DownloadCheck } from '@/types/download-check'
+
+export function useDownloadChecks(files: Ref<{ id: number }[]>) {
+ const checks = ref>({})
+ const interval = ref(300)
+ const saving = ref(false)
+ const error = ref('')
+ const checking = ref(false)
+ let controller: AbortController | undefined
+ let timer: ReturnType | undefined
+ let disposed = false
+
+ const statusFor = (id: number): DownloadCheck => checks.value[id] ?? {
+ id, status: 'unknown', message: '尚未检测', checkedAt: null
+ }
+ const schedule = () => {
+ clearTimeout(timer)
+ if (!disposed && interval.value > 0) timer = setTimeout(() => {
+ if (typeof document !== 'undefined' && document.hidden) schedule()
+ else void refresh()
+ }, interval.value * 1000)
+ }
+ const refresh = async () => {
+ controller?.abort()
+ const current = new AbortController()
+ controller = current
+ clearTimeout(timer)
+ checking.value = true
+ const ids = files.value.map(file => file.id)
+ checks.value = Object.fromEntries(ids.map(id => [id, {
+ ...statusFor(id), status: 'checking', message: '正在检测'
+ }]))
+ try {
+ for (let offset = 0; offset < ids.length; offset += 20) {
+ const batch = ids.slice(offset, offset + 20)
+ try {
+ const response = await DownloadCheckService.check(batch, current.signal)
+ if (current.signal.aborted || disposed) return
+ if (response.code !== 200 || !Array.isArray(response.detail)) throw new Error('检测请求失败')
+ for (const id of batch) {
+ checks.value[id] = response.detail.find(item => item.id === id) ?? {
+ id, status: 'unknown', message: '未返回检测结果,请重试', checkedAt: null
+ }
+ }
+ } catch {
+ if (current.signal.aborted || disposed) return
+ for (const id of batch) checks.value[id] = {
+ id, status: 'unknown', message: '检测请求失败,请刷新重试', checkedAt: null
+ }
+ }
+ }
+ } finally {
+ if (controller === current && !disposed) {
+ checking.value = false
+ schedule()
+ }
+ }
+ }
+ const loadInterval = async () => {
+ try {
+ const response = await ConfigService.getConfig()
+ if (!disposed && response.code === 200) {
+ interval.value = response.detail?.downloadCheckInterval ?? 300
+ schedule()
+ }
+ } catch { error.value = '无法读取检测间隔,暂按 5 分钟刷新' }
+ }
+ const saveInterval = async (value: number) => {
+ if (saving.value) return
+ saving.value = true
+ error.value = ''
+ try {
+ const response = await ConfigService.updateConfig({ downloadCheckInterval: value })
+ if (response.code !== 200) throw new Error('save failed')
+ interval.value = value
+ schedule()
+ } catch { error.value = '检测间隔保存失败,请重试' }
+ finally { saving.value = false }
+ }
+ // Every successful list load (refresh, page, filter, or edit) gets fresh results.
+ watch(files, () => { void refresh() })
+ onScopeDispose(() => {
+ disposed = true
+ controller?.abort()
+ clearTimeout(timer)
+ })
+ return { checks, interval, saving, error, checking, statusFor, refresh, loadInterval, saveInterval }
+}
diff --git a/src/composables/useRetrieveFlow.ts b/src/composables/useRetrieveFlow.ts
index fe827b0..d7a120f 100644
--- a/src/composables/useRetrieveFlow.ts
+++ b/src/composables/useRetrieveFlow.ts
@@ -9,6 +9,7 @@ import { copyToClipboard } from '@/utils/clipboard'
import { getErrorMessage } from '@/utils/common'
import { renderMarkdownPreview } from '@/utils/content-preview'
import { downloadReceivedRecord } from '@/utils/download-action'
+import { markRecordRetrieved } from '@/utils/receive-record'
type InputStatus = {
readonly: boolean
@@ -60,8 +61,9 @@ export function useRetrieveFlow() {
? detail.type === 'text'
: detail.name === 'Text' && !detail.text.startsWith('/share/download')
const content = isText ? (detail.content ?? detail.text) : null
- const downloadUrl = isText ? null : (detail.download_url ?? detail.text)
+ const downloadUrl = detail.download_url ?? (isText ? null : detail.text)
+ const queriedAt = new Date().toISOString()
return {
id: Date.now(),
code: detail.code,
@@ -69,7 +71,9 @@ export function useRetrieveFlow() {
size: formatFileSize(detail.size),
downloadUrl,
content,
- date: new Date().toLocaleString(),
+ date: queriedAt,
+ queriedAt,
+ retrievedAt: null,
type: isText ? 'text' : 'file',
remainingDownloads: detail.remaining_downloads
}
@@ -130,6 +134,7 @@ export function useRetrieveFlow() {
(file) => file.code === newFileData.code
)
if (existingIndex !== -1) {
+ newFileData.retrievedAt = fileStore.receiveData[existingIndex].retrievedAt ?? null
fileStore.deleteReceiveData(existingIndex)
}
fileStore.addReceiveData(newFileData)
@@ -186,7 +191,9 @@ export function useRetrieveFlow() {
}
const downloadRecord = (record: ReceivedFileRecord) => {
- downloadReceivedRecord(record)
+ if (downloadReceivedRecord(record)) {
+ markRecordRetrieved(record)
+ }
}
const showContentPreview = () => {
diff --git a/src/directives/resizable-columns.ts b/src/directives/resizable-columns.ts
new file mode 100644
index 0000000..d3afcc0
--- /dev/null
+++ b/src/directives/resizable-columns.ts
@@ -0,0 +1,114 @@
+import type { ObjectDirective } from 'vue'
+import { resizeColumn } from '../utils/column-width'
+import '../assets/style/resizable-columns.css'
+
+const states = new WeakMap void; signature: () => boolean }>()
+
+function mount(table: HTMLTableElement) {
+ const view = table.ownerDocument.defaultView!
+ const headers = Array.from(table.querySelectorAll('thead th'))
+ const labels = headers.map(header => header.textContent?.trim() || '')
+ const handles: HTMLElement[] = []
+ let stopDrag = () => {}
+ table.classList.add('resizable-columns')
+
+ function measure() {
+ return headers.map(header => header.getBoundingClientRect().width)
+ }
+
+ function minimum(header: HTMLTableCellElement) {
+ const range = table.ownerDocument.createRange()
+ range.selectNodeContents(header)
+ // Keep the label and padding visible even when the data column is narrowed.
+ const labelWidth = Array.from(range.getClientRects()).reduce((max, rect) => Math.max(max, rect.width), 0)
+ const style = view.getComputedStyle(header)
+ return Math.ceil(Math.max(72, labelWidth + parseFloat(style.paddingLeft) + parseFloat(style.paddingRight)))
+ }
+
+ function apply(widths: number[]) {
+ table.style.tableLayout = 'fixed'
+ table.style.minWidth = '0'
+ table.style.width = `${widths.reduce((sum, width) => sum + width, 0)}px`
+ table.classList.add('columns-sized')
+ headers.forEach((header, index) => {
+ header.style.width = `${widths[index]}px`
+ handles[index]!.setAttribute('aria-valuenow', String(Math.round(widths[index]!)))
+ })
+ }
+
+ headers.forEach((header, index) => {
+ const handle = table.ownerDocument.createElement('span')
+ handle.className = 'column-resize-handle'
+ handle.tabIndex = 0
+ handle.setAttribute('role', 'separator')
+ handle.setAttribute('aria-orientation', 'vertical')
+ header.setAttribute('aria-label', labels[index]!)
+ handle.setAttribute('aria-label', `${labels[index]} — ↔`)
+ handle.setAttribute('aria-valuenow', String(Math.round(header.getBoundingClientRect().width)))
+ header.append(handle)
+ handles.push(handle)
+
+ handle.onpointerdown = event => {
+ if (event.button !== 0) return
+ event.preventDefault()
+ event.stopPropagation()
+ stopDrag()
+ const widths = measure()
+ const min = minimum(header)
+ const startX = event.clientX
+ const pointerId = event.pointerId
+ handle.setPointerCapture(pointerId)
+ table.classList.add('columns-resizing')
+ const move = (event: PointerEvent) => {
+ if (event.pointerId === pointerId) apply(resizeColumn(widths, index, event.clientX - startX, min))
+ }
+ const finish = (event: PointerEvent) => {
+ if (event.pointerId === pointerId) stopDrag()
+ }
+ stopDrag = () => {
+ view.removeEventListener('pointermove', move)
+ view.removeEventListener('pointerup', finish)
+ view.removeEventListener('pointercancel', finish)
+ view.removeEventListener('blur', stopDrag)
+ handle.removeEventListener('lostpointercapture', finish)
+ if (handle.hasPointerCapture(pointerId)) handle.releasePointerCapture(pointerId)
+ table.classList.remove('columns-resizing')
+ stopDrag = () => {}
+ }
+ view.addEventListener('pointermove', move)
+ view.addEventListener('pointerup', finish)
+ view.addEventListener('pointercancel', finish)
+ view.addEventListener('blur', stopDrag)
+ handle.addEventListener('lostpointercapture', finish)
+ }
+ handle.onkeydown = event => {
+ if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return
+ event.preventDefault()
+ apply(resizeColumn(measure(), index, event.key === 'ArrowRight' ? 16 : -16, minimum(header)))
+ }
+ })
+ states.set(table, { signature: () => {
+ const current = Array.from(table.querySelectorAll('thead th'))
+ return current.length === headers.length && current.every((header, index) =>
+ header === headers[index] && header.textContent?.trim() === labels[index] && handles[index]?.isConnected)
+ }, cleanup: () => {
+ stopDrag()
+ handles.forEach(handle => handle.remove())
+ headers.forEach(header => header.removeAttribute('aria-label'))
+ } })
+}
+
+export const vResizableColumns: ObjectDirective = {
+ mounted: mount,
+ updated(table) {
+ const state = states.get(table)
+ if (!state?.signature()) {
+ state?.cleanup()
+ mount(table)
+ }
+ },
+ beforeUnmount(table) {
+ states.get(table)?.cleanup()
+ states.delete(table)
+ }
+}
diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts
index cfee306..12fdb65 100644
--- a/src/i18n/locales/en-US.ts
+++ b/src/i18n/locales/en-US.ts
@@ -406,7 +406,11 @@ export default {
fileRecord: {
filename: 'Filename',
size: 'Size',
- date: 'Date',
+ date: 'Lookup time',
+ queryTime: 'Lookup time',
+ retrieveTime: 'Retrieval time',
+ notRetrieved: 'Not retrieved yet',
+ retrieveTimeHint: 'Most recent download click; does not indicate completion.',
code: 'Code',
actions: 'Actions',
download: 'Download',
@@ -666,13 +670,17 @@ export default {
title: 'Retrieval History',
description: 'Retrieved {value}; current status is {status}.'
},
+ queried_event: {
+ title: 'Lookup #{value}',
+ description: 'Lookup succeeded. Source IP: {detail}.'
+ },
retrieved_event: {
title: 'Retrieval #{value}',
- description: 'This retrieval is complete; current status is {status}.'
+ description: 'Retrieval started; this does not indicate download completion.'
},
retrieved_event_unknown: {
title: 'Retrieval History',
- description: 'This retrieval is complete; current status is {status}.'
+ description: 'Retrieval started; this does not indicate download completion.'
}
},
headers: {
diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts
index 1160fd9..9c71024 100644
--- a/src/i18n/locales/zh-CN.ts
+++ b/src/i18n/locales/zh-CN.ts
@@ -581,7 +581,7 @@ export default {
lifecycle: '生命周期',
expandLifecycle: '展开全部生命周期记录(共 {count} 条)',
collapseLifecycle: '收起生命周期记录',
- expandRetrievalHistory: '展开全部取件记录(共 {count} 次)',
+ expandRetrievalHistory: '展开全部取件记录(共 {count} 条)',
collapseRetrievalHistory: '收起取件记录',
permanent: '永久有效',
createdAt: '创建时间',
@@ -662,13 +662,17 @@ export default {
title: '取件记录',
description: '累计取件 {value},当前状态为 {status}。'
},
+ queried_event: {
+ title: '第 {value} 次查件',
+ description: '查件成功,来源 IP:{detail}。'
+ },
retrieved_event: {
title: '第 {value} 次取件',
- description: '本次取件已完成,当前状态为 {status}。'
+ description: '已发起取件,不代表下载完成。'
},
retrieved_event_unknown: {
title: '取件记录',
- description: '本次取件已完成,当前状态为 {status}。'
+ description: '已发起取件,不代表下载完成。'
}
},
headers: {
@@ -709,7 +713,11 @@ export default {
fileRecord: {
filename: '文件名',
size: '文件大小',
- date: '取件日期',
+ date: '查件时间',
+ queryTime: '查件时间',
+ retrieveTime: '取件时间',
+ notRetrieved: '尚未取件',
+ retrieveTimeHint: '最近一次点击下载的时间,不代表下载完成。',
code: '取件码',
actions: '操作',
download: '下载',
diff --git a/src/services/download-check.ts b/src/services/download-check.ts
new file mode 100644
index 0000000..c4ed481
--- /dev/null
+++ b/src/services/download-check.ts
@@ -0,0 +1,9 @@
+import api from './client'
+import type { ApiResponse } from '@/types'
+import type { DownloadCheck } from '@/types/download-check'
+
+export const DownloadCheckService = {
+ check(ids: number[], signal?: AbortSignal): Promise> {
+ return api.post('/admin/file/download-check', { ids }, { signal, timeout: 70000 })
+ }
+}
diff --git a/src/services/index.ts b/src/services/index.ts
index 0374385..77a602f 100644
--- a/src/services/index.ts
+++ b/src/services/index.ts
@@ -11,3 +11,5 @@ export { uploadChunkedFile } from './upload-strategy'
export { LocalShareService } from './local-share'
export { UploadCancellation, UploadInterrupted, isUploadInterrupted } from './upload-cancellation'
+
+export { DownloadCheckService } from './download-check'
diff --git a/src/types/config.ts b/src/types/config.ts
index aff2fbf..07899fa 100644
--- a/src/types/config.ts
+++ b/src/types/config.ts
@@ -47,6 +47,7 @@ export interface ConfigState {
opacity: number
enableChunk: number
chunkSizeMB: number
+ downloadCheckInterval?: number
s3_access_key_id: string
background: string
showAdminAddr: number
diff --git a/src/types/download-check.ts b/src/types/download-check.ts
new file mode 100644
index 0000000..0ba0c94
--- /dev/null
+++ b/src/types/download-check.ts
@@ -0,0 +1,6 @@
+export interface DownloadCheck {
+ id: number
+ status: 'available' | 'unavailable' | 'unknown' | 'checking'
+ message: string
+ checkedAt: string | null
+}
diff --git a/src/types/file.ts b/src/types/file.ts
index 2743f62..ccdbf12 100644
--- a/src/types/file.ts
+++ b/src/types/file.ts
@@ -453,7 +453,10 @@ export interface ReceivedFileRecord {
size: string
downloadUrl: string | null
content: string | null
+ /** Legacy query time, retained for existing records. */
date: string
+ queriedAt?: string
+ retrievedAt?: string | null
type?: 'file' | 'text'
remainingDownloads?: number | null
}
diff --git a/src/utils/column-width.ts b/src/utils/column-width.ts
new file mode 100644
index 0000000..28391c6
--- /dev/null
+++ b/src/utils/column-width.ts
@@ -0,0 +1,3 @@
+export function resizeColumn(widths: number[], index: number, delta: number, minimum: number): number[] {
+ return widths.map((width, column) => column === index ? Math.max(minimum, width + delta) : width)
+}
diff --git a/src/utils/download-action.ts b/src/utils/download-action.ts
index b3a4aa5..c461353 100644
--- a/src/utils/download-action.ts
+++ b/src/utils/download-action.ts
@@ -7,16 +7,18 @@ const unsafeFilenamePattern = new RegExp(
'g'
)
-export function downloadReceivedRecord(record: ReceivedFileRecord): void {
+export function downloadReceivedRecord(record: ReceivedFileRecord): boolean {
if (record.downloadUrl) {
window.open(buildDownloadUrl(record.downloadUrl), '_blank')
- return
+ return true
}
- if (record.content) {
+ if (typeof record.content === 'string') {
const blob = new Blob([record.content], { type: 'text/plain;charset=utf-8' })
saveAs(blob, `${record.filename}.txt`)
+ return true
}
+ return false
}
export const getSafeFilename = (name: string) =>
diff --git a/src/utils/receive-record.ts b/src/utils/receive-record.ts
new file mode 100644
index 0000000..650c002
--- /dev/null
+++ b/src/utils/receive-record.ts
@@ -0,0 +1,18 @@
+import type { ReceivedFileRecord } from '../types/file'
+
+/** Legacy date was written on lookup, never on download. */
+export function queriedAt(record: ReceivedFileRecord): string {
+ return record.queriedAt || record.date
+}
+
+export function formatRecordTime(value?: string | null): string {
+ if (!value) return ''
+ // Old records contain locale-formatted dates; retain them without guessing.
+ if (!/^\d{4}-\d{2}-\d{2}T/.test(value)) return value
+ const time = new Date(value)
+ return Number.isNaN(time.getTime()) ? value : time.toLocaleString()
+}
+
+export function markRecordRetrieved(record: ReceivedFileRecord, at = new Date()): void {
+ record.retrievedAt = at.toISOString()
+}
diff --git a/src/views/RetrievewFileView.vue b/src/views/RetrievewFileView.vue
index 19b65ca..97df86a 100644
--- a/src/views/RetrievewFileView.vue
+++ b/src/views/RetrievewFileView.vue
@@ -44,6 +44,7 @@
:record="selectedRecord"
@close="closeDetails"
@preview-content="showContentPreview"
+ @download-record="downloadRecord"
/>
|
{{ t('admin.dashboard.topDownloads.file') }}
|
{{ t('admin.dashboard.topDownloads.downloads') }}
|
{{ t('admin.dashboard.topDownloads.traffic') }}
|
{{ t('admin.dashboard.topDownloads.status') }}
@@ -417,6 +418,7 @@
|