From 568af58103372440efe8a383978b35da5ead221e Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Thu, 29 May 2025 13:47:33 +1000 Subject: [PATCH] fix: fix an issue for the edge cases of resources url changing --- public/manifest.json | 2 +- src/components/PlayListItem.vue | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/public/manifest.json b/public/manifest.json index 4c0656c..fa21ab3 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -42,7 +42,7 @@ "storage" ], "content_security_policy": { - "extension_pages": "default-src 'self'; script-src 'self' http://localhost:5173; style-src 'self' 'unsafe-inline'; connect-src 'self' ws://localhost:5173 https://monster-siren.hypergryph.com https://web.hycdn.cn; img-src 'self' https://web.hycdn.cn; media-src 'self' https://res01.hycdn.cn;", + "extension_pages": "default-src 'self'; script-src 'self' http://localhost:5173; style-src 'self' 'unsafe-inline'; connect-src 'self' ws://localhost:5173 https://monster-siren.hypergryph.com https://web.hycdn.cn https://res01.hycdn.cn; img-src 'self' https://web.hycdn.cn; media-src 'self' https://res01.hycdn.cn;", "sandbox": "sandbox" } } \ No newline at end of file diff --git a/src/components/PlayListItem.vue b/src/components/PlayListItem.vue index 6090b0e..b29222d 100644 --- a/src/components/PlayListItem.vue +++ b/src/components/PlayListItem.vue @@ -2,14 +2,17 @@ import { artistsOrganize } from '../utils' import { ref } from 'vue' import { useFavourites } from '../stores/useFavourites' +import apis from '../apis' +import axios from 'axios' import StarSlashIcon from '../assets/icons/starslash.vue' +import { onMounted } from 'vue' const favourites = useFavourites() const hover = ref(false) -defineProps<{ +const props = defineProps<{ item: QueueItem index: number }>() @@ -17,6 +20,16 @@ defineProps<{ const emit = defineEmits<{ (e: 'play', index: number): void }>() + +onMounted(async () => { + try { + await axios.get(props.item.song.sourceUrl ?? '') + } catch (error) { } + // 刷新资源地址 + const updatedSong = await apis.getSong(props.item.song.cid) + console.log('Updated song:', updatedSong) + props.item.song.sourceUrl = updatedSong.sourceUrl +})