直接从歌单详情收藏的列表新增同步功能
parent
2056bdb43d
commit
f1049169b5
|
@ -1,3 +1,6 @@
|
||||||
|
### 新增
|
||||||
|
|
||||||
|
- 直接从歌单详情收藏的列表新增同步功能。注意:这将会覆盖本地的目标列表,歌曲将被替换成最新的在线列表
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,21 @@ export default {
|
||||||
getPlayList().then(({ defaultList, loveList, userList, downloadList }) => {
|
getPlayList().then(({ defaultList, loveList, userList, downloadList }) => {
|
||||||
if (!defaultList) defaultList = this.defaultList
|
if (!defaultList) defaultList = this.defaultList
|
||||||
if (!loveList) loveList = this.loveList
|
if (!loveList) loveList = this.loveList
|
||||||
if (!userList) userList = this.userList
|
if (userList) {
|
||||||
|
let needSave = false
|
||||||
|
const getListId = id => id.includes('.') ? getListId(id.substring(0, id.lastIndexOf('_'))) : id
|
||||||
|
userList.forEach(l => {
|
||||||
|
if (!l.id.includes('__') || l.source) return
|
||||||
|
let [source, id] = l.id.split('__')
|
||||||
|
id = getListId(id)
|
||||||
|
l.source = source
|
||||||
|
l.sourceListId = id
|
||||||
|
if (!needSave) needSave = true
|
||||||
|
})
|
||||||
|
if (needSave) this.this.saveUserList(userList)
|
||||||
|
} else {
|
||||||
|
userList = this.userList
|
||||||
|
}
|
||||||
|
|
||||||
if (!defaultList.list) defaultList.list = []
|
if (!defaultList.list) defaultList.list = []
|
||||||
if (!loveList.list) loveList.list = []
|
if (!loveList.list) loveList.list = []
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"lists_rename": "Rename",
|
"lists_rename": "Rename",
|
||||||
"lists_moveup": "Move Up",
|
"lists_moveup": "Move Up",
|
||||||
"lists_movedown": "Move Down",
|
"lists_movedown": "Move Down",
|
||||||
|
"lists_sync": "Sync",
|
||||||
"lists_remove": "Remove",
|
"lists_remove": "Remove",
|
||||||
"list_play": "Play",
|
"list_play": "Play",
|
||||||
"list_copy_name": "Copy name",
|
"list_copy_name": "Copy name",
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"lists_rename": "重命名",
|
"lists_rename": "重命名",
|
||||||
"lists_moveup": "上移",
|
"lists_moveup": "上移",
|
||||||
"lists_movedown": "下移",
|
"lists_movedown": "下移",
|
||||||
|
"lists_sync": "同步",
|
||||||
"lists_remove": "删除",
|
"lists_remove": "删除",
|
||||||
"list_play": "播放",
|
"list_play": "播放",
|
||||||
"list_copy_name": "复制歌曲名",
|
"list_copy_name": "复制歌曲名",
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"lists_rename": "重命名",
|
"lists_rename": "重命名",
|
||||||
"lists_moveup": "上移",
|
"lists_moveup": "上移",
|
||||||
"lists_movedown": "下移",
|
"lists_movedown": "下移",
|
||||||
|
"lists_sync": "同步",
|
||||||
"lists_remove": "刪除",
|
"lists_remove": "刪除",
|
||||||
"list_play": "播放",
|
"list_play": "播放",
|
||||||
"list_copy_name": "複製歌曲名",
|
"list_copy_name": "複製歌曲名",
|
||||||
|
|
|
@ -60,7 +60,7 @@ const mutations = {
|
||||||
allListInit(state.defaultList, state.loveList, state.userList)
|
allListInit(state.defaultList, state.loveList, state.userList)
|
||||||
state.isInitedList = true
|
state.isInitedList = true
|
||||||
},
|
},
|
||||||
setList(state, { id, list, name, location }) {
|
setList(state, { id, list, name, location, source, sourceListId }) {
|
||||||
const targetList = allList[id]
|
const targetList = allList[id]
|
||||||
if (targetList) {
|
if (targetList) {
|
||||||
if (name && targetList.name === name) {
|
if (name && targetList.name === name) {
|
||||||
|
@ -76,6 +76,8 @@ const mutations = {
|
||||||
id,
|
id,
|
||||||
list,
|
list,
|
||||||
location,
|
location,
|
||||||
|
source,
|
||||||
|
sourceListId,
|
||||||
}
|
}
|
||||||
state.userList.push(newList)
|
state.userList.push(newList)
|
||||||
allListUpdate(newList)
|
allListUpdate(newList)
|
||||||
|
@ -145,7 +147,7 @@ const mutations = {
|
||||||
if (!targetList) return
|
if (!targetList) return
|
||||||
Object.assign(targetList.list[index], data)
|
Object.assign(targetList.list[index], data)
|
||||||
},
|
},
|
||||||
createUserList(state, { name, id = `userlist_${Date.now()}`, list = [] }) {
|
createUserList(state, { name, id = `userlist_${Date.now()}`, list = [], source, sourceListId }) {
|
||||||
let newList = state.userList.find(item => item.id === id)
|
let newList = state.userList.find(item => item.id === id)
|
||||||
if (!newList) {
|
if (!newList) {
|
||||||
newList = {
|
newList = {
|
||||||
|
@ -153,6 +155,8 @@ const mutations = {
|
||||||
id,
|
id,
|
||||||
list: [],
|
list: [],
|
||||||
location: 0,
|
location: 0,
|
||||||
|
source,
|
||||||
|
sourceListId,
|
||||||
}
|
}
|
||||||
state.userList.push(newList)
|
state.userList.push(newList)
|
||||||
allListUpdate(newList)
|
allListUpdate(newList)
|
||||||
|
|
|
@ -81,8 +81,8 @@ const actions = {
|
||||||
: music[source].songList.getListDetail(id, page)
|
: music[source].songList.getListDetail(id, page)
|
||||||
).then(result => commit('setListDetail', { result, key, source, id, page }))
|
).then(result => commit('setListDetail', { result, key, source, id, page }))
|
||||||
},
|
},
|
||||||
getListDetailAll({ state, rootState }, id) {
|
getListDetailAll({ state, rootState }, { source, id }) {
|
||||||
let source = rootState.setting.songList.source
|
// console.log(source, id)
|
||||||
const loadData = (id, page) => {
|
const loadData = (id, page) => {
|
||||||
let key = `sdetail__${source}__${id}__${page}`
|
let key = `sdetail__${source}__${id}__${page}`
|
||||||
return cache.has(key)
|
return cache.has(key)
|
||||||
|
|
|
@ -100,6 +100,7 @@ export default {
|
||||||
isShowItemMenu: false,
|
isShowItemMenu: false,
|
||||||
itemMenuControl: {
|
itemMenuControl: {
|
||||||
rename: true,
|
rename: true,
|
||||||
|
sync: false,
|
||||||
moveup: true,
|
moveup: true,
|
||||||
movedown: true,
|
movedown: true,
|
||||||
remove: true,
|
remove: true,
|
||||||
|
@ -131,6 +132,7 @@ export default {
|
||||||
isMove: false,
|
isMove: false,
|
||||||
isMoveMultiple: false,
|
isMoveMultiple: false,
|
||||||
isVisibleMusicSearch: false,
|
isVisibleMusicSearch: false,
|
||||||
|
fetchingListStatus: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -180,6 +182,11 @@ export default {
|
||||||
action: 'rename',
|
action: 'rename',
|
||||||
disabled: !this.listsData.itemMenuControl.rename,
|
disabled: !this.listsData.itemMenuControl.rename,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: this.$t('view.list.lists_sync'),
|
||||||
|
action: 'sync',
|
||||||
|
disabled: !this.listsData.itemMenuControl.sync,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: this.$t('view.list.lists_moveup'),
|
name: this.$t('view.list.lists_moveup'),
|
||||||
action: 'moveup',
|
action: 'moveup',
|
||||||
|
@ -309,7 +316,18 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['setPrevSelectListId']),
|
...mapMutations(['setPrevSelectListId']),
|
||||||
...mapMutations('list', ['listRemove', 'listRemoveMultiple', 'setUserListName', 'createUserList', 'moveupUserList', 'movedownUserList', 'removeUserList', 'setListScroll']),
|
...mapMutations('list', [
|
||||||
|
'listRemove',
|
||||||
|
'listRemoveMultiple',
|
||||||
|
'setUserListName',
|
||||||
|
'createUserList',
|
||||||
|
'moveupUserList',
|
||||||
|
'movedownUserList',
|
||||||
|
'removeUserList',
|
||||||
|
'setListScroll',
|
||||||
|
'setList',
|
||||||
|
]),
|
||||||
|
...mapActions('songList', ['getListDetailAll']),
|
||||||
...mapActions('download', ['createDownload', 'createDownloadMultiple']),
|
...mapActions('download', ['createDownload', 'createDownloadMultiple']),
|
||||||
...mapMutations('player', {
|
...mapMutations('player', {
|
||||||
setPlayList: 'setList',
|
setPlayList: 'setList',
|
||||||
|
@ -668,6 +686,8 @@ export default {
|
||||||
}).catch(_ => _)
|
}).catch(_ => _)
|
||||||
},
|
},
|
||||||
handleListsItemRigthClick(event, index) {
|
handleListsItemRigthClick(event, index) {
|
||||||
|
const source = this.userList[index].source
|
||||||
|
this.listsData.itemMenuControl.sync = !!source && !!musicSdk[source].songList
|
||||||
this.listsData.itemMenuControl.moveup = index > 0
|
this.listsData.itemMenuControl.moveup = index > 0
|
||||||
this.listsData.itemMenuControl.movedown = index < this.userList.length - 1
|
this.listsData.itemMenuControl.movedown = index < this.userList.length - 1
|
||||||
this.listsData.rightClickItemIndex = index
|
this.listsData.rightClickItemIndex = index
|
||||||
|
@ -714,6 +734,9 @@ export default {
|
||||||
dom.querySelector('input').focus()
|
dom.querySelector('input').focus()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
case 'sync':
|
||||||
|
this.handleSyncSourceList(index)
|
||||||
|
break
|
||||||
case 'moveup':
|
case 'moveup':
|
||||||
this.moveupUserList(index)
|
this.moveupUserList(index)
|
||||||
break
|
break
|
||||||
|
@ -814,6 +837,27 @@ export default {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
fetchList(id, source, sourceListId) {
|
||||||
|
if (this.fetchingListStatus[id] == null) {
|
||||||
|
this.$set(this.fetchingListStatus, id, true)
|
||||||
|
} else {
|
||||||
|
this.fetchingListStatus[id] = true
|
||||||
|
}
|
||||||
|
return this.getListDetailAll({ source, id: sourceListId }).catch(err => {
|
||||||
|
return Promise.reject(err)
|
||||||
|
}).finally(() => {
|
||||||
|
this.fetchingListStatus[id] = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async handleSyncSourceList(index) {
|
||||||
|
const targetList = this.userList[index]
|
||||||
|
const list = await this.fetchList(targetList.id, targetList.source, targetList.sourceListId)
|
||||||
|
// console.log(targetList.list.length, list.length)
|
||||||
|
this.setList({
|
||||||
|
...targetList,
|
||||||
|
list,
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -405,14 +405,22 @@ export default {
|
||||||
},
|
},
|
||||||
async fetchList() {
|
async fetchList() {
|
||||||
this.detailLoading = true
|
this.detailLoading = true
|
||||||
const list = await this.getListDetailAll(this.selectListInfo.id)
|
return this.getListDetailAll({ source: this.source, id: this.selectListInfo.id }).catch(err => {
|
||||||
|
return Promise.reject(err)
|
||||||
|
}).finally(() => {
|
||||||
this.detailLoading = false
|
this.detailLoading = false
|
||||||
return list
|
})
|
||||||
},
|
},
|
||||||
async addSongListDetail() {
|
async addSongListDetail() {
|
||||||
if (!this.listDetail.info.name) return
|
if (!this.listDetail.info.name) return
|
||||||
const list = await this.fetchList()
|
const list = await this.fetchList()
|
||||||
this.createUserList({ name: this.listDetail.info.name, id: `${this.listDetail.source}__${this.listDetail.id}`, list })
|
this.createUserList({
|
||||||
|
name: this.listDetail.info.name,
|
||||||
|
id: `${this.listDetail.source}__${this.listDetail.id}`,
|
||||||
|
list,
|
||||||
|
source: this.listDetail.source,
|
||||||
|
sourceListId: this.listDetail.id,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
async playSongListDetail() {
|
async playSongListDetail() {
|
||||||
if (!this.listDetail.info.name) return
|
if (!this.listDetail.info.name) return
|
||||||
|
|
Loading…
Reference in New Issue