This commit is contained in:
rca 2024-07-18 23:11:29 +09:00
parent d086565e62
commit deb5c17fbf

View File

@ -1,14 +1,5 @@
import { store } from 'quasar/wrappers'
import { InjectionKey } from 'vue'
import { Router } from 'vue-router'
import {
createStore,
Store as VuexStore,
useStore as vuexUseStore,
} from 'vuex'
// import example from './module-example'
// import { ExampleStateInterface } from './module-example/state';
import { createPinia } from 'pinia'
/*
* If not building with SSR mode, you can
@ -19,45 +10,11 @@ import {
* with the Store instance.
*/
export interface StateInterface {
// Define your own store structure, using submodules if needed
// example: ExampleStateInterface;
// Declared as unknown to avoid linting issue. Best to strongly type as per the line above.
example: unknown
}
export default store((/* { ssrContext } */) => {
const pinia = createPinia()
// provide typings for `this.$store`
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$store: VuexStore<StateInterface>
}
}
// You can add Pinia plugins here
// pinia.use(SomePiniaPlugin)
// provide typings for `useStore` helper
export const storeKey: InjectionKey<VuexStore<StateInterface>> = Symbol('vuex-key')
// Provide typings for `this.$router` inside Vuex stores
declare module "vuex" {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface Store<S> {
readonly $router: Router;
}
}
export default store(function (/* { ssrContext } */) {
const Store = createStore<StateInterface>({
modules: {
// example
},
// enable strict mode (adds overhead!)
// for dev mode and --debug builds only
strict: !!process.env.DEBUGGING
})
return Store;
return pinia
})
export function useStore() {
return vuexUseStore(storeKey)
}