{"remainingRequest":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/components/TopNav/index.vue?vue&type=script&lang=js","dependencies":[{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/components/TopNav/index.vue","mtime":1701742078545},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\n// +----------------------------------------------------------------------\n// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]\n// +----------------------------------------------------------------------\n// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.\n// +----------------------------------------------------------------------\n// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权\n// +----------------------------------------------------------------------\n// | Author: CRMEB Team <admin@crmeb.com>\n// +----------------------------------------------------------------------\n\nexport default {\n  data() {\n    return {\n      // 顶部栏初始数\n      visibleNumber: 9,\n      // 当前激活菜单的 index\n      currentIndex: undefined,\n    };\n  },\n  computed: {\n    theme() {\n      return this.$store.state.settings.theme;\n    },\n    navIcon() {\n      return this.$store.state.settings.navIcon;\n    },\n    // 所有的路由信息\n    routers() {\n      let routers = this.$store.state.permission.topbarRouters;\n      let arr = [],\n        obj = {};\n      routers.forEach((item) => {\n        obj = item;\n        obj.path = item.url;\n        arr.push(obj);\n      });\n      return arr;\n    },\n    // 顶部显示菜单\n    topMenus() {\n      let topMenus = [];\n      this.routers.map((menu) => {\n        if (menu.hidden !== true) {\n          // 兼容顶部栏一级菜单内部跳转\n          if (menu.path === '/') {\n            topMenus.push(menu.child[0]);\n          } else {\n            topMenus.push(menu);\n          }\n        }\n      });\n      return topMenus;\n    },\n    // 默认激活的菜单\n    activeMenu() {\n      //简单粗暴的办法，获取当前路由截取一级路由赋值给默认选中菜单\n      let key = this.$route.path.split('/')[1];\n      key = '/' + key;\n      return key;\n    },\n  },\n  beforeMount() {\n    window.addEventListener('resize', this.setVisibleNumber);\n  },\n  beforeDestroy() {\n    window.removeEventListener('resize', this.setVisibleNumber);\n  },\n  mounted() {\n    this.setVisibleNumber();\n  },\n  methods: {\n    // 根据宽度计算设置显示栏数\n    setVisibleNumber() {\n      const width = document.body.getBoundingClientRect().width / 1.8;\n      this.visibleNumber = parseInt(width / 85);\n    },\n    // 菜单选择事件\n    handleSelect(key, keyPath) {\n      this.currentIndex = key;\n      if (this.ishttp(key)) {\n        // http(s):// 路径新窗口打开\n        window.open(key, '_blank');\n      } else if (key.indexOf('/redirect') !== -1) {\n        // /redirect 路径内部打开\n        this.$router.push({ path: key.replace('/redirect', '') });\n      } else {\n        // 显示左侧联动菜单\n        this.activeRoutes(key);\n      }\n    },\n    // 当前激活的路由\n    activeRoutes(key) {\n      var routes = [];\n      this.routers.map((item) => {\n        if (key == item.url && item.child) {\n          //如果选中导航的key值与遍历项的url匹配并且有子级，那么就将该项的子级数组放在routes中\n          routes = item.child;\n        } else if (key == item.url && !item.child) {\n          //只满足选中导航的key值与遍历项的url匹配但是没有子级的情况下，就把这一项赋值给vuex中\n          //这一项其实针对控制台，控制台没有子级\n          this.$store.commit('permission/SET_SIDEBAR_ROUTERS', [item]);\n        }\n      });\n      if (routes.length > 0) {\n        //routes数组有长度就将它放在vuex中，左侧导航就能读取到，展示的也是选中项的子级\n        this.$store.commit('permission/SET_SIDEBAR_ROUTERS', routes);\n      }\n      return routes;\n    },\n    ishttp(url) {\n      return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1;\n    },\n  },\n};\n",null]}