process.js 747 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. export default {
  2. state: {
  3. list: [
  4. {
  5. label: '首页',
  6. value: '/',
  7. active: true
  8. }
  9. ]
  10. },
  11. actions: {},
  12. mutations: {
  13. ADD_PROCESS(state, item) {
  14. const index = state.list.findIndex(e => e.value == item.value);
  15. state.list.map(e => {
  16. e.active = e.value == item.value;
  17. });
  18. if (index < 0) {
  19. if (item.value == '/') {
  20. item.label = '首页';
  21. }
  22. if (item.label) {
  23. state.list.push({
  24. ...item,
  25. active: true
  26. });
  27. }
  28. }
  29. },
  30. DEL_PROCESS(state, index) {
  31. state.list.splice(index, 1);
  32. },
  33. SET_PROCESS(state, list) {
  34. state.list = list;
  35. },
  36. RESET_PROCESS(state) {
  37. state.list = [
  38. {
  39. label: '首页',
  40. value: '/',
  41. active: true
  42. }
  43. ];
  44. }
  45. }
  46. };