import { createStore } from 'vuex' import { getUserInfo } from '@/api/user' const store = createStore({ state: { user: {}, isWorkingDay: true, requestUrl: '', fileRequestUrl: '', appCredential: '', userCredential: '' }, mutations: { setUser(state) { return new Promise((resolve, reject) => { getUserInfo().then(data => { state.user = data.user state.isWorkingDay = data.isWorkingDay resolve() }).catch(err => { reject(err) }) }) }, setRequestUrl(state, url) { state.requestUrl = url }, setFileRequestUrl(state, url) { state.fileRequestUrl = url }, setAppCredential(state, val) { state.appCredential = val }, setUserCredential(state, val) { state.userCredential = val } }, actions: { } }) export default store