store作成

This commit is contained in:
rca 2024-07-21 22:30:21 +09:00
parent c13484d9a7
commit 121046c0c0
5 changed files with 59 additions and 0 deletions

11
src/store/cache/actions.ts vendored Normal file
View File

@ -0,0 +1,11 @@
import { ActionTree } from 'vuex';
import { StateInterface } from '../index';
import { ExampleStateInterface } from './state';
const actions: ActionTree<ExampleStateInterface, StateInterface> = {
someAction (/* context */) {
// your code
}
};
export default actions;

11
src/store/cache/getters.ts vendored Normal file
View File

@ -0,0 +1,11 @@
import { GetterTree } from 'vuex';
import { StateInterface } from '../index';
import { ExampleStateInterface } from './state';
const getters: GetterTree<ExampleStateInterface, StateInterface> = {
someGetter (/* context */) {
// your code
}
};
export default getters;

16
src/store/cache/index.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import { Module } from 'vuex';
import { StateInterface } from '../index';
import state, { ExampleStateInterface } from './state';
import actions from './actions';
import getters from './getters';
import mutations from './mutations';
const exampleModule: Module<ExampleStateInterface, StateInterface> = {
namespaced: true,
actions,
getters,
mutations,
state
};
export default exampleModule;

10
src/store/cache/mutations.ts vendored Normal file
View File

@ -0,0 +1,10 @@
import { MutationTree } from 'vuex';
import { ExampleStateInterface } from './state';
const mutation: MutationTree<ExampleStateInterface> = {
someMutation (/* state: ExampleStateInterface */) {
// your code
}
};
export default mutation;

11
src/store/cache/state.ts vendored Normal file
View File

@ -0,0 +1,11 @@
export interface ExampleStateInterface {
prop: boolean;
}
function state(): ExampleStateInterface {
return {
prop: false,
};
}
export default state;