mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 12:06:38 +08:00
fix: harden discover artwork caching
This commit is contained in:
+12
-2
@@ -151,11 +151,21 @@ export function hlsURL(mediaId: string): string {
|
||||
|
||||
// imageURL converts a remote poster URL into a same-origin proxy URL so it
|
||||
// can never be blocked by CORS / GFW. Empty strings pass through unchanged.
|
||||
export function imageURL(remote?: string, version?: string, retryFailed = false): string {
|
||||
export type ImageURLOptions =
|
||||
| boolean
|
||||
| {
|
||||
refreshCache?: boolean
|
||||
retryFailed?: boolean
|
||||
}
|
||||
|
||||
export function imageURL(remote?: string, version?: string, options: ImageURLOptions = false): string {
|
||||
if (!remote) return ''
|
||||
const versionQuery = version ? `v=${encodeURIComponent(version)}` : ''
|
||||
const retryFailed = typeof options === 'boolean' ? options : Boolean(options.retryFailed)
|
||||
const refreshCache = typeof options === 'boolean' ? false : Boolean(options.refreshCache)
|
||||
const retryQuery = retryFailed ? 'retry=1' : ''
|
||||
const imageQuery = [versionQuery, retryQuery].filter(Boolean).join('&')
|
||||
const refreshQuery = refreshCache ? 'refresh=1' : ''
|
||||
const imageQuery = [versionQuery, retryQuery, refreshQuery].filter(Boolean).join('&')
|
||||
if (remote.startsWith('/api/img')) return withQuery(withoutAuthQuery(remote), imageQuery)
|
||||
if (remote.startsWith('/api/cloud/play/')) return withQuery(withoutAuthQuery(remote), imageQuery)
|
||||
if (remote.startsWith('/api/')) return withQuery(withQuery(remote, tokenQuery()), imageQuery)
|
||||
|
||||
Reference in New Issue
Block a user