This commit is contained in:
ろむねこ 2024-07-18 15:35:27 +09:00
parent d26592c25e
commit ac55722f22
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168

View File

@ -19,22 +19,24 @@ import {
* with the Store instance. * with the Store instance.
*/ */
export interface StateInterface { export interface AccountStateInterface {
// Define your own store structure, using submodules if needed account: {
// example: ExampleStateInterface; username: string
// Declared as unknown to avoid linting issue. Best to strongly type as per the line above. token: string
example: unknown }
isLogin: boolean
taskList: any[]
} }
// provide typings for `this.$store` // provide typings for `this.$store`
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
interface ComponentCustomProperties { interface ComponentCustomProperties {
$store: VuexStore<StateInterface> $store: VuexStore<AccountStateInterface>
} }
} }
// provide typings for `useStore` helper // provide typings for `useStore` helper
export const storeKey: InjectionKey<VuexStore<StateInterface>> = Symbol('vuex-key') export const storeKey: InjectionKey<VuexStore<AccountStateInterface>> = Symbol('vuex-key')
// Provide typings for `this.$router` inside Vuex stores // Provide typings for `this.$router` inside Vuex stores
declare module "vuex" { declare module "vuex" {
@ -44,12 +46,8 @@ declare module "vuex" {
} }
} }
export default store(function (/* { ssrContext } */) { export default store(function(/* { ssrContext } */) {
const Store = createStore<StateInterface>({ const Store = createStore<AccountStateInterface>({
modules: {
// example
},
// enable strict mode (adds overhead!) // enable strict mode (adds overhead!)
// for dev mode and --debug builds only // for dev mode and --debug builds only
strict: !!process.env.DEBUGGING strict: !!process.env.DEBUGGING