支持对移动端的位置同步调整

This commit is contained in:
lyswhut
2021-12-17 17:36:10 +08:00
parent e3acb7ce4e
commit d93b5a3374
2 changed files with 16 additions and 13 deletions
+13 -6
View File
@@ -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])
},