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/settings.ts
2020-01-22 17:16:40 +00:00

31 lines
657 B
TypeScript

import { getterTree, mutationTree, actionTree } from 'typed-vuex'
import { accessor } from '~/store'
export const namespaced = true
export const state = () => ({
scroll: 10,
scroll_invert: true,
})
export const getters = getterTree(state, {})
export const mutations = mutationTree(state, {
setScroll(state, scroll: number) {
state.scroll = scroll
localStorage.setItem('scroll', `${scroll}`)
},
})
export const actions = actionTree(
{ state, getters, mutations },
{
initialise() {
const scroll = localStorage.getItem('scroll')
if (scroll) {
accessor.settings.setScroll(parseInt(scroll))
}
},
},
)