Commit 22931897 authored by zhengke's avatar zhengke

修复 编辑撤回 数据清除问题

parent 942f280d
......@@ -39,6 +39,7 @@ export const useSnapshotStore = defineStore('snapshot', {
const newFirstSnapshot = {
index: slidesStore.slideIndex,
slides: slidesStore.slides,
thumbnails: slidesStore.thumbnails
}
await db.snapshots.add(newFirstSnapshot)
this.setSnapshotCursor(0)
......@@ -64,6 +65,7 @@ export const useSnapshotStore = defineStore('snapshot', {
const snapshot = {
index: slidesStore.slideIndex,
slides: slidesStore.slides,
thumbnails: slidesStore.thumbnails
}
await db.snapshots.add(snapshot)
......@@ -98,11 +100,12 @@ export const useSnapshotStore = defineStore('snapshot', {
const snapshotCursor = this.snapshotCursor - 1
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
const snapshot = snapshots[snapshotCursor]
const { index, slides } = snapshot
const { index, slides, thumbnails } = snapshot
const slideIndex = index > slides.length - 1 ? slides.length - 1 : index
slidesStore.setSlides(slides)
slidesStore.setThumbnails(thumbnails)
slidesStore.updateSlideIndex(slideIndex)
this.setSnapshotCursor(snapshotCursor)
mainStore.setActiveElementIdList([])
......@@ -117,12 +120,13 @@ export const useSnapshotStore = defineStore('snapshot', {
const snapshotCursor = this.snapshotCursor + 1
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
const snapshot = snapshots[snapshotCursor]
const { index, slides } = snapshot
const { index, slides, thumbnails } = snapshot
const slideIndex = index > slides.length - 1 ? slides.length - 1 : index
slidesStore.setSlides(slides)
slidesStore.updateSlideIndex(slideIndex)
slidesStore.setThumbnails(thumbnails)
this.setSnapshotCursor(snapshotCursor)
mainStore.setActiveElementIdList([])
},
......
......@@ -10,7 +10,8 @@ export interface writingBoardImg {
export interface Snapshot {
index: number
slides: Slide[]
slides: Slide[],
thumbnails: string[]
}
const databaseNamePrefix = 'PPTist'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment