12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import * as api from '@/api/index'
- import {ElMessageBox} from "element-plus";
- const state = {
- apiProxy: {
- EzServer6Api: 'EzServer6-api', // 地图底图代理
- },
- userInfo: null
- }
- const getters = {
- isLogin(state) {
- return localStorage.getItem('sc_token')
- }
- }
- const mutations = {
- SET_USER_INFO(state, data) {
- state.userInfo = data
- }
- }
- const actions = {
- LOAD_USER_INFO({ commit }, refresh = false) {
- return new Promise((resolve, reject) => {
- if (refresh || !state.userInfo) {
- api.default.getUserInfo().then(res => {
- commit('SET_USER_INFO', res.userInfo)
- resolve(res.userInfo)
- }).catch(() => {
- })
- } else {
- resolve()
- }
- })
- },
- EXIT_LOGIN({ commit }) {
- ElMessageBox.confirm('确定进行[退出]操作?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- api.default.logout()
- localStorage.removeItem('sc_token')
- location.reload()
- }).catch(() => {
- })
- },
- }
- export default {
- namespaced: true,
- state,
- getters,
- mutations,
- actions
- }
|