Browse Source

chore[litemall-vue]: 删除vuex支持,目前暂时使用storage

Junling Bu 6 years ago
parent
commit
f8a9e4e4c8

+ 0 - 1
litemall-vue/package.json

@@ -24,7 +24,6 @@
     "vee-validate": "^2.1.4",
     "vue": "^2.5.17",
     "js-cookie": "2.2.0",
-    "vuex": "3.0.1",
     "vue-router": "^3.0.1",
     "vuelidation": "^1.1.0"
   },

+ 0 - 2
litemall-vue/src/main.js

@@ -1,7 +1,6 @@
 import Vue from 'vue';
 import App from './App.vue';
 import router from './router';
-import store from './store'
 import 'vant/lib/icon/local.css';
 import '@/assets/scss/global.scss';
 import '@/assets/scss/iconfont/iconfont.css';
@@ -41,6 +40,5 @@ Vue.config.productionTip = false;
 
 new Vue({
   router,
-  store,
   render: h => h(App)
 }).$mount('#app');

+ 0 - 16
litemall-vue/src/store/getters.js

@@ -1,16 +0,0 @@
-const getters = {
-  sidebar: state => state.app.sidebar,
-  language: state => state.app.language,
-  size: state => state.app.size,
-  device: state => state.app.device,
-
-  token: state => state.user.token,
-  avatar: state => state.user.avatar,
-  name: state => state.user.name,
-  introduction: state => state.user.introduction,
-  status: state => state.user.status,
-  roles: state => state.user.roles,
-  perms: state => state.user.perms,
-  setting: state => state.user.setting
-}
-export default getters

+ 0 - 17
litemall-vue/src/store/index.js

@@ -1,17 +0,0 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-import app from './modules/app'
-import user from './modules/user'
-import getters from './getters'
-
-Vue.use(Vuex)
-
-const store = new Vuex.Store({
-  modules: {
-    app,
-    user
-  },
-  getters
-})
-
-export default store

+ 0 - 59
litemall-vue/src/store/modules/app.js

@@ -1,59 +0,0 @@
-import Cookies from 'js-cookie'
-
-const app = {
-  state: {
-    sidebar: {
-      opened: !+Cookies.get('sidebarStatus'),
-      withoutAnimation: false
-    },
-    device: 'desktop',
-    language: Cookies.get('language') || 'en',
-    size: Cookies.get('size') || 'medium'
-  },
-  mutations: {
-    TOGGLE_SIDEBAR: state => {
-      if (state.sidebar.opened) {
-        Cookies.set('sidebarStatus', 1)
-      } else {
-        Cookies.set('sidebarStatus', 0)
-      }
-      state.sidebar.opened = !state.sidebar.opened
-      state.sidebar.withoutAnimation = false
-    },
-    CLOSE_SIDEBAR: (state, withoutAnimation) => {
-      Cookies.set('sidebarStatus', 1)
-      state.sidebar.opened = false
-      state.sidebar.withoutAnimation = withoutAnimation
-    },
-    TOGGLE_DEVICE: (state, device) => {
-      state.device = device
-    },
-    SET_LANGUAGE: (state, language) => {
-      state.language = language
-      Cookies.set('language', language)
-    },
-    SET_SIZE: (state, size) => {
-      state.size = size
-      Cookies.set('size', size)
-    }
-  },
-  actions: {
-    toggleSideBar({ commit }) {
-      commit('TOGGLE_SIDEBAR')
-    },
-    closeSideBar({ commit }, { withoutAnimation }) {
-      commit('CLOSE_SIDEBAR', withoutAnimation)
-    },
-    toggleDevice({ commit }, device) {
-      commit('TOGGLE_DEVICE', device)
-    },
-    setLanguage({ commit }, language) {
-      commit('SET_LANGUAGE', language)
-    },
-    setSize({ commit }, size) {
-      commit('SET_SIZE', size)
-    }
-  }
-}
-
-export default app

+ 0 - 103
litemall-vue/src/store/modules/user.js

@@ -1,103 +0,0 @@
-import { authLoginByAccount, authLogout, authInfo } from '@/api/api'
-import { getToken, setToken, removeToken } from '@/utils/auth'
-
-const user = {
-  state: {
-    user: '',
-    status: '',
-    code: '',
-    token: getToken(),
-    name: '',
-    avatar: '',
-    introduction: '',
-    roles: [],
-    perms: [],
-    setting: {
-      articlePlatform: []
-    }
-  },
-
-  mutations: {
-    SET_CODE: (state, code) => {
-      state.code = code
-    },
-    SET_TOKEN: (state, token) => {
-      state.token = token
-    },
-    SET_INTRODUCTION: (state, introduction) => {
-      state.introduction = introduction
-    },
-    SET_SETTING: (state, setting) => {
-      state.setting = setting
-    },
-    SET_STATUS: (state, status) => {
-      state.status = status
-    },
-    SET_NAME: (state, name) => {
-      state.name = name
-    },
-    SET_AVATAR: (state, avatar) => {
-      state.avatar = avatar
-    },
-    SET_ROLES: (state, roles) => {
-      state.roles = roles
-    },
-    SET_PERMS: (state, perms) => {
-      state.perms = perms
-    }
-  },
-
-  actions: {
-    // 用户名登录
-    LoginByUsername({ commit }, userInfo) {
-      const username = userInfo.username.trim()
-      return new Promise((resolve, reject) => {
-        authLoginByAccount(username, userInfo.password).then(response => {
-          const token = response.data.data
-          commit('SET_TOKEN', token)
-          setToken(token)
-          resolve()
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-
-    // 获取用户信息
-    GetUserInfo({ commit, state }) {
-      return new Promise((resolve, reject) => {
-        getUserInfo(state.token).then(response => {
-          const data = response.data.data
-
-          commit('SET_ROLES', data.roles)
-          commit('SET_NAME', data.name)
-          commit('SET_AVATAR', data.avatar)
-          commit('SET_INTRODUCTION', data.introduction)
-          resolve(response)
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-
-   
-    // 登出
-    LogOut({ commit, state }) {
-      return new Promise((resolve, reject) => {
-        authLogout(state.token).then(() => {
-          commit('Authorization', '')
-          commit('avatar', '')
-          commit('background_image', [])
-          commit('nickName', [])
-
-          removeToken()
-          resolve()
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    }
-  }
-}
-
-export default user