refute.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. Vue.use(Vuex);
  5. const api = {
  6. refute: `/api/article/refute`,
  7. };
  8. const state = () => ({});
  9. const mutations = {};
  10. const actions = {
  11. async query({ commit }, { skip = 0, limit, ...info } = {}) {
  12. const res = await this.$axios.$get(api.refute, { skip, limit, ...info });
  13. return res;
  14. },
  15. async create({ commit }, payload) {
  16. const res = await this.$axios.$post(`${api.refute}`, payload);
  17. return res;
  18. },
  19. async fetch({ commit, rootState }, payload) {
  20. const res = await this.$axios.$get(`${api.refute}/${payload}`, {
  21. openid: rootState.user.openid || undefined,
  22. });
  23. return res;
  24. },
  25. async update({ commit }, { id, ...info } = {}) {
  26. const res = await this.$axios.$post(`${api.refute}/update/${id}`, {
  27. ...info,
  28. });
  29. return res;
  30. },
  31. async delete({ commit }, payload) {
  32. const res = await this.$axios.$delete(`${api.refute}/${payload}`);
  33. return res;
  34. },
  35. };
  36. export default {
  37. namespaced: true,
  38. state,
  39. mutations,
  40. actions,
  41. };