This repository was archived by the owner on Jul 17, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<!-- 图片组件 -->
22<template >
3- <Transition name="fade" mode="out-in">
4- <div ref =" imgContainer" :key =" src" class =" s-image" >
5- <!-- 加载图片 -->
6- <Transition name="fade">
7- <img v-if =" !isLoaded" :src =" defaultSrc" class =" loading" alt =" loading" />
8- </Transition >
9- <!-- 真实图片 -->
10- <img
11- v-if =" imgSrc"
12- ref =" imgRef"
13- :src =" imgSrc"
14- :key =" imgSrc"
15- :alt =" alt || 'image'"
16- :class =" ['cover', { loaded: isLoaded }]"
17- :decoding =" decodeAsync ? 'async' : 'auto'"
18- :loading =" nativeLazy ? 'lazy' : 'eager'"
19- @load =" imageLoaded"
20- @error =" imageError"
21- />
22- </div >
23- </Transition >
3+ <div ref =" imgContainer" :key =" src" class =" s-image" >
4+ <!-- 加载图片 -->
5+ <Transition name="fade">
6+ <img v-if =" !isLoaded" :src =" defaultSrc" class =" loading" alt =" loading" />
7+ </Transition >
8+ <!-- 真实图片 -->
9+ <img
10+ v-if =" imgSrc"
11+ ref =" imgRef"
12+ :src =" imgSrc"
13+ :key =" imgSrc"
14+ :alt =" alt || 'image'"
15+ :class =" ['cover', { loaded: isLoaded }]"
16+ :decoding =" decodeAsync ? 'async' : 'auto'"
17+ :loading =" nativeLazy ? 'lazy' : 'eager'"
18+ @load =" imageLoaded"
19+ @error =" imageError"
20+ />
21+ </div >
2422</template >
2523
2624<script setup lang="ts">
Original file line number Diff line number Diff line change 7979
8080<script setup lang="ts">
8181import { useMusicStore , useStatusStore , useSettingStore } from " @/stores" ;
82+ import blob from " @/utils/blob" ;
8283import init from " @/utils/init" ;
8384
8485const musicStore = useMusicStore ();
@@ -94,6 +95,8 @@ const { height: contentHeight } = useElementSize(contentRef);
9495// 离开前提醒
9596window .addEventListener (" beforeunload" , (event ) => {
9697 event .preventDefault ();
98+ // 释放所有 blob URL
99+ blob .revokeAllBlobURLs ();
97100 event .returnValue = " " ;
98101});
99102
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { SongType } from "@/types/main";
33import { isElectron } from "@/utils/env" ;
44import { cloneDeep } from "lodash-es" ;
55import { SongLyric } from "@/types/lyric" ;
6+ import blob from "@/utils/blob" ;
67
78interface MusicState {
89 playSong : SongType ;
@@ -80,6 +81,16 @@ export const useMusicStore = defineStore("music", {
8081 actions : {
8182 /** 重置音乐数据 */
8283 resetMusicData ( ) {
84+ // 清理旧的 blob URL(如果 cover 是 blob URL)
85+ const oldCover = this . playSong . cover ;
86+ const oldPath = this . playSong . path ;
87+ if ( oldCover && oldCover . startsWith ( "blob:" ) && oldPath ) {
88+ try {
89+ blob . revokeBlobURL ( oldPath ) ;
90+ } catch ( e ) {
91+ // 忽略错误
92+ }
93+ }
8394 this . playSong = { ...defaultMusicData } ;
8495 this . setSongLyric ( { lrcData : [ ] , yrcData : [ ] } , true ) ;
8596 if ( isElectron ) {
Original file line number Diff line number Diff line change @@ -451,6 +451,16 @@ class Player {
451451 try {
452452 const musicStore = useMusicStore ( ) ;
453453 const statusStore = useStatusStore ( ) ;
454+ // 清理旧的 blob URL(如果存在)
455+ const oldCover = musicStore . playSong . cover ;
456+ const oldPath = musicStore . playSong . path ;
457+ if ( oldCover && oldCover . startsWith ( "blob:" ) && oldPath && oldPath !== path ) {
458+ try {
459+ blob . revokeBlobURL ( oldPath ) ;
460+ } catch ( e ) {
461+ // 忽略错误
462+ }
463+ }
454464 // 获取封面数据
455465 const coverData = await window . electron . ipcRenderer . invoke ( "get-music-cover" , path ) ;
456466 if ( coverData ) {
You can’t perform that action at this time.
0 commit comments