From 853546f3d201e2ecfbbcf57f5496226798c54b13 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 10 May 2026 15:15:13 -0500 Subject: [PATCH] Fix cover image sampling not working when webview strips origin header, instead fetch image from server with CapacitorHttp --- components/app/AudioPlayer.vue | 21 ++++++------ pages/item/_id/index.vue | 19 ++++------- plugins/nativeHttp.js | 6 ++-- utils/coverAverageColor.js | 59 ++++++++++++++++++++++++++++++++++ utils/imageHttpBlob.js | 40 +++++++++++++++++++++++ 5 files changed, 118 insertions(+), 27 deletions(-) create mode 100644 utils/coverAverageColor.js create mode 100644 utils/imageHttpBlob.js diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index 907a4587..4d83d125 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -114,7 +114,7 @@ import { Capacitor } from '@capacitor/core' import { AbsAudioPlayer } from '@/plugins/capacitor' import { Dialog } from '@capacitor/dialog' -import { FastAverageColor } from 'fast-average-color' +import { getAverageColorFromCoverUrl } from '@/utils/coverAverageColor' import WrappingMarquee from '@/assets/WrappingMarquee.js' import jumpLabelMixin from '@/mixins/jumpLabel' @@ -412,17 +412,14 @@ export default { }, async coverImageLoaded(fullCoverUrl) { if (!fullCoverUrl) return - - const fac = new FastAverageColor() - fac - .getColorAsync(fullCoverUrl) - .then((color) => { - this.coverRgb = color.rgba - this.coverBgIsLight = color.isLight - }) - .catch((e) => { - console.log(e) - }) + const avg = await getAverageColorFromCoverUrl(this, fullCoverUrl) + if (!avg) { + this.coverRgb = 'rgb(55, 56, 56)' + this.coverBgIsLight = false + } else { + this.coverRgb = avg.rgba + this.coverBgIsLight = avg.isLight + } }, clickTitleAndAuthor() { if (!this.showFullscreen) return diff --git a/pages/item/_id/index.vue b/pages/item/_id/index.vue index 4966eecf..3cec7392 100644 --- a/pages/item/_id/index.vue +++ b/pages/item/_id/index.vue @@ -13,7 +13,7 @@
- +
@@ -172,7 +172,7 @@