| | |
| | | <template> |
| | | <div> |
| | | <div class="leftTopWrapper"> |
| | | <div class="logo"> |
| | | <img src="../assets/img/www.terra-it.cn.png" alt="" /> |
| | | </div> |
| | | <div class="menu"> |
| | | <el-menu |
| | | active-text-color="#ffd04b" |
| | | class="el-menu-vertical-demo" |
| | | :default-active="activeIndex" |
| | | background-color="#586884" |
| | | text-color="#fff" |
| | | @select="handleselect" |
| | | > |
| | | <customElMenu :menuData="menuList"></customElMenu> |
| | | </el-menu> |
| | | </div> |
| | | <div class="topMenu"> |
| | | <div class="logo"> |
| | | <img src="../assets/img/www.terra-it.cn.png" alt="" /> |
| | | </div> |
| | | <div class="leftBotWrapper"> |
| | | <div class="rightWrapper"> |
| | | <div class="menu"> |
| | | <ul> |
| | | <li v-for="item in menuList" :key="item.id"> |
| | | {{ item.cnName }} |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | <div class="userInfo"> |
| | | <img src="../assets/img/user.png" alt="" /> |
| | | <span>admin</span> |
| | | <span @click="logOut">注销</span> |
| | | |
| | | <span @click="switchLang"> 切换语言</span> |
| | | </div> |
| | | <div class="btnBox"> |
| | | <div><img src="../assets/img/leftBtn.png" alt="" /></div> |
| | | <div><img src="../assets/img/rightBtn.png" alt="" /></div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | import { logout } from "@/api/api"; |
| | | import { removeToken, getToken } from "@/utils/auth"; |
| | | import customElMenu from "../components/customElMenu.vue"; |
| | | import { queryMenuTree, updateMenuTree, queryMaxId } from "../api/api"; |
| | | import { queryMenuTree, getPerms } from "../api/api"; |
| | | |
| | | export default { |
| | | name: "navMenu", |
| | |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.getUserPerms(); |
| | | this.getMenuTree(); |
| | | }, |
| | | computed: { |
| | |
| | | if (res.code == 200) { |
| | | if (res.result.length != 0) { |
| | | let menuLists = res.result.filter((value) => { |
| | | return value.type == 1; |
| | | return value.pid == 1; |
| | | }); |
| | | this.menuList = this.treeData(menuLists); |
| | | // console.log(menuLists); |
| | | this.menuList = menuLists; |
| | | } else { |
| | | alert("暂无菜单栏数据"); |
| | | } |
| | |
| | | }) |
| | | .then(async () => { |
| | | const data = await logout({ token: getToken() }); |
| | | console.log(data); |
| | | // console.log(data); |
| | | if (data.code != 200) { |
| | | return this.$message.error("退出登录失败"); |
| | | } |
| | |
| | | this.$store.commit("changeLang", "en"); //传递点击的节点 |
| | | } |
| | | }, |
| | | handleselect(index, indexPath) { |
| | | handleselect(index, indexPath, e) { |
| | | // console.log(e.$attrs.perms); |
| | | this.$store.commit("currentPerms", e.$attrs.perms.perms); |
| | | if (Window.ws != null) { |
| | | Window.ws.close(); |
| | | Window.ws.onclose = () => { |
| | | console.log("服务器关闭"); |
| | | }; |
| | | Window.ws = null; |
| | | } |
| | | |
| | | if (index.indexOf("http") != -1) { |
| | | this.$router.push("/databaseMonitoring"); |
| | | this.$store.commit("getIframe", index); |
| | | } else if (isNaN(Number(index))) { |
| | | this.$router.push(index); |
| | | } |
| | | }, |
| | | getUserPerms() { |
| | | getPerms().then((res) => { |
| | | if (res.code == 200) this.$store.commit("getPermsEntity", res.result); |
| | | }); |
| | | }, |
| | | }, |
| | | watch: { |
| | |
| | | </script> |
| | | <style lang="less" scoped> |
| | | //@import url(); 引入公共css类 |
| | | .leftTopWrapper { |
| | | .topMenu { |
| | | width: 100%; |
| | | .logo { |
| | | // background-color: rgb(139, 0, 0); |
| | | width: 249px; |
| | | height: 52px; |
| | | img { |
| | | width: 100%; |
| | | } |
| | | } |
| | | .menu { |
| | | height: 740px; |
| | | margin-top: 22px; |
| | | overflow: auto; |
| | | |
| | | .el-menu { |
| | | width: 234px; |
| | | border-right: none; |
| | | /deep/ .el-submenu { |
| | | margin-bottom: 10px; |
| | | .el-submenu__title { |
| | | background-color: transparent !important; |
| | | } |
| | | } |
| | | .faSub { |
| | | background-color: #586884; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | .leftBotWrapper { |
| | | width: 258px; |
| | | position: absolute; |
| | | left: 19px; |
| | | bottom: 17px; |
| | | height: 100%; |
| | | background-image: linear-gradient(rgb(34, 33, 33), rgb(27, 31, 78)); |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | .userInfo { |
| | | // width: 138px; |
| | | font-size: 16px; |
| | | font-family: Microsoft YaHei; |
| | | font-weight: 400; |
| | | color: #fcfcfc; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | cursor: pointer; |
| | | |
| | | .logo { |
| | | width: 500px; |
| | | height: 100%; |
| | | position: relative; |
| | | img { |
| | | width: 70%; |
| | | position: absolute; |
| | | top: 0; |
| | | bottom: 0; |
| | | left: 0; |
| | | right: 0; |
| | | margin: auto; |
| | | } |
| | | } |
| | | .btnBox { |
| | | width: 65px; |
| | | .rightWrapper { |
| | | width: 70%; |
| | | height: 100%; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | .menu { |
| | | height: 100%; |
| | | width: 80%; |
| | | background-color: rgb(120, 121, 120); |
| | | ul { |
| | | display: flex; |
| | | justify-content: space-around; |
| | | li { |
| | | width: 120px; |
| | | height: 120px; |
| | | background: #bfa; |
| | | } |
| | | } |
| | | } |
| | | .userInfo { |
| | | background-color: pink; |
| | | |
| | | // width: 138px; |
| | | font-size: 16px; |
| | | font-family: Microsoft YaHei; |
| | | font-weight: 400; |
| | | color: #fcfcfc; |
| | | // display: flex; |
| | | // justify-content: space-between; |
| | | // align-items: center; |
| | | // cursor: pointer; |
| | | } |
| | | } |
| | | } |
| | | </style> |