personalchat.js 1.1 KB

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