process.js 944 B

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