mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
38 lines
728 B
TypeScript
38 lines
728 B
TypeScript
|
import { getterTree, mutationTree, actionTree } from 'typed-vuex'
|
||
|
import { Member } from '~/client/types'
|
||
|
|
||
|
export const namespaced = true
|
||
|
|
||
|
export const state = () => ({
|
||
|
id: '',
|
||
|
})
|
||
|
|
||
|
export const getters = getterTree(state, {
|
||
|
hosting: (state, getters, root) => {
|
||
|
return root.user.id === state.id
|
||
|
},
|
||
|
host: (state, getters, root) => {
|
||
|
return root.user.member[state.id] || null
|
||
|
},
|
||
|
})
|
||
|
|
||
|
export const mutations = mutationTree(state, {
|
||
|
clearHost(state) {
|
||
|
state.id = ''
|
||
|
},
|
||
|
setHost(state, host: string | Member) {
|
||
|
if (typeof host === 'string') {
|
||
|
state.id = host
|
||
|
} else {
|
||
|
state.id = host.id
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
|
||
|
export const actions = actionTree(
|
||
|
{ state, getters, mutations },
|
||
|
{
|
||
|
//
|
||
|
},
|
||
|
)
|