add files
This commit is contained in:
parent
218721bc15
commit
b8a9e43033
25
src/store/actions.js
Normal file
25
src/store/actions.js
Normal 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
5
src/store/mutations.js
Normal file
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
toggleLoading (state, loading = null) {
|
||||
state.loading = !!loading
|
||||
}
|
||||
}
|
1
src/tools.js
Normal file
1
src/tools.js
Normal file
@ -0,0 +1 @@
|
||||
export const apiUrl = 'https://bot.trj.tw'
|
Loading…
Reference in New Issue
Block a user