Commit 22931897 authored by zhengke's avatar zhengke

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

parent 942f280d
...@@ -39,6 +39,7 @@ export const useSnapshotStore = defineStore('snapshot', { ...@@ -39,6 +39,7 @@ export const useSnapshotStore = defineStore('snapshot', {
const newFirstSnapshot = { const newFirstSnapshot = {
index: slidesStore.slideIndex, index: slidesStore.slideIndex,
slides: slidesStore.slides, slides: slidesStore.slides,
thumbnails: slidesStore.thumbnails
} }
await db.snapshots.add(newFirstSnapshot) await db.snapshots.add(newFirstSnapshot)
this.setSnapshotCursor(0) this.setSnapshotCursor(0)
...@@ -64,6 +65,7 @@ export const useSnapshotStore = defineStore('snapshot', { ...@@ -64,6 +65,7 @@ export const useSnapshotStore = defineStore('snapshot', {
const snapshot = { const snapshot = {
index: slidesStore.slideIndex, index: slidesStore.slideIndex,
slides: slidesStore.slides, slides: slidesStore.slides,
thumbnails: slidesStore.thumbnails
} }
await db.snapshots.add(snapshot) await db.snapshots.add(snapshot)
...@@ -98,11 +100,12 @@ export const useSnapshotStore = defineStore('snapshot', { ...@@ -98,11 +100,12 @@ export const useSnapshotStore = defineStore('snapshot', {
const snapshotCursor = this.snapshotCursor - 1 const snapshotCursor = this.snapshotCursor - 1
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray() const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
const snapshot = snapshots[snapshotCursor] const snapshot = snapshots[snapshotCursor]
const { index, slides } = snapshot const { index, slides, thumbnails } = snapshot
const slideIndex = index > slides.length - 1 ? slides.length - 1 : index const slideIndex = index > slides.length - 1 ? slides.length - 1 : index
slidesStore.setSlides(slides) slidesStore.setSlides(slides)
slidesStore.setThumbnails(thumbnails)
slidesStore.updateSlideIndex(slideIndex) slidesStore.updateSlideIndex(slideIndex)
this.setSnapshotCursor(snapshotCursor) this.setSnapshotCursor(snapshotCursor)
mainStore.setActiveElementIdList([]) mainStore.setActiveElementIdList([])
...@@ -117,12 +120,13 @@ export const useSnapshotStore = defineStore('snapshot', { ...@@ -117,12 +120,13 @@ export const useSnapshotStore = defineStore('snapshot', {
const snapshotCursor = this.snapshotCursor + 1 const snapshotCursor = this.snapshotCursor + 1
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray() const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
const snapshot = snapshots[snapshotCursor] const snapshot = snapshots[snapshotCursor]
const { index, slides } = snapshot const { index, slides, thumbnails } = snapshot
const slideIndex = index > slides.length - 1 ? slides.length - 1 : index const slideIndex = index > slides.length - 1 ? slides.length - 1 : index
slidesStore.setSlides(slides) slidesStore.setSlides(slides)
slidesStore.updateSlideIndex(slideIndex) slidesStore.updateSlideIndex(slideIndex)
slidesStore.setThumbnails(thumbnails)
this.setSnapshotCursor(snapshotCursor) this.setSnapshotCursor(snapshotCursor)
mainStore.setActiveElementIdList([]) mainStore.setActiveElementIdList([])
}, },
......
...@@ -10,7 +10,8 @@ export interface writingBoardImg { ...@@ -10,7 +10,8 @@ export interface writingBoardImg {
export interface Snapshot { export interface Snapshot {
index: number index: number
slides: Slide[] slides: Slide[],
thumbnails: string[]
} }
const databaseNamePrefix = 'PPTist' 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