error.js 747 B

123456789101112131415161718192021222324252627282930313233
  1. export default {
  2. namespaced: true,
  3. state: {
  4. logs: []
  5. },
  6. mutations: {
  7. ADD_ERROR_LOG: (state, log) => {
  8. state.logs.unshift(log)
  9. },
  10. CLEAR_ERROR_LOG: (state) => {
  11. state.logs.splice(0)
  12. }
  13. },
  14. actions: {
  15. add({
  16. commit
  17. }, log) {
  18. if (!log.route) {
  19. const pages = getCurrentPages()
  20. if (pages.length) {
  21. log.route = pages[pages.length - 1].route
  22. }
  23. }
  24. log.route = '/' + (log.route || '')
  25. commit('ADD_ERROR_LOG', log)
  26. },
  27. clear({
  28. commit
  29. }) {
  30. commit('CLEAR_ERROR_LOG')
  31. }
  32. }
  33. }