1 line
5.3 KiB
JSON
1 line
5.3 KiB
JSON
{"remainingRequest":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\src\\components\\TopNav\\index.vue?vue&type=script&lang=js","dependencies":[{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\src\\components\\TopNav\\index.vue","mtime":1732871026484},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\cache-loader\\dist\\cjs.js","mtime":1732872824662},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\babel-loader\\lib\\index.js","mtime":1732872825017},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\cache-loader\\dist\\cjs.js","mtime":1732872824662},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\vue-loader\\lib\\index.js","mtime":1732872825835}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\r\nimport { constantRouterMap } from '@/router/routers'\r\n\r\nexport default {\r\n data() {\r\n return {\r\n // 顶部栏初始数\r\n visibleNumber: 5,\r\n // 是否为首次加载\r\n isFrist: false,\r\n // 当前激活菜单的 index\r\n currentIndex: undefined\r\n }\r\n },\r\n computed: {\r\n theme() {\r\n return this.$store.state.settings.theme\r\n },\r\n // 顶部显示菜单\r\n topMenus() {\r\n const topMenus = []\r\n this.routers.map((menu) => {\r\n if (menu.hidden !== true) {\r\n // 兼容顶部栏一级菜单内部跳转\r\n if (menu.path === '/') {\r\n topMenus.push(menu.children[0])\r\n } else {\r\n topMenus.push(menu)\r\n }\r\n }\r\n })\r\n return topMenus\r\n },\r\n // 所有的路由信息\r\n routers() {\r\n return this.$store.state.permission.topbarRouters\r\n },\r\n // 设置子路由\r\n childrenMenus() {\r\n var childrenMenus = []\r\n this.routers.map((router) => {\r\n for (var item in router.children) {\r\n if (router.children[item].parentPath === undefined) {\r\n if (router.path === '/') {\r\n router.children[item].path = '/redirect/' + router.children[item].path\r\n } else {\r\n if (!this.ishttp(router.children[item].path)) {\r\n router.children[item].path = router.path + '/' + router.children[item].path\r\n }\r\n }\r\n router.children[item].parentPath = router.path\r\n }\r\n childrenMenus.push(router.children[item])\r\n }\r\n })\r\n return constantRouterMap.concat(childrenMenus)\r\n },\r\n // 默认激活的菜单\r\n activeMenu() {\r\n const path = this.$route.path\r\n let activePath = this.defaultRouter()\r\n if (path.lastIndexOf('/') > 0) {\r\n const tmpPath = path.substring(1, path.length)\r\n activePath = '/' + tmpPath.substring(0, tmpPath.indexOf('/'))\r\n } else if (path === '/index' || path === '') {\r\n if (!this.isFrist) {\r\n this.$set(this, 'isFrist', true)\r\n } else {\r\n activePath = 'index'\r\n }\r\n }\r\n var routes = this.activeRoutes(activePath)\r\n if (routes.length === 0) {\r\n activePath = this.currentIndex || this.defaultRouter()\r\n this.activeRoutes(activePath)\r\n }\r\n return activePath\r\n }\r\n },\r\n beforeMount() {\r\n window.addEventListener('resize', this.setVisibleNumber)\r\n },\r\n beforeDestroy() {\r\n window.removeEventListener('resize', this.setVisibleNumber)\r\n },\r\n mounted() {\r\n this.setVisibleNumber()\r\n },\r\n methods: {\r\n // 根据宽度计算设置显示栏数\r\n setVisibleNumber() {\r\n const width = document.body.getBoundingClientRect().width / 3\r\n this.visibleNumber = parseInt(width / 85)\r\n },\r\n // 默认激活的路由\r\n defaultRouter() {\r\n let router\r\n Object.keys(this.routers).some((key) => {\r\n if (!this.routers[key].hidden) {\r\n router = this.routers[key].path\r\n return true\r\n }\r\n })\r\n return router\r\n },\r\n // 菜单选择事件\r\n handleSelect(key, keyPath) {\r\n this.currentIndex = key\r\n if (this.ishttp(key)) {\r\n // http(s):// 路径新窗口打开\r\n window.open(key, '_blank')\r\n } else if (key.indexOf('/redirect') !== -1) {\r\n // /redirect 路径内部打开\r\n this.$router.push({ path: key.replace('/redirect', '') })\r\n } else {\r\n // 显示左侧联动菜单\r\n this.activeRoutes(key)\r\n }\r\n },\r\n // 当前激活的路由\r\n activeRoutes(key) {\r\n var routes = []\r\n if (this.childrenMenus && this.childrenMenus.length > 0) {\r\n this.childrenMenus.map((item) => {\r\n if (key === item.parentPath || (key === 'index' && item.path === '')) {\r\n routes.push(item)\r\n }\r\n })\r\n }\r\n if (routes.length > 0) {\r\n this.$store.commit('SET_SIDEBAR_ROUTERS', routes)\r\n }\r\n return routes\r\n },\r\n ishttp(url) {\r\n return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1\r\n }\r\n }\r\n}\r\n",null]} |