fix cloud library mounts and artwork caching

This commit is contained in:
ShukeBta
2026-06-10 20:43:42 +08:00
parent 0bf983cec8
commit fd0428ee7d
36 changed files with 1469 additions and 140 deletions
+6
View File
@@ -151,9 +151,15 @@ export function hlsURL(mediaId: string): string {
export function imageURL(remote?: string): string {
if (!remote) return ''
if (remote.startsWith('/api/img')) return remote
if (remote.startsWith('/api/')) return withQuery(remote, tokenQuery())
return `/api/img?url=${encodeURIComponent(remote)}&${tokenQuery()}`
}
function withQuery(url: string, query: string): string {
if (!query) return url
return `${url}${url.includes('?') ? '&' : '?'}${query}`
}
// getToken returns the current auth token
export function getToken(): string | null {
return useAuthStore.getState().token
+35
View File
@@ -48,6 +48,24 @@ export interface CloudUploadResult {
}>
}
export interface CloudScanStatus {
library_id: string
provider: string
stage: string
state: string
dirs: number
discovered: number
visited: number
added: number
updated: number
skipped: number
removed: number
error?: string
resume_hint?: string
estimate_message?: string
files_per_second?: number
}
export const storageAPI = {
status: () =>
api
@@ -83,6 +101,23 @@ export const storageAPI = {
api
.post<{ result: CloudUploadResult; error?: string }>(`/admin/storage/${type}/upload-local`, input)
.then((r) => r.data),
scanAllCloud: () =>
api
.post<{ items: CloudScanStatus[]; message?: string; estimate_message?: string }>('/admin/cloud/scan-all')
.then((r) => r.data),
cancelCloudScan: (libraryID = '', provider = '') =>
api
.post<{ cancelled: number; message?: string }>('/admin/cloud/scan/cancel', null, {
params: libraryID ? { library_id: libraryID } : provider ? { provider } : undefined,
})
.then((r) => r.data),
cloudScanStatus: () =>
api
.get<{ items: CloudScanStatus[] }>('/admin/cloud/scan/status')
.then((r) => r.data),
}
// cloudAPI drives 网盘 browsing, QR login and 302 import.