refactor: move composables/stores/plugins back to project root for Nuxt auto-imports
This commit is contained in:
parent
e1daaede27
commit
bc2babbe90
5 changed files with 8 additions and 10 deletions
25
composables/useFixtureIO.ts
Normal file
25
composables/useFixtureIO.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { useCounterStore } from '~/stores/counter'
|
||||
|
||||
export type AppSnapshot = {
|
||||
counter: { count: number }
|
||||
}
|
||||
|
||||
export function useFixtureIO() {
|
||||
const exportAll = (): AppSnapshot => {
|
||||
const counter = useCounterStore()
|
||||
return {
|
||||
counter: { count: counter.count }
|
||||
}
|
||||
}
|
||||
|
||||
const importAll = (snapshot: AppSnapshot) => {
|
||||
const counter = useCounterStore()
|
||||
if (snapshot?.counter) {
|
||||
counter.$patch({ count: snapshot.counter.count ?? 0 })
|
||||
}
|
||||
}
|
||||
|
||||
return { exportAll, importAll }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue