add files

This commit is contained in:
Jay 2018-08-17 23:59:19 +08:00
parent 218721bc15
commit b8a9e43033
3 changed files with 31 additions and 0 deletions

25
src/store/actions.js Normal file
View File

@ -0,0 +1,25 @@
import axios from 'axios'
import {apiUrl} from '@/tools'
const client = axios.create({
baseURL: apiUrl,
withCredentials: true
})
export default {
async checkSession ({commit}, cb = null) {
commit('toggleLoading', true)
let flag = false
try {
await client({
method: 'get',
url: '/api/session'
})
flag = true
} catch (err) {
flag = false
}
if (typeof cb === 'function') cb(flag)
commit('toggleLoading', false)
}
}

5
src/store/mutations.js Normal file
View File

@ -0,0 +1,5 @@
export default {
toggleLoading (state, loading = null) {
state.loading = !!loading
}
}

1
src/tools.js Normal file
View File

@ -0,0 +1 @@
export const apiUrl = 'https://bot.trj.tw'