✨ feat: 重构管理后台并增强组件系统与回收站功能
* 新增自适应数值与窗口分析工具,提升交互体验 * 优化回收站模块逻辑,增加展示与选择功能 * 引入 Macaron 主题配置文件并更新 Tailwind 配置 * 精简基础组件代码,移除冗余样式与设置项 * 完善测试用例,覆盖 UI 系统与回收站工作流 * 更新多语言配置,支持功能变更后的文案需求
This commit is contained in:
1 parent
614b9a2104
commit
9b22534e2b
61 files changed
+1624
-832
No files matched your search
@@ -0,0 +1,4 @@
|
||||
export function fitValueFontSize(available: number, measured: number, maximum: number, minimum: number): number {
|
||||
if (available <= 0 || measured <= 0) return maximum
|
||||
return Math.max(minimum, Math.min(maximum, Math.floor(maximum * available / measured * 10) / 10))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { AnalyticsDailyRow } from '@/types'
|
||||
|
||||
export interface AnalyticsWindowTotals {
|
||||
downloads: number
|
||||
uploads: number
|
||||
downloadTraffic: number
|
||||
uploadTraffic: number
|
||||
}
|
||||
|
||||
export function summarizeAnalyticsWindow(
|
||||
rows: AnalyticsDailyRow[],
|
||||
offset: number,
|
||||
windowSize: number
|
||||
): AnalyticsWindowTotals {
|
||||
const start = Math.max(0, Math.floor(offset))
|
||||
const end = Math.min(rows.length, Math.ceil(offset + windowSize))
|
||||
return rows.slice(start, end).reduce(
|
||||
(totals, row) => {
|
||||
totals.downloads += Number(row.downloads || 0)
|
||||
totals.uploads += Number(row.uploads || 0)
|
||||
totals.downloadTraffic += Number(row.downloadTraffic || 0)
|
||||
totals.uploadTraffic += Number(row.uploadTraffic || 0)
|
||||
return totals
|
||||
},
|
||||
{ downloads: 0, uploads: 0, downloadTraffic: 0, uploadTraffic: 0 }
|
||||
)
|
||||
}
|
||||
@@ -19,9 +19,12 @@ export function formatTrashTime(value?: string | null, now?: number): string {
|
||||
}
|
||||
|
||||
export function getTrashPresentation(item: TrashFileItem, now: number) {
|
||||
const reason = item.trashReason === 'manual' ? '手动删除'
|
||||
: item.trashReason === 'expired' ? '已过期或次数用尽'
|
||||
: item.trashReason ? '其他原因' : '未记录'
|
||||
const reasons: Record<string, string> = {
|
||||
manual: '手动删除', batch_delete: '批量删除', expired_time: '保存到期',
|
||||
expired_count: '次数用尽', expired_both: '到期且次数用尽', expired: '历史自动回收'
|
||||
}
|
||||
const reason = item.trashReason ? reasons[item.trashReason] || '其他原因' : '未记录'
|
||||
|
||||
if (item.isTrashPurged) return {
|
||||
state: '已清理', tone: 'muted', reason, reminder: '',
|
||||
timeLabel: '清理时间', timeText: formatTrashTime(item.trashPurgedAt, now),
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { TrashFileItem, TrashRetentionRequest, TrashBatchResult } from '../types/trash'
|
||||
|
||||
export function selectableTrashIds(items: Pick<TrashFileItem, 'id' | 'isTrashPurged'>[]) {
|
||||
return [...new Set(items.filter(item => !item.isTrashPurged).map(item => item.id))]
|
||||
}
|
||||
export function buildTrashRetention(permanent: boolean, value: string, now: number): TrashRetentionRequest {
|
||||
if (permanent) return { retentionDays: 0 }
|
||||
const timestamp = new Date(value).getTime()
|
||||
if (!Number.isFinite(timestamp) || timestamp <= now || timestamp > now + 365 * 86400000) {
|
||||
throw new Error('请选择未来 365 天内的自动清理时间')
|
||||
}
|
||||
return { expiresAt: new Date(timestamp).toISOString() }
|
||||
}
|
||||
export function summarizeTrashBatch(result: Pick<TrashBatchResult, 'succeeded' | 'failed'>) {
|
||||
return result.failed.length ? `成功 ${result.succeeded.length} 项,失败 ${result.failed.length} 项` : `已完成 ${result.succeeded.length} 项`
|
||||
}
|
||||
Reference in new issue
Block a user