index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import Vue from "vue";
  2. import Vuex from "vuex";
  3. Vue.use(Vuex);
  4. // 定义是否菜单可取消选中(true:可取消选中,false:不可取消选中)【取消选中:当菜单已经为选中状态,再次点击会取消选中状态】
  5. const menus = true;
  6. export default new Vuex.Store({
  7. state: {
  8. baseMapType:1, //当前的底图类型 0 - 影像图; 1 - 蓝黑图, 2-街道图
  9. // 头部菜单选中菜单对象(主要用于元素判断是否显示)
  10. navSelect: window.localStorage.getItem("navSelect")
  11. ? JSON.parse(window.localStorage.getItem("navSelect"))
  12. : { index: "1", name: "首页", subIndex: "" },
  13. // 左侧菜单选中菜单index(主要用于元素判断是否显示)
  14. leftMenuTitle: "",
  15. // 底部菜单选中菜单index,subIndex(主要用于元素判断是否高亮)
  16. bottomMenuIndexs: { index: -1, subIndex: -1 },
  17. // 当前浏览器窗口的宽高(优化自适应布局)
  18. windowsSize: {
  19. width: document.body.clientWidth,
  20. height: document.body.clientHeight,
  21. },
  22. // 地图常用方法集合
  23. mapMethodsCollection: new Map(),
  24. // 自定义模型数组
  25. customModelsArr: [],
  26. // 自定义模型状态改变 -- 修改或创建
  27. modelStatus: "create",
  28. // 法律法规弹窗
  29. lawPopupShow:false
  30. },
  31. getters: {
  32. customModelsArr: (state) => state.customModelsArr,
  33. },
  34. mutations: {
  35. // 用户点击头部菜单,更新暂存对象
  36. changeNavSelect(state, navSelect) {
  37. state.navSelect = navSelect;
  38. window.localStorage.setItem("navSelect", JSON.stringify(state.navSelect));
  39. },
  40. // 用户点击左侧菜单,更新暂存对象(当menus为true时,点击相同的菜单会取消选中)
  41. changeLeftMenuTitle(state, leftMenuTitle) {
  42. state.leftMenuTitle = leftMenuTitle;
  43. },
  44. // 用户点击底部菜单,更新暂存对象(当menus为true时,点击相同的菜单会取消选中)
  45. changeBottomMenu(state, bottomMenuIndex) {
  46. if (
  47. bottomMenuIndex.index == state.bottomMenuIndexs.index &&
  48. bottomMenuIndex.subIndex == state.bottomMenuIndexs.subIndex &&
  49. menus
  50. ) {
  51. state.bottomMenuIndexs = { index: -1, subIndex: -1 };
  52. } else {
  53. state.bottomMenuIndexs = bottomMenuIndex;
  54. }
  55. },
  56. changeWindowsSize(state, windowWidth, windowHeight) {
  57. state.windowsSize = { width: windowWidth, height: windowHeight };
  58. },
  59. mapMethods: (state, options) => {
  60. state.mapMethodsCollection.set(options.name, options.value);
  61. },
  62. changeCustomModelsArr: (state, data) => {
  63. state.customModelsArr = data;
  64. },
  65. changeModelStatus: (state, data) => {
  66. state.modelStatus = data;
  67. },
  68. },
  69. actions: {},
  70. modules: {},
  71. });