diff --git a/publish/changeLog.md b/publish/changeLog.md index bdb5f74..93960ff 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,6 +1,11 @@ +### 新增 + +- 同步功能新增对列表位置调整的支持(若你使用同步功能,请务必升级到此版本以上,不然会有问题) + ### 优化 - 修改对播放模块的调用,杜绝应用显示正在播放的歌曲与实际播放歌曲不一致的问题(这是播放模块歌曲队列与应用内歌曲队列在某些情况下出现不一致时导致的) +- 支持PC端同步功能添加对列表顺序调整的控制,确保手动调整位置后的列表与不同的电脑同步时,列表位置不会被还原 ### 修复 diff --git a/src/plugins/sync/modules/list/on.js b/src/plugins/sync/modules/list/on.js index e05ed51..45969f8 100644 --- a/src/plugins/sync/modules/list/on.js +++ b/src/plugins/sync/modules/list/on.js @@ -15,9 +15,7 @@ import { removeUserList, setUserListName, setMusicPosition, - // moveupUserList, - // movedownUserList, - // setUserListPosition, + setUserListPosition, } from '@/store/modules/list/action' const store = getStore() @@ -70,6 +68,9 @@ const handleListAction = enMsg => { case 'set_user_list_name': store.dispatch(setUserListName(data)) break + case 'set_user_list_position': + store.dispatch(setUserListPosition(data)) + break case 'set_music_position': store.dispatch(setMusicPosition(data)) break diff --git a/src/store/modules/list/action.js b/src/store/modules/list/action.js index 148fc03..6d095c1 100644 --- a/src/store/modules/list/action.js +++ b/src/store/modules/list/action.js @@ -328,7 +328,11 @@ export const setUserListName = ({ id, name, isSync }) => async(dispatch, getStat const targetList = global.allList[id] await saveList(targetList) } -export const setUserListPosition = ({ id, position }) => async(dispatch, getState) => { +export const setUserListPosition = ({ id, position, isSync }) => async(dispatch, getState) => { + if (!isSync) { + listSync.sendListAction('set_user_list_position', { id, position }) + } + dispatch({ type: TYPES.setUserListPosition, payload: { id, position }, diff --git a/src/store/modules/list/reducer.js b/src/store/modules/list/reducer.js index 53c7b91..10fa9bf 100644 --- a/src/store/modules/list/reducer.js +++ b/src/store/modules/list/reducer.js @@ -253,6 +253,7 @@ const mutations = { if (position == null) { userList.push(newList) } else { + newList.locationUpdateTime = Date.now() userList.splice(position + 1, 0, newList) } newState.userList = userList @@ -279,7 +280,7 @@ const mutations = { const index = state.userList.findIndex(targetList) if (index < 0) return state state.userList.splice(index, 1) - state.userList.splice(index, position, targetList) + state.userList.splice(Math.max(Math.min(position, state.userList.length - 1), 0), 0, targetList) return updateStateList({ ...state }, [id]) }, [TYPES.setMusicPosition](state, { id, position, list }) {