支持对移动端的位置同步调整
parent
e3acb7ce4e
commit
d93b5a3374
|
@ -17,10 +17,9 @@ export default () => {
|
|||
const createUserList = useCommit('list', 'createUserList')
|
||||
const removeUserList = useCommit('list', 'removeUserList')
|
||||
const setUserListName = useCommit('list', 'setUserListName')
|
||||
const moveupUserList = useCommit('list', 'moveupUserList')
|
||||
const movedownUserList = useCommit('list', 'movedownUserList')
|
||||
const setMusicPosition = useCommit('list', 'setMusicPosition')
|
||||
const setSyncListData = useCommit('list', 'setSyncListData')
|
||||
const setUserListPosition = useCommit('list', 'setUserListPosition')
|
||||
|
||||
const setting = useRefGetter('setting')
|
||||
|
||||
|
@ -65,11 +64,8 @@ export default () => {
|
|||
case 'set_user_list_name':
|
||||
setUserListName(data)
|
||||
break
|
||||
case 'moveup_user_list':
|
||||
moveupUserList(data)
|
||||
break
|
||||
case 'movedown_user_list':
|
||||
movedownUserList(data)
|
||||
case 'set_user_list_position':
|
||||
setUserListPosition(data)
|
||||
break
|
||||
case 'set_music_position':
|
||||
setMusicPosition(data)
|
||||
|
|
|
@ -362,11 +362,7 @@ const mutations = {
|
|||
|
||||
const index = userLists.findIndex(l => l.id == id)
|
||||
if (index < 0) return
|
||||
let targetList = userLists[index]
|
||||
userLists.splice(index, 1)
|
||||
userLists.splice(index - 1, 0, targetList)
|
||||
targetList.locationUpdateTime = Date.now()
|
||||
window.eventHub.emit(eventListNames.listChange, [id])
|
||||
this.commit('list/setUserListPosition', { id, position: index - 1 })
|
||||
},
|
||||
movedownUserList(state, { id, isSync }) {
|
||||
if (!isSync) {
|
||||
|
@ -377,9 +373,20 @@ const mutations = {
|
|||
}
|
||||
const index = userLists.findIndex(l => l.id == id)
|
||||
if (index < 0) return
|
||||
this.commit('list/setUserListPosition', { id, position: index + 1 })
|
||||
},
|
||||
setUserListPosition(state, { id, position, isSync }) {
|
||||
if (!isSync) {
|
||||
window.eventHub.emit(eventSyncName.send_action_list, {
|
||||
action: 'set_user_list_position',
|
||||
data: { id, position },
|
||||
})
|
||||
}
|
||||
const index = userLists.findIndex(l => l.id == id)
|
||||
if (index < 0) return
|
||||
let targetList = userLists[index]
|
||||
userLists.splice(index, 1)
|
||||
userLists.splice(index + 1, 0, targetList)
|
||||
userLists.splice(Math.max(Math.min(position, userLists.length - 1), 0), 0, targetList)
|
||||
targetList.locationUpdateTime = Date.now()
|
||||
window.eventHub.emit(eventListNames.listChange, [id])
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue