mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-18 08:47:34 +08:00
feat: 优化媒体服务器库和播放列表的添加逻辑,避免重复项
This commit is contained in:
@@ -26,7 +26,11 @@ async function loadLibrary(server: string) {
|
||||
params: { server: server, hidden: true },
|
||||
})
|
||||
if (result && result.length > 0) {
|
||||
libraryList.value = libraryList.value.concat(result)
|
||||
// 不存在时添加
|
||||
for (const item of result) {
|
||||
const index = libraryList.value.findIndex(i => i.id === item.id)
|
||||
if (index === -1) libraryList.value.push(item)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
||||
@@ -24,7 +24,11 @@ async function loadPlayingList(server: string) {
|
||||
try {
|
||||
const result: MediaServerPlayItem[] = await api.get('mediaserver/playing', { params: { server } })
|
||||
if (result && result.length > 0) {
|
||||
playingList.value = playingList.value.concat(result)
|
||||
// 不存在时添加
|
||||
for (const item of result) {
|
||||
const index = playingList.value.findIndex(i => i.id === item.id)
|
||||
if (index === -1) playingList.value = playingList.value.concat(result)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
||||
Reference in New Issue
Block a user