From 6739767f58490d92544aa8a99105f64adf534e74 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sun, 11 Sep 2022 10:53:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20indexeddb=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 4 +++- src/store/snapshot.ts | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index 905e23dd..f6f121cd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,6 +9,7 @@ import { onMounted } from 'vue' import { storeToRefs } from 'pinia' import { useScreenStore, useMainStore, useSnapshotStore } from '@/store' import { LOCALSTORAGE_KEY_DISCARDED_DB } from '@/configs/storage' +import { deleteDiscardedDB } from '@/utils/database' import { isPC } from './utils/common' import Editor from './views/Editor/index.vue' @@ -26,7 +27,8 @@ if (process.env.NODE_ENV === 'production') { window.onbeforeunload = () => false } -onMounted(() => { +onMounted(async () => { + await deleteDiscardedDB() snapshotStore.initSnapshotDatabase() mainStore.setAvailableFonts() }) diff --git a/src/store/snapshot.ts b/src/store/snapshot.ts index b85faa0b..4b991295 100644 --- a/src/store/snapshot.ts +++ b/src/store/snapshot.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia' import { IndexableTypeArray } from 'dexie' -import { db, deleteDiscardedDB, Snapshot } from '@/utils/database' +import { db, Snapshot } from '@/utils/database' import { useSlidesStore } from './slides' import { useMainStore } from './main' @@ -35,8 +35,6 @@ export const useSnapshotStore = defineStore('snapshot', { async initSnapshotDatabase() { const slidesStore = useSlidesStore() - - await deleteDiscardedDB() const newFirstSnapshot = { index: slidesStore.slideIndex,