过滤id重复的歌曲
parent
798b840472
commit
4d7d92759f
|
@ -1,5 +1,7 @@
|
||||||
import music from '../../utils/music'
|
import music from '../../utils/music'
|
||||||
import { markRawList } from '@renderer/utils/vueTools'
|
import { markRawList } from '@renderer/utils/vueTools'
|
||||||
|
import { deduplicationList } from '@renderer/utils'
|
||||||
|
|
||||||
const sourceList = {}
|
const sourceList = {}
|
||||||
const sources = []
|
const sources = []
|
||||||
const cache = new Map()
|
const cache = new Map()
|
||||||
|
@ -57,6 +59,7 @@ const actions = {
|
||||||
// : music[source].leaderboard.getList(bangId, page)
|
// : music[source].leaderboard.getList(bangId, page)
|
||||||
// ).then(result => commit('setList', { result, key }))
|
// ).then(result => commit('setList', { result, key }))
|
||||||
return music[source].leaderboard.getList(bangId, page).then(result => {
|
return music[source].leaderboard.getList(bangId, page).then(result => {
|
||||||
|
result.list = deduplicationList(result.list)
|
||||||
cache.set(key, result)
|
cache.set(key, result)
|
||||||
listInfo.list = markRawList(result.list)
|
listInfo.list = markRawList(result.list)
|
||||||
listInfo.total = result.total
|
listInfo.total = result.total
|
||||||
|
@ -75,6 +78,7 @@ const actions = {
|
||||||
return cache.has(key)
|
return cache.has(key)
|
||||||
? Promise.resolve(cache.get(key))
|
? Promise.resolve(cache.get(key))
|
||||||
: music[source].leaderboard.getList(bangId, page).then(result => {
|
: music[source].leaderboard.getList(bangId, page).then(result => {
|
||||||
|
result.list = markRawList(deduplicationList(result.list))
|
||||||
cache.set(key, result)
|
cache.set(key, result)
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
@ -89,7 +93,7 @@ const actions = {
|
||||||
: loadData(id, loadPage).then(result1 => load(++loadPage).then(result2 => [...result1.list, ...result2]))
|
: loadData(id, loadPage).then(result1 => load(++loadPage).then(result2 => [...result1.list, ...result2]))
|
||||||
}
|
}
|
||||||
return load().then(result2 => [...result.list, ...result2])
|
return load().then(result2 => [...result.list, ...result2])
|
||||||
})
|
}).then(list => deduplicationList(list))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import music from '../../utils/music'
|
import music from '../../utils/music'
|
||||||
import { markRawList } from '@renderer/utils/vueTools'
|
import { markRawList } from '@renderer/utils/vueTools'
|
||||||
|
import { deduplicationList } from '@renderer/utils'
|
||||||
|
|
||||||
const sources = []
|
const sources = []
|
||||||
const sourceList = {}
|
const sourceList = {}
|
||||||
|
@ -85,7 +86,7 @@ sources.push({
|
||||||
})
|
})
|
||||||
|
|
||||||
// state
|
// state
|
||||||
const state = {
|
const state = window.state = {
|
||||||
sourceList,
|
sourceList,
|
||||||
list: [],
|
list: [],
|
||||||
text: '',
|
text: '',
|
||||||
|
@ -151,6 +152,7 @@ const mutations = {
|
||||||
},
|
},
|
||||||
setList(state, datas) {
|
setList(state, datas) {
|
||||||
let source = state.sourceList[datas.source]
|
let source = state.sourceList[datas.source]
|
||||||
|
datas.list = deduplicationList(datas.list)
|
||||||
source.list = markRawList(datas.list)
|
source.list = markRawList(datas.list)
|
||||||
source.total = datas.total
|
source.total = datas.total
|
||||||
source.allPage = datas.allPage
|
source.allPage = datas.allPage
|
||||||
|
@ -170,6 +172,7 @@ const mutations = {
|
||||||
total += source.total
|
total += source.total
|
||||||
// limit = Math.max(source.limit, limit)
|
// limit = Math.max(source.limit, limit)
|
||||||
}
|
}
|
||||||
|
list = deduplicationList(list)
|
||||||
state.allPage = Math.max(...pages)
|
state.allPage = Math.max(...pages)
|
||||||
state.total = total
|
state.total = total
|
||||||
state.limit = limit
|
state.limit = limit
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import music from '../../utils/music'
|
import music from '../../utils/music'
|
||||||
import { markRawList } from '@renderer/utils/vueTools'
|
import { markRawList } from '@renderer/utils/vueTools'
|
||||||
|
import { deduplicationList } from '@renderer/utils'
|
||||||
|
|
||||||
const sortList = {}
|
const sortList = {}
|
||||||
const sources = []
|
const sources = []
|
||||||
|
@ -91,6 +92,7 @@ const actions = {
|
||||||
? Promise.resolve(cache.get(key))
|
? Promise.resolve(cache.get(key))
|
||||||
: music[source]?.songList.getListDetail(id, page).then(result => ({ ...result, list: filterList(result.list) }))
|
: music[source]?.songList.getListDetail(id, page).then(result => ({ ...result, list: filterList(result.list) }))
|
||||||
).then(result => {
|
).then(result => {
|
||||||
|
result.list = markRawList(deduplicationList(result.list))
|
||||||
commit('setListDetail', { result, key, source, id, page })
|
commit('setListDetail', { result, key, source, id, page })
|
||||||
return result.list
|
return result.list
|
||||||
})
|
})
|
||||||
|
@ -103,6 +105,7 @@ const actions = {
|
||||||
return cache.has(key)
|
return cache.has(key)
|
||||||
? Promise.resolve(cache.get(key))
|
? Promise.resolve(cache.get(key))
|
||||||
: music[source]?.songList.getListDetail(id, page).then(result => {
|
: music[source]?.songList.getListDetail(id, page).then(result => {
|
||||||
|
result.list = markRawList(deduplicationList(result.list))
|
||||||
cache.set(key, result)
|
cache.set(key, result)
|
||||||
return result
|
return result
|
||||||
}) ?? Promise.reject(new Error('source not found'))
|
}) ?? Promise.reject(new Error('source not found'))
|
||||||
|
@ -117,7 +120,7 @@ const actions = {
|
||||||
: loadData(id, loadPage).then(result1 => loadDetail(++loadPage).then(result2 => [...result1.list, ...result2]))
|
: loadData(id, loadPage).then(result1 => loadDetail(++loadPage).then(result2 => [...result1.list, ...result2]))
|
||||||
}
|
}
|
||||||
return loadDetail().then(result2 => [...result.list, ...result2]).then(list => filterList(list))
|
return loadDetail().then(result2 => [...result.list, ...result2]).then(list => filterList(list))
|
||||||
})
|
}).then(list => deduplicationList(list))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +142,7 @@ const mutations = {
|
||||||
cache.set(key, result)
|
cache.set(key, result)
|
||||||
},
|
},
|
||||||
setListDetail(state, { result, key, source, id, page }) {
|
setListDetail(state, { result, key, source, id, page }) {
|
||||||
state.listDetail.list = markRawList(result.list)
|
state.listDetail.list = result.list
|
||||||
state.listDetail.id = id
|
state.listDetail.id = id
|
||||||
state.listDetail.source = source
|
state.listDetail.source = source
|
||||||
state.listDetail.total = result.total
|
state.listDetail.total = result.total
|
||||||
|
|
|
@ -571,3 +571,13 @@ export const getFontSizeWithScreen = (screenWidth = window.innerWidth) => {
|
||||||
? 20
|
? 20
|
||||||
: screenWidth <= 2560 ? 20 : 22
|
: screenWidth <= 2560 ? 20 : 22
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const deduplicationList = list => {
|
||||||
|
const ids = new Set()
|
||||||
|
return list.filter(s => {
|
||||||
|
if (ids.has(s.songmid)) return false
|
||||||
|
ids.add(s.songmid)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue