12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { VerifyLogin } from '@/api/api'
- import Cookies from 'js-cookie'
- const getDefaultState = () => {
- return {
- JSESSSIONID: Cookies.get('JSESSIONID') || '',
- }
- }
- const state = getDefaultState()
- const mutations = {
- RESET_JSESSIONID: (state, JSESSSIONID) => {
- Cookies.set('JSESSIONID', JSESSSIONID);
- state.JSESSSIONID = JSESSSIONID
- }
- }
- const actions = {
- // user login
- setJsessionId({ commit }) {
- return new Promise((resolve, reject) => {
- VerifyLogin().then(response => {
- const { data } = response
- commit('RESET_JSESSIONID', data.JSESSSIONID)
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- },
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|