linwenling
2023-10-22 dbca8bf9dde4fe0c7eb89a0c30b095eb823142a5
1
{"remainingRequest":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\src\\components\\TopNav\\index.vue?vue&type=style&index=0&id=35f3a2c1&lang=scss&","dependencies":[{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\src\\components\\TopNav\\index.vue","mtime":1676881540000},{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\css-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\vue-loader\\lib\\loaders\\stylePostLoader.js","mtime":499162500000},{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\postcss-loader\\src\\index.js","mtime":499162500000},{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\sass-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\Users\\小蓝\\Desktop\\赖博士版\\ruoyi-ui\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":[{"type":"Buffer","data":"base64:CgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoudG9wbWVudS1jb250YWluZXIuZWwtbWVudS0taG9yaXpvbnRhbCA+IC5lbC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ACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.vue","sourceRoot":"src/components/TopNav","sourcesContent":["<template>\n  <el-menu\n    :default-active=\"activeMenu\"\n    mode=\"horizontal\"\n    @select=\"handleSelect\"\n  >\n    <template v-for=\"(item, index) in topMenus\">\n      <el-menu-item :style=\"{'--theme': theme}\" :index=\"item.path\" :key=\"index\" v-if=\"index < visibleNumber\"\n        ><svg-icon :icon-class=\"item.meta.icon\" />\n        {{ item.meta.title }}</el-menu-item\n      >\n    </template>\n\n    <!-- 顶部菜单超出数量折叠 -->\n    <el-submenu :style=\"{'--theme': theme}\" index=\"more\" v-if=\"topMenus.length > visibleNumber\">\n      <template slot=\"title\">更多菜单</template>\n      <template v-for=\"(item, index) in topMenus\">\n        <el-menu-item\n          :index=\"item.path\"\n          :key=\"index\"\n          v-if=\"index >= visibleNumber\"\n          ><svg-icon :icon-class=\"item.meta.icon\" />\n          {{ item.meta.title }}</el-menu-item\n        >\n      </template>\n    </el-submenu>\n  </el-menu>\n</template>\n\n<script>\nimport { constantRoutes } from \"@/router\";\n\n// 隐藏侧边栏路由\nconst hideList = ['/index', '/user/profile'];\n\nexport default {\n  data() {\n    return {\n      // 顶部栏初始数\n      visibleNumber: 5,\n      // 当前激活菜单的 index\n      currentIndex: undefined\n    };\n  },\n  computed: {\n    theme() {\n      return this.$store.state.settings.theme;\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.children[0]);\n          } else {\n              topMenus.push(menu);\n          }\n        }\n      });\n      return topMenus;\n    },\n    // 所有的路由信息\n    routers() {\n      return this.$store.state.permission.topbarRouters;\n    },\n    // 设置子路由\n    childrenMenus() {\n      var childrenMenus = [];\n      this.routers.map((router) => {\n        for (var item in router.children) {\n          if (router.children[item].parentPath === undefined) {\n            if(router.path === \"/\") {\n              router.children[item].path = \"/\" + router.children[item].path;\n            } else {\n              if(!this.ishttp(router.children[item].path)) {\n                router.children[item].path = router.path + \"/\" + router.children[item].path;\n              }\n            }\n            router.children[item].parentPath = router.path;\n          }\n          childrenMenus.push(router.children[item]);\n        }\n      });\n      return constantRoutes.concat(childrenMenus);\n    },\n    // 默认激活的菜单\n    activeMenu() {\n      const path = this.$route.path;\n      let activePath = path;\n      if (path !== undefined && path.lastIndexOf(\"/\") > 0 && hideList.indexOf(path) === -1) {\n        const tmpPath = path.substring(1, path.length);\n        activePath = \"/\" + tmpPath.substring(0, tmpPath.indexOf(\"/\"));\n        if (!this.$route.meta.link) {\n          this.$store.dispatch('app/toggleSideBarHide', false);\n        }\n      } else if(!this.$route.children) {\n        activePath = path;\n        this.$store.dispatch('app/toggleSideBarHide', true);\n      }\n      this.activeRoutes(activePath);\n      return activePath;\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 / 3;\n      this.visibleNumber = parseInt(width / 85);\n    },\n    // 菜单选择事件\n    handleSelect(key, keyPath) {\n      this.currentIndex = key;\n      const route = this.routers.find(item => item.path === key);\n      if (this.ishttp(key)) {\n        // http(s):// 路径新窗口打开\n        window.open(key, \"_blank\");\n      } else if (!route || !route.children) {\n        // 没有子路由路径内部打开\n        this.$router.push({ path: key });\n        this.$store.dispatch('app/toggleSideBarHide', true);\n      } else {\n        // 显示左侧联动菜单\n        this.activeRoutes(key);\n        this.$store.dispatch('app/toggleSideBarHide', false);\n      }\n    },\n    // 当前激活的路由\n    activeRoutes(key) {\n      var routes = [];\n      if (this.childrenMenus && this.childrenMenus.length > 0) {\n        this.childrenMenus.map((item) => {\n          if (key == item.parentPath || (key == \"index\" && \"\" == item.path)) {\n            routes.push(item);\n          }\n        });\n      }\n      if(routes.length > 0) {\n        this.$store.commit(\"SET_SIDEBAR_ROUTERS\", routes);\n      } else {\n        this.$store.dispatch('app/toggleSideBarHide', true);\n      }\n    },\n    ishttp(url) {\n      return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1\n    }\n  },\n};\n</script>\n\n<style lang=\"scss\">\n.topmenu-container.el-menu--horizontal > .el-menu-item {\n  float: left;\n  height: 50px !important;\n  line-height: 50px !important;\n  color: #999093 !important;\n  padding: 0 5px !important;\n  margin: 0 10px !important;\n}\n\n.topmenu-container.el-menu--horizontal > .el-menu-item.is-active, .el-menu--horizontal > .el-submenu.is-active .el-submenu__title {\n  border-bottom: 2px solid #{'var(--theme)'} !important;\n  color: #303133;\n}\n\n/* submenu item */\n.topmenu-container.el-menu--horizontal > .el-submenu .el-submenu__title {\n  float: left;\n  height: 50px !important;\n  line-height: 50px !important;\n  color: #999093 !important;\n  padding: 0 5px !important;\n  margin: 0 10px !important;\n}\n</style>\n"]}]}