降低反复提取封面耗时
This commit is contained in:
parent
277e2dd5b9
commit
f16e3f62cb
@ -30,7 +30,8 @@ await database.store('musicObjectStore') // 音乐(为什么会用这么丑的
|
||||
|
||||
// 读取本地音乐列表并标识为缓存状态(本地缓存)
|
||||
const list = await Promise.all((await database.getAll('musicObjectStore')).map(async item => {
|
||||
if (!item.picture) {
|
||||
if (!item.picture && item.picture !== false) {
|
||||
console.log('提取封面', item.name)
|
||||
const blob = new Blob([item.arrayBuffer], { type: item.type })
|
||||
const metadata = await parseBlob(blob)
|
||||
const picture = metadata.common.picture?.[0]
|
||||
@ -38,7 +39,10 @@ const list = await Promise.all((await database.getAll('musicObjectStore')).map(a
|
||||
const format = picture.format
|
||||
const data = picture.data
|
||||
item.picture = `data:${format};base64,${Buffer.from(data).toString('base64')}`
|
||||
} else {
|
||||
item.picture = false
|
||||
}
|
||||
database.put('musicObjectStore', item)
|
||||
}
|
||||
return { save: true, ...item }
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user