feat: use indexDB instead of array filter

This commit is contained in:
YunYouJun
2023-07-30 18:25:54 +08:00
parent 70787d3a80
commit c2b1ffdd9e
16 changed files with 181 additions and 88 deletions

18
composables/db.ts Normal file
View File

@@ -0,0 +1,18 @@
import { useStorage } from '@vueuse/core'
import { lastDbUpdated, namespace } from '~/constants'
export function useIndexedDB() {
const dbUpdated = useStorage(`${namespace}:lastDbUpdated`, lastDbUpdated)
return {
// db,
// initDb,
init: async () => {
const count = await db.recipes.count()
if (!count || dbUpdated.value !== lastDbUpdated) {
dbUpdated.value = lastDbUpdated
initDb()
}
},
}
}