Add store
This commit is contained in:
15
src/store/albums/actions.ts
Normal file
15
src/store/albums/actions.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Actions } from 'vuex-smart-module';
|
||||
import Vue from 'vue';
|
||||
import { AxiosResponse, AxiosError } from 'axios';
|
||||
import AlbumsState from './state';
|
||||
import AlbumsGetters from './getters';
|
||||
import AlbumsMutations from './muttations';
|
||||
|
||||
export default class AlbumsActions extends Actions<
|
||||
AlbumsState,
|
||||
AlbumsGetters,
|
||||
AlbumsMutations,
|
||||
AlbumsActions
|
||||
> {
|
||||
|
||||
}
|
||||
6
src/store/albums/getters.ts
Normal file
6
src/store/albums/getters.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Getters } from 'vuex-smart-module';
|
||||
import AlbumsState from './state';
|
||||
|
||||
export default class AlbumsGetters extends Getters<AlbumsState> {
|
||||
|
||||
}
|
||||
15
src/store/albums/index.ts
Normal file
15
src/store/albums/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Module } from 'vuex-smart-module';
|
||||
import AlbumsState from './state';
|
||||
import AlbumsGetters from './getters';
|
||||
import AlbumsMutations from './muttations';
|
||||
import AlbumsActions from './actions';
|
||||
|
||||
|
||||
const authModule = new Module({
|
||||
state: AlbumsState,
|
||||
getters: AlbumsGetters,
|
||||
mutations: AlbumsMutations,
|
||||
actions: AlbumsActions,
|
||||
});
|
||||
|
||||
export default authModule;
|
||||
8
src/store/albums/muttations.ts
Normal file
8
src/store/albums/muttations.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Mutations } from 'vuex-smart-module';
|
||||
import AlbumsState, { IAlbum } from './state';
|
||||
|
||||
export default class AlbumsMutations extends Mutations<AlbumsState> {
|
||||
updateAlbums(albumsData: IAlbum[]) {
|
||||
this.state.albums = albumsData;
|
||||
}
|
||||
}
|
||||
12
src/store/albums/state.ts
Normal file
12
src/store/albums/state.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export interface IAlbum {
|
||||
name: string;
|
||||
description: string;
|
||||
protected: boolean;
|
||||
|
||||
folderName: string;
|
||||
files: string[];
|
||||
}
|
||||
|
||||
export default class AlbumsState {
|
||||
albums: IAlbum[] | null = null;
|
||||
}
|
||||
30
src/store/index.ts
Normal file
30
src/store/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import Vue from 'vue';
|
||||
import * as Vuex from 'vuex';
|
||||
import { createStore, Module } from 'vuex-smart-module';
|
||||
|
||||
import { Store } from 'vuex';
|
||||
|
||||
import albums from './albums';
|
||||
import albumsState from './albums/state';
|
||||
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
interface IStore {
|
||||
albums: albumsState
|
||||
}
|
||||
|
||||
export type StoreType = Store<IStore>;
|
||||
|
||||
const store: StoreType = createStore(
|
||||
new Module({
|
||||
modules: {
|
||||
albums,
|
||||
}
|
||||
}),
|
||||
{
|
||||
strict: process.env.NODE_ENV !== 'production',
|
||||
}
|
||||
)
|
||||
|
||||
export default store;
|
||||
Reference in New Issue
Block a user