Add app store
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { Actions } from 'vuex-smart-module';
|
||||
import Vue from 'vue';
|
||||
import { AxiosResponse, AxiosError } from 'axios';
|
||||
import AlbumsState from './state';
|
||||
import AlbumsState, { IAlbum } from './state';
|
||||
import AlbumsGetters from './getters';
|
||||
import AlbumsMutations from './muttations';
|
||||
import AlbumsMutations from './mutations';
|
||||
|
||||
export default class AlbumsActions extends Actions<
|
||||
AlbumsState,
|
||||
@@ -11,5 +9,53 @@ export default class AlbumsActions extends Actions<
|
||||
AlbumsMutations,
|
||||
AlbumsActions
|
||||
> {
|
||||
|
||||
$init() {
|
||||
const albums: IAlbum[] = [
|
||||
{
|
||||
name: 'Test',
|
||||
description: 'Test description',
|
||||
protected: false,
|
||||
|
||||
folderName: 'test',
|
||||
files: [
|
||||
'p (1).jpg',
|
||||
'p (2).jpg',
|
||||
'p (3).jpg',
|
||||
'p (4).jpg',
|
||||
'p (5).jpg',
|
||||
'p (6).jpg',
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Test 2',
|
||||
description: 'Test 2 description',
|
||||
protected: false,
|
||||
|
||||
folderName: 'test2',
|
||||
files: [
|
||||
'p (1).jpg',
|
||||
'p (2).jpg',
|
||||
'p (3).jpg',
|
||||
'p (4).jpg',
|
||||
'p (5).jpg',
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Test 3',
|
||||
description: 'Test 3 description',
|
||||
protected: false,
|
||||
|
||||
folderName: 'test3',
|
||||
files: [
|
||||
'p (1).jpg',
|
||||
'p (2).jpg',
|
||||
'p (3).jpg',
|
||||
'p (4).jpg',
|
||||
'p (5).jpg',
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
setTimeout(() => this.commit('updateAlbums', albums), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from 'vuex-smart-module';
|
||||
import AlbumsState from './state';
|
||||
import AlbumsGetters from './getters';
|
||||
import AlbumsMutations from './muttations';
|
||||
import AlbumsMutations from './mutations';
|
||||
import AlbumsActions from './actions';
|
||||
|
||||
|
||||
|
||||
15
src/store/app/actions.ts
Normal file
15
src/store/app/actions.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Actions } from 'vuex-smart-module';
|
||||
import AppState from './state';
|
||||
import AppGetters from './getters';
|
||||
import AppMutations from './mutations';
|
||||
|
||||
export default class AppActions extends Actions<
|
||||
AppState,
|
||||
AppGetters,
|
||||
AppMutations,
|
||||
AppActions
|
||||
> {
|
||||
setLeftPanelCloseStatus(value: boolean) {
|
||||
this.commit("setLeftPanelCloseStatus", value);
|
||||
}
|
||||
}
|
||||
6
src/store/app/getters.ts
Normal file
6
src/store/app/getters.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Getters } from 'vuex-smart-module';
|
||||
import AppState from './state';
|
||||
|
||||
export default class AppGetters extends Getters<AppState> {
|
||||
|
||||
}
|
||||
16
src/store/app/index.ts
Normal file
16
src/store/app/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Module } from 'vuex-smart-module';
|
||||
import AppState from './state';
|
||||
import AppGetters from './getters';
|
||||
import AppMutations from './mutations';
|
||||
import AppActions from './actions';
|
||||
import AlbumsMutations from '../albums/mutations';
|
||||
|
||||
|
||||
const appModule = new Module({
|
||||
state: AppState,
|
||||
getters: AppGetters,
|
||||
mutations: AppMutations,
|
||||
actions: AppActions,
|
||||
});
|
||||
|
||||
export default appModule;
|
||||
8
src/store/app/mutations.ts
Normal file
8
src/store/app/mutations.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Mutations } from 'vuex-smart-module';
|
||||
import AppState from './state';
|
||||
|
||||
export default class AppMutations extends Mutations<AppState> {
|
||||
setLeftPanelCloseStatus(value: boolean) {
|
||||
this.state.leftPanelClosed = value;
|
||||
}
|
||||
}
|
||||
3
src/store/app/state.ts
Normal file
3
src/store/app/state.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default class AppState {
|
||||
leftPanelClosed: boolean = true;
|
||||
}
|
||||
@@ -7,11 +7,15 @@ import { Store } from 'vuex';
|
||||
import albums from './albums';
|
||||
import albumsState from './albums/state';
|
||||
|
||||
import app from './app';
|
||||
import appState from './app/state';
|
||||
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
interface IStore {
|
||||
albums: albumsState
|
||||
albums: albumsState,
|
||||
app: appState
|
||||
}
|
||||
|
||||
export type StoreType = Store<IStore>;
|
||||
@@ -20,6 +24,7 @@ const store: StoreType = createStore(
|
||||
new Module({
|
||||
modules: {
|
||||
albums,
|
||||
app
|
||||
}
|
||||
}),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user