refactor: indexeddb初始化调整

This commit is contained in:
pipipi-pikachu 2022-09-11 10:53:35 +08:00
parent 5b88d360e2
commit 6739767f58
2 changed files with 4 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import { onMounted } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useScreenStore, useMainStore, useSnapshotStore } from '@/store' import { useScreenStore, useMainStore, useSnapshotStore } from '@/store'
import { LOCALSTORAGE_KEY_DISCARDED_DB } from '@/configs/storage' import { LOCALSTORAGE_KEY_DISCARDED_DB } from '@/configs/storage'
import { deleteDiscardedDB } from '@/utils/database'
import { isPC } from './utils/common' import { isPC } from './utils/common'
import Editor from './views/Editor/index.vue' import Editor from './views/Editor/index.vue'
@ -26,7 +27,8 @@ if (process.env.NODE_ENV === 'production') {
window.onbeforeunload = () => false window.onbeforeunload = () => false
} }
onMounted(() => { onMounted(async () => {
await deleteDiscardedDB()
snapshotStore.initSnapshotDatabase() snapshotStore.initSnapshotDatabase()
mainStore.setAvailableFonts() mainStore.setAvailableFonts()
}) })

View File

@ -1,6 +1,6 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { IndexableTypeArray } from 'dexie' import { IndexableTypeArray } from 'dexie'
import { db, deleteDiscardedDB, Snapshot } from '@/utils/database' import { db, Snapshot } from '@/utils/database'
import { useSlidesStore } from './slides' import { useSlidesStore } from './slides'
import { useMainStore } from './main' import { useMainStore } from './main'
@ -35,8 +35,6 @@ export const useSnapshotStore = defineStore('snapshot', {
async initSnapshotDatabase() { async initSnapshotDatabase() {
const slidesStore = useSlidesStore() const slidesStore = useSlidesStore()
await deleteDiscardedDB()
const newFirstSnapshot = { const newFirstSnapshot = {
index: slidesStore.slideIndex, index: slidesStore.slideIndex,