refactor: 重构设置、API、图库与存储页面前端结构。

将操作日志并入设置侧栏,补齐检查更新提示与版本接口刷新;拆分各模块组件并修复图库搜索分页变量。
This commit is contained in:
O96u committed 2026-09-01 17:15:02 +08:00
1 parent 270af4e707
commit ac65c1eb9d
51 files changed
+5119 -2059

No files matched your search

+39 -5
View File
@@ -7,6 +7,34 @@ import {
getFolderStorageStats,
getUserScopedStorageStats
} from '../utils/storage'
import { buildBackendCapacity } from '../utils/storage-capacity'
import { getActiveBackendRow } from '../utils/storage/resolver'
interface StorageUsageStat {
usedBytes: number
totalBytes: number | null
percent: number | null
}
async function resolveStorageUsage(usedBytes: number): Promise<StorageUsageStat> {
const backend = getActiveBackendRow()
if (!backend) {
return { usedBytes, totalBytes: null, percent: null }
}
const capacity = await buildBackendCapacity(
backend.id,
backend.type,
usedBytes,
backend.quota_bytes
)
return {
usedBytes,
totalBytes: capacity.totalBytes,
percent: capacity.percent
}
}
export default defineEventHandler(async (event) => {
const user = await requireUserAuth(event)
@@ -14,25 +42,30 @@ export default defineEventHandler(async (event) => {
try {
if (user.role === 'admin' && userFilter === 'admin') {
const [activity, storedCount, byFolder] = await Promise.all([
Promise.resolve(getActivityStats()),
const activity = getActivityStats()
const [storedCount, byFolder, storageUsage] = await Promise.all([
countImages(),
getFolderStorageStats()
getFolderStorageStats(),
resolveStorageUsage(activity.uploadBytesTotal)
])
return {
...activity,
storedCount,
byFolder,
userCount: countUsers()
userCount: countUsers(),
storageUsage
}
}
const scoped = await getUserScopedStorageStats(user.id)
const storageUsage = await resolveStorageUsage(scoped.uploadBytesTotal)
return {
uploadToday: scoped.uploadToday,
uploadYesterday: scoped.uploadYesterday,
uploadMonth: scoped.uploadMonth,
uploadLastMonth: scoped.uploadLastMonth,
deleteToday: 0,
deleteMonth: 0,
uploadTotal: scoped.storedCount,
@@ -44,7 +77,8 @@ export default defineEventHandler(async (event) => {
count: item.count
})),
storedCount: scoped.storedCount,
byFolder: scoped.byFolder
byFolder: scoped.byFolder,
storageUsage
}
} catch (error) {
logException('stats failed', error)