fix: 修复创建幻灯片再撤销后索引异常的bug

This commit is contained in:
pipipi-pikachu 2021-02-27 00:48:32 +08:00
parent 8787c5d5b7
commit 345a9b6600

View File

@ -61,8 +61,10 @@ export const actions: ActionTree<State, State> = {
const snapshot = snapshots[snapshotCursor] const snapshot = snapshots[snapshotCursor]
const { index, slides } = snapshot const { index, slides } = snapshot
const slideIndex = index > slides.length - 1 ? slides.length - 1 : index
commit(MutationTypes.SET_SLIDES, slides) commit(MutationTypes.SET_SLIDES, slides)
commit(MutationTypes.UPDATE_SLIDE_INDEX, index) commit(MutationTypes.UPDATE_SLIDE_INDEX, slideIndex)
commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotCursor) commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotCursor)
commit(MutationTypes.SET_ACTIVE_ELEMENT_ID_LIST, []) commit(MutationTypes.SET_ACTIVE_ELEMENT_ID_LIST, [])
}, },
@ -75,8 +77,10 @@ export const actions: ActionTree<State, State> = {
const snapshot = snapshots[snapshotCursor] const snapshot = snapshots[snapshotCursor]
const { index, slides } = snapshot const { index, slides } = snapshot
const slideIndex = index > slides.length - 1 ? slides.length - 1 : index
commit(MutationTypes.SET_SLIDES, slides) commit(MutationTypes.SET_SLIDES, slides)
commit(MutationTypes.UPDATE_SLIDE_INDEX, index) commit(MutationTypes.UPDATE_SLIDE_INDEX, slideIndex)
commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotCursor) commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotCursor)
commit(MutationTypes.SET_ACTIVE_ELEMENT_ID_LIST, []) commit(MutationTypes.SET_ACTIVE_ELEMENT_ID_LIST, [])
}, },