new-menue.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <nav class="site-navbar mynewnav" :class="'site-navbar--' + mybarLayoutSkin">
  3. <!-- <div class="site-navbar__header">
  4. <h1 class="site-navbar__brand" @click="$router.push({ name: 'home' })">
  5. <a class="site-navbar__brand-lg" href="javascript:;">智能算法平台</a>
  6. <a class="site-navbar__brand-mini" href="javascript:;">人人</a>
  7. </h1>
  8. </div> -->
  9. <el-menu class="my" mode="horizontal"
  10. background-color="#545c64" text-color="#fff" active-text-color="#fff">
  11. <el-menu-item class="site-navbar__brand" @click="$router.push({ path: '/visi-dataset'})"> <a
  12. class="site-navbar__brand-lg" href="javascript:;">智能算法平台</a></el-menu-item>
  13. <el-menu-item index="home" @click="$router.push({ name: 'home' })">
  14. <span slot="title">帮助文档</span>
  15. </el-menu-item>
  16. <!-- <el-menu-item index="home" @click="$router.push({ name: 'home' })">
  17. <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg>
  18. <span slot="title">首页</span>
  19. </el-menu-item> -->
  20. <!-- 开始自己的菜单这部分为测试静态路由,不需要 -->
  21. <!-- <el-menu-item index="dataset" @click="$router.push({ name: 'dataset' })">
  22. <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg>
  23. <span slot="title">数据集管理</span>
  24. </el-menu-item> -->
  25. <!-- demo菜单 -->
  26. <!-- <el-submenu index="demo">
  27. <template slot="title">
  28. <icon-svg name="shoucang" class="site-sidebar__menu-icon"></icon-svg>
  29. <span>demo</span>
  30. </template>
  31. <el-menu-item index="demo-echarts" @click="$router.push({ name: 'demo-echarts' })">
  32. <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg>
  33. <span slot="title">echarts</span>
  34. </el-menu-item>
  35. <el-menu-item index="demo-ueditor" @click="$router.push({ name: 'demo-ueditor' })">
  36. <icon-svg name="editor" class="site-sidebar__menu-icon"></icon-svg>
  37. <span slot="title">ueditor</span>
  38. </el-menu-item>
  39. </el-submenu> -->
  40. <!--
  41. <el-submenu index="demo">
  42. <template slot="title">
  43. <icon-svg name="shoucang" class="site-sidebar__menu-icon"></icon-svg>
  44. <span>demo</span>
  45. </template>
  46. <el-menu-item index="demo-echarts" @click="$router.push({ name: 'demo-echarts' })">
  47. <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg>
  48. <span slot="title">echarts</span>
  49. </el-menu-item>
  50. <el-menu-item index="demo-ueditor" @click="$router.push({ name: 'demo-ueditor' })">
  51. <icon-svg name="editor" class="site-sidebar__menu-icon"></icon-svg>
  52. <span slot="title">ueditor</span>
  53. </el-menu-item>
  54. </el-submenu> -->
  55. <sub-menu v-for="menu in menuList" :key="menu.menuId" :menu="menu" :dynamicMenuRoutes="dynamicMenuRoutes" >
  56. </sub-menu>
  57. <!-- 导航右边 从设置按钮开始-->
  58. <el-menu-item style="float:right" class="site-navbar__avatar " index="6">
  59. <el-dropdown :show-timeout="0" placement="bottom">
  60. <span class="el-dropdown-link">
  61. <img src="~@/assets/img/avatar.png" :alt="userName" />{{
  62. userName
  63. }}
  64. </span>
  65. <el-dropdown-menu slot="dropdown">
  66. <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>
  67. <!-- <el-dropdown-item @click.native="switchBigData()">大数据平台</el-dropdown-item>
  68. <el-dropdown-item @click.native="switchMkcloud()">智能云平台</el-dropdown-item>
  69. <el-dropdown-item @click.native="switchScreen()">大屏展示</el-dropdown-item> -->
  70. <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
  71. </el-dropdown-menu>
  72. </el-dropdown>
  73. </el-menu-item>
  74. <!-- <el-menu-item style="float:right" index="5" @click="$router.push({ name: 'theme' })">
  75. <template slot="title">
  76. <icon-svg name="shezhi" class="el-icon-setting"></icon-svg>
  77. </template>
  78. </el-menu-item> -->
  79. <!-- 弹窗, 修改密码 -->
  80. <update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password>
  81. </el-menu>
  82. </nav>
  83. </template>
  84. <script>
  85. import SubMenu from "./main-sidebar-sub-menu";
  86. import { isURL } from "@/utils/validate";
  87. import UpdatePassword from "./main-navbar-update-password";
  88. import { clearLoginInfo } from "@/utils";
  89. import { MessageBox } from 'element-ui'
  90. import { Message } from "element-ui"
  91. export default {
  92. data() {
  93. return {
  94. dynamicMenuRoutes: [],
  95. updatePassowrdVisible: false,
  96. };
  97. },
  98. components: {
  99. SubMenu,
  100. UpdatePassword,
  101. },
  102. computed: {
  103. navbarLayoutType: {
  104. get() {
  105. return this.$store.state.common.navbarLayoutType;
  106. },
  107. },
  108. sidebarFold: {
  109. get() {
  110. return this.$store.state.common.sidebarFold;
  111. },
  112. set(val) {
  113. this.$store.commit("common/updateSidebarFold", val);
  114. },
  115. },
  116. mainTabs: {
  117. get() {
  118. return this.$store.state.common.mainTabs;
  119. },
  120. set(val) {
  121. this.$store.commit("common/updateMainTabs", val);
  122. },
  123. },
  124. userName: {
  125. get() {
  126. return this.$store.state.user.name;
  127. },
  128. },
  129. //分隔
  130. mybarLayoutSkin: {
  131. get() {
  132. return this.$store.state.common.mybarLayoutSkin;
  133. },
  134. },
  135. sidebarFold: {
  136. get() {
  137. return this.$store.state.common.sidebarFold;
  138. },
  139. },
  140. menuList: {
  141. get() {
  142. return this.$store.state.common.menuList;
  143. },
  144. set(val) {
  145. this.$store.commit("common/updateMenuList", val);
  146. },
  147. },
  148. menuActiveName: {
  149. get() {
  150. return this.$store.state.common.menuActiveName;
  151. },
  152. set(val) {
  153. this.$store.commit("common/updateMenuActiveName", val);
  154. },
  155. },
  156. mainTabs: {
  157. get() {
  158. return this.$store.state.common.mainTabs;
  159. },
  160. set(val) {
  161. this.$store.commit("common/updateMainTabs", val);
  162. },
  163. },
  164. mainTabsActiveName: {
  165. get() {
  166. return this.$store.state.common.mainTabsActiveName;
  167. },
  168. set(val) {
  169. this.$store.commit("common/updateMainTabsActiveName", val);
  170. },
  171. },
  172. },
  173. watch: {
  174. $route: "routeHandle",
  175. },
  176. created() {
  177. this.menuList = JSON.parse(sessionStorage.getItem("menuList") || "[]");
  178. this.dynamicMenuRoutes = JSON.parse(
  179. sessionStorage.getItem("dynamicMenuRoutes") || "[]"
  180. );
  181. this.routeHandle(this.$route);
  182. },
  183. methods: {
  184. // 路由操作
  185. routeHandle(route) {
  186. if (route.meta.isTab) {
  187. // tab选中, 不存在先添加
  188. var tab = this.mainTabs.filter((item) => item.name === route.name)[0];
  189. if (!tab) {
  190. if (route.meta.isDynamic) {
  191. route = this.dynamicMenuRoutes.filter(
  192. (item) => item.name === route.name
  193. )[0];
  194. if (!route) {
  195. return console.error("未能找到可用标签页!");
  196. }
  197. }
  198. tab = {
  199. menuId: route.meta.menuId || route.name,
  200. name: route.name,
  201. title: route.meta.title,
  202. type: isURL(route.meta.iframeUrl) ? "iframe" : "module",
  203. iframeUrl: route.meta.iframeUrl || "",
  204. params: route.params,
  205. query: route.query,
  206. };
  207. this.mainTabs = this.mainTabs.concat(tab);
  208. }
  209. this.menuActiveName = tab.menuId + "";
  210. this.mainTabsActiveName = tab.name;
  211. }
  212. },
  213. //分隔
  214. // 修改密码
  215. updatePasswordHandle() {
  216. this.updatePassowrdVisible = true;
  217. this.$nextTick(() => {
  218. this.$refs.updatePassowrd.init();
  219. });
  220. },
  221. // 切换大数据平台
  222. switchBigData() {
  223. // window.location.href = "http://112.126.68.148/#/"
  224. window.location.href = "http://112.126.68.148/bdm/#/"
  225. },
  226. // 切换智能云平台
  227. switchMkcloud() {
  228. // window.location.href = "http://112.126.68.148/#/"
  229. window.location.href = "http://112.126.68.148/mkcloud/#/"
  230. },
  231. // 切换大屏展示
  232. switchScreen() {
  233. // window.location.href = "http://112.126.68.148/#/"
  234. window.location.href = "http://112.126.68.148/screen/#/"
  235. },
  236. // 退出
  237. logoutHandle() {
  238. MessageBox.confirm(`确定进行[退出]操作?`, "提示", {
  239. confirmButtonText: "确定",
  240. cancelButtonText: "取消",
  241. type: "warning",
  242. })
  243. .then(() => {
  244. this.$http({
  245. url: this.$http.adornUrl("/sys/logout"),
  246. method: "post",
  247. data: this.$http.adornData(),
  248. }).then(({ data }) => {
  249. if (data && data.code === 0) {
  250. clearLoginInfo();
  251. this.$router.push({ name: "login" });
  252. //window.location.href="http://112.126.68.148/#/";
  253. }
  254. });
  255. })
  256. .catch(() => {});
  257. },
  258. },
  259. };
  260. </script>
  261. <style scoped>
  262. .mynewnav {
  263. height: 50px;
  264. width: 1903px;
  265. line-height: 50px;
  266. }
  267. .site-navbar__brand {
  268. display: table-cell;
  269. vertical-align: middle;
  270. /*width: 230px;*/
  271. width: 200px;
  272. height: 60px;
  273. margin: 0;
  274. line-height: 60px;
  275. font-size: 20px;
  276. text-align: center;
  277. text-transform: uppercase;
  278. white-space: nowrap;
  279. color: #fff;
  280. }
  281. </style>