frp/web/frps/src/store/modules/server.js

30 lines
470 B
JavaScript
Raw Normal View History

2020-12-04 01:08:40 +08:00
import Vue from 'vue'
import Vuex from 'vuex'
import fetch from '@/utils/fetch'
Vue.use(Vuex)
const state = {
serverInfo: null
}
const mutations = {
SET_SERVER_INFO(state, serverInfo) {
state.serverInfo = serverInfo
}
}
const actions = {
async fetchServerInfo({ commit }) {
const json = await fetch('serverinfo')
commit('SET_SERVER_INFO', json || null)
return json
}
}
export default {
namespaced: true,
state,
mutations,
actions
}