diff --git a/src/@core/utils/formatters.ts b/src/@core/utils/formatters.ts index 1b54972c..4a8b4d3f 100644 --- a/src/@core/utils/formatters.ts +++ b/src/@core/utils/formatters.ts @@ -60,19 +60,25 @@ export const prefixWithPlus = (value: number) => (value > 0 ? `+${value}` : valu export const formatSeason = (value: string) => (value ? `S${value.padStart(2, '0')}` : '') // 格式化为xx[TGMK]B -export function formatFileSize(bytes: number, decimals = 2) { - if (bytes < 0) throw new Error('字节数不能为负数。') +export function formatFileSize(bytes: number, decimals = 2, prefix = false) { + // 负数标记 + let negative = false + let size = bytes + if (bytes < 0) { + negative = true + size = Math.abs(bytes) + } const units = ['B', 'KB', 'MB', 'GB', 'TB'] - let size = bytes let unitIndex = 0 while (size >= 1024 && unitIndex < units.length - 1) { size /= 1024 unitIndex++ } - - return `${size.toFixed(decimals)} ${units[unitIndex]}` + if (negative) return `-${size.toFixed(decimals)} ${units[unitIndex]}` + else + return prefix ? `+${size.toFixed(decimals)} ${units[unitIndex]}` : `${size.toFixed(decimals)} ${units[unitIndex]}` } // 将时间秒格式化为时分秒 diff --git a/src/api/types.ts b/src/api/types.ts index b0ad8df9..7ecea116 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -471,6 +471,10 @@ export interface SiteUserData { message_unread_contents?: any[] // 默认为空数组 // 错误信息 err_msg?: string | null // 默认为 null + // 更新日期 + updated_day?: string + // 更新时间 + updated_time?: string } // 正在下载 diff --git a/src/components/dialog/SiteUserDataDialog.vue b/src/components/dialog/SiteUserDataDialog.vue index 67aba6ad..0ad530e4 100644 --- a/src/components/dialog/SiteUserDataDialog.vue +++ b/src/components/dialog/SiteUserDataDialog.vue @@ -1,7 +1,11 @@ - + - + + + + + + + + + 用户等级 + + {{ siteData?.user_level || '无' }} + + + + + + + + + + + + + + + + 积分 + + {{ siteData?.bonus?.toLocaleString() }} + + ({{ getDiffString(diffData?.bonus) }}) + + + + + + + + + + + + + + + + + 分享率 + + {{ siteData?.ratio }} + + ({{ getDiffString(diffData?.ratio) }}) + + + + + + + + + + + + + + + + + 总上传量 + + {{ formatFileSize(siteData?.upload || 0) }} + + ({{ formatFileSize(diffData?.upload || 0, 2, true) }}) + + + + + + + + + + + + + + + + + 总下载量 + + {{ formatFileSize(siteData?.download || 0) }} + + ({{ formatFileSize(diffData?.download || 0, 2, true) }}) + + + + + + + + + + + + + + + + + 总做种数 + + {{ siteData?.seeding?.toLocaleString() }} + + ({{ getDiffString(diffData?.seeding) }}) + + + + + + + + + + + + + + + + + 总做种体积 + + {{ formatFileSize(siteData?.seeding_size || 0) }} + + ({{ formatFileSize(diffData?.seeding_size || 0, 2, true) }}) + + + + + + + + + + + + + + + + + 加入时间 + + {{ siteData?.join_at?.split(' ')[0] }} + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/dialog/UserAddEditDialog.vue b/src/components/dialog/UserAddEditDialog.vue index c0ec2e1b..8b1615a5 100644 --- a/src/components/dialog/UserAddEditDialog.vue +++ b/src/components/dialog/UserAddEditDialog.vue @@ -218,14 +218,14 @@ watch(() => store.state.auth.avatar, () => { - + - 还原当前头像 + 重置 - - 重置默认头像 + + 默认 diff --git a/src/views/user/UserProfileView.vue b/src/views/user/UserProfileView.vue index f2db1bf0..6d55a61c 100644 --- a/src/views/user/UserProfileView.vue +++ b/src/views/user/UserProfileView.vue @@ -1,12 +1,12 @@ @@ -235,18 +237,18 @@ watch(() => store.state.auth.avatar, () => { @input="changeAvatar" /> - + - 还原当前头像 + 重置 - - 重置默认头像 + + 默认