Archived
2
0
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
neko-custom/client/src/store/client.ts

47 lines
937 B
TypeScript
Raw Normal View History

2020-01-23 06:16:40 +13:00
import { getterTree, mutationTree, actionTree } from 'typed-vuex'
import { accessor } from '~/store'
export const namespaced = true
export const state = () => {
let side = false
let _side = localStorage.getItem('side')
if (_side) {
side = _side === '1'
}
let tab = 'chat'
let _tab = localStorage.getItem('tab')
if (_tab) {
tab = _tab
}
return {
side,
about: false,
about_page: '',
tab,
}
}
export const getters = getterTree(state, {})
export const mutations = mutationTree(state, {
setTab(state, tab: string) {
state.tab = tab
localStorage.setItem('tab', tab)
},
setAbout(state, page: string) {
state.about_page = page
},
toggleAbout(state) {
state.about = !state.about
},
toggleSide(state) {
state.side = !state.side
localStorage.setItem('side', state.side ? '1' : '0')
},
})
export const actions = actionTree({ state, getters, mutations }, {})