Skip to content

Commit

Permalink
更新首页刷新页面indexedDB未删除bug
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Aug 22, 2024
1 parent bf24fde commit 10c9f12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 0 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,11 @@
</template>

<script lang="ts" setup>
import { onMounted, computed } from 'vue'
import { deleteDiscardedDB } from '@/utils/database'
import { useMainStore, useSnapshotStore } from '@/store'
import { storeToRefs } from 'pinia'
import { LocalStorageDiscardedKey } from '@/configs/canvas'
import useI18n from '@/hooks/useI18n'

const { messages }= useI18n()
const locale = computed(() => messages.value)

const snapshotStore = useSnapshotStore()
const mainStore = useMainStore()

onMounted(async () => {
await deleteDiscardedDB()
await snapshotStore.initSnapshotDatabase()
// mainStore.getFonts()
})

// 在主入口监听PWA注册事件
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
Expand Down
14 changes: 12 additions & 2 deletions src/views/Editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@
import Computer from '@/views/Editor/computer.vue'
import Mobile from '@/views/Editor/mobile.vue'
import useI18n from '@/hooks/useI18n'
import { useMainStore } from '@/store'
import { useMainStore, useSnapshotStore } from '@/store'
import { storeToRefs } from 'pinia'
import { isMobile } from '@/utils/common'
import { LocalStorageDiscardedKey } from '@/configs/canvas'
const { databaseId } = storeToRefs(useMainStore())
import { deleteDiscardedDB } from '@/utils/database'
const { messages }= useI18n()
const { databaseId } = storeToRefs(useMainStore())
const locale = computed(() => messages.value)
if (import.meta.env.MODE === 'production') {
window.onbeforeunload = () => false
}
const snapshotStore = useSnapshotStore()
// const mainStore = useMainStore()
onMounted(async () => {
await deleteDiscardedDB()
await snapshotStore.initSnapshotDatabase()
// mainStore.getFonts()
})
// 应用注销时向 localStorage 中记录下本次 indexedDB 的数据库ID,用于之后清除数据库
window.addEventListener('unload', () => {
const discardedDB = localStorage.getItem(LocalStorageDiscardedKey)
Expand Down

0 comments on commit 10c9f12

Please sign in to comment.