auth-user.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. //用户的菜单选项增删改查
  5. Vue.use(Vuex);
  6. const api = {
  7. interface: `/api/auth/user`,
  8. getMenu: `/api/auth/user/menus`,
  9. };
  10. const state = () => ({});
  11. const mutations = {};
  12. const actions = {
  13. async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
  14. const res = await this.$axios.$get(api.interface, { skip, limit, ...info });
  15. return res;
  16. },
  17. async create({ commit }, payload) {
  18. const res = await this.$axios.$post(`${api.interface}`, payload);
  19. return res;
  20. },
  21. async fetch({ commit }, payload) {
  22. //特殊变化,查用户菜单
  23. const res = await this.$axios.$get(`${api.getMenu}`, payload);
  24. return res;
  25. },
  26. async update({ commit }, { id, ...info } = {}) {
  27. const res = await this.$axios.$post(`${api.interface}/update/${id}`, {
  28. ...info,
  29. });
  30. return res;
  31. },
  32. async delete({ commit }, payload) {
  33. const res = await this.$axios.$delete(`${api.interface}/${payload}`);
  34. return res;
  35. },
  36. };
  37. export default {
  38. namespaced: true,
  39. state,
  40. mutations,
  41. actions,
  42. };