pageMenu.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <div class="pageMenu" v-bind:class="{ widthFold: menuFold }">
  3. <div class="panel">
  4. <div class="icon" v-show="!menuFold" @click="menuFoldHandle()">
  5. <b></b>
  6. </div>
  7. <div class="iconFold" v-show="menuFold" @click="menuFoldHandle(1)">
  8. <b></b>
  9. </div>
  10. <ul class="menuFold" v-show="menuFold">
  11. <li
  12. @click="menuFoldHandle(1)"
  13. v-bind:class="{ isOpened: opened === 'mainPage' }"
  14. >
  15. <b class="my-icon-home is"></b>
  16. </li>
  17. <li
  18. @click="menuFoldHandle(1)"
  19. v-bind:class="{ isOpened: opened === 'modelLibrary' }"
  20. >
  21. <b class="my-icon-menuA"></b>
  22. </li>
  23. <li
  24. @click="menuFoldHandle(1)"
  25. v-bind:class="{ isOpened: opened === 'algorithmsLibrary' }"
  26. >
  27. <b class="my-icon-menuB"></b>
  28. </li>
  29. <li
  30. @click="menuFoldHandle(1)"
  31. v-bind:class="{ isOpened: opened === 'sceneLibrary' }"
  32. >
  33. <b class="my-icon-menuC"></b>
  34. </li>
  35. <li
  36. @click="menuFoldHandle(1)"
  37. v-bind:class="{ isOpened: opened === 'workManagement' }"
  38. >
  39. <b class="my-icon-menuD"></b>
  40. </li>
  41. <!-- <li
  42. @click="menuFoldHandle(1)"
  43. v-bind:class="{ isOpened: opened === 'systemManagement' }"
  44. >
  45. <b class="my-icon-menuE"></b>
  46. </li>
  47. <li
  48. @click="menuFoldHandle(1)"
  49. v-bind:class="{ isOpened: opened === 'systemManagement' }"
  50. >
  51. <b class="my-icon-menuF"></b>
  52. </li> -->
  53. </ul>
  54. <div class="menuList" v-show="!menuFold">
  55. <el-menu
  56. ref="menu"
  57. :default-active="activeMenu"
  58. class="el-menu-vertical-demo"
  59. :background-color="themeColor"
  60. :unique-opened="true"
  61. :router="true"
  62. @select="menuSel"
  63. >
  64. <!-- active-text-color="#ffffff" -->
  65. <el-menu-item :index="menus[0]" class="indexMenu">
  66. <i class="my-icon-home"></i>
  67. <span>首页</span>
  68. </el-menu-item>
  69. <el-submenu :index="menus[1]">
  70. <template slot="title">
  71. <i class="my-icon-menuA"></i>
  72. <span>模型库</span>
  73. </template>
  74. <el-menu-item index="/sensorModel"
  75. >传感器模型</el-menu-item
  76. >
  77. <el-menu-item index="/vehicleModel"
  78. >车辆模型</el-menu-item
  79. >
  80. <el-menu-item index="/vehicleConfigurationList"
  81. >车辆配置</el-menu-item
  82. >
  83. </el-submenu>
  84. <el-submenu :index="menus[2]">
  85. <template slot="title">
  86. <i class="my-icon-menuB"></i>
  87. <span>算法库</span>
  88. </template>
  89. <el-menu-item index="/algorithmsLibraryList"
  90. >算法库列表</el-menu-item
  91. >
  92. <el-menu-item index="/algorithmsPlatformList"
  93. >算法平台</el-menu-item
  94. >
  95. </el-submenu>
  96. <el-submenu :index="menus[3]">
  97. <template slot="title">
  98. <i class="my-icon-menuC"></i>
  99. <span>场景库</span>
  100. </template>
  101. <el-menu-item index="/naturalDrivingScenarioList"
  102. >自然驾驶场景</el-menu-item
  103. >
  104. <el-menu-item
  105. index="/standardRegulationSimulationScenarioList"
  106. >标准法规仿真场景</el-menu-item
  107. >
  108. <el-menu-item
  109. index="/trafficAccidentSimulationScenarioList"
  110. >交通事故仿真场景</el-menu-item
  111. >
  112. <el-menu-item index="/scenarioTestPackageManagementList"
  113. >场景测试包管理</el-menu-item
  114. >
  115. <el-menu-item index="/gradingRulesList"
  116. >评分规则</el-menu-item
  117. >
  118. </el-submenu>
  119. <el-submenu :index="menus[4]">
  120. <template slot="title">
  121. <i class="my-icon-menuD"></i>
  122. <span>工作管理</span>
  123. </template>
  124. <el-menu-item index="/manualRunProjectList"
  125. >手动运行项目</el-menu-item
  126. >
  127. </el-submenu>
  128. <el-submenu index="systemManagement">
  129. <template slot="title">
  130. <i class="my-icon-menuF"></i>
  131. <span>系统管理</span>
  132. </template>
  133. <el-menu-item index="/accountManagement"
  134. >账户管理</el-menu-item
  135. >
  136. <el-menu-item index="/parameterManagement"
  137. >参数管理</el-menu-item
  138. >
  139. <el-menu-item index="clusteringManagement"
  140. >集群管理</el-menu-item>
  141. </el-submenu>
  142. </el-menu>
  143. </div>
  144. </div>
  145. </div>
  146. </template>
  147. <script>
  148. import { mapState } from "vuex";
  149. export default {
  150. name: "pageMenu",
  151. data() {
  152. return {
  153. menuFold: false, // menu是否折叠
  154. opened: false,
  155. menus: [
  156. "/mainPage",
  157. "modelLibrary",
  158. "algorithmsLibrary",
  159. "sceneLibrary",
  160. "workManagement",
  161. ],
  162. activeMenu: "mainPage", // 当前menu
  163. expiresTime: '',
  164. toExpiresTime: '',
  165. tokenTimer: undefined
  166. };
  167. },
  168. computed: {
  169. ...mapState(["themeColor"]),
  170. },
  171. mounted() {
  172. let menuKind = this.$route.meta.menuKind;
  173. if (menuKind && menuKind !== "mainPage") {
  174. this.$refs.menu.open(menuKind);
  175. }
  176. //设置一个定时器定时查看过期时间,如果距离过期时间小于5min,则发送refreshToken
  177. /*
  178. this.expiresTime = localStorage.getItem('expiresTime')
  179. this.toExpiresTime = new Date(this.expiresTime).getTime() - new Date().getTime();
  180. if(this.toExpiresTime < 5*60*1000){
  181. this.refreshToken()
  182. }else{
  183. setInterval(function(){
  184. let that = this;
  185. that.checkExpiresTime()
  186. }, 5*60*1000)
  187. }*/
  188. },
  189. methods: {
  190. menuFoldHandle(val) {
  191. if (val) {
  192. this.menuFold = false;
  193. } else {
  194. this.menuFold = true;
  195. }
  196. this.$emit("menuFold", this.menuFold);
  197. },
  198. menuSel(index, indexPath) {
  199. // console.log(index, indexPath);
  200. this.opened = indexPath[0];
  201. // 如果是首页 手动关闭其他菜单
  202. if (index === this.menus[0]) {
  203. this.menus.forEach((i) => {
  204. this.$refs.menu.close(i);
  205. });
  206. }
  207. },
  208. checkExpiresTime(){
  209. this.toExpiresTime = new Date(this.expiresTime).getTime() - new Date().getTime();
  210. if(this.toExpiresTime < 5*60*1000){
  211. this.refreshToken()
  212. }
  213. },
  214. refreshToken(){
  215. this.$axios({
  216. method: "post",
  217. url: this.$api.common.refreshToken,
  218. data: {
  219. refreshToken: localStorage.getItem("refreshToken"),
  220. },
  221. }).then((res) => {
  222. if (res.code == 200 && res.info) {
  223. let Authorization = res.info.token_type + ' ' + res.info.access_token;
  224. let refreshToken = res.info.refresh_token;
  225. let expiresTime = res.info.expires_time;
  226. localStorage.clear();
  227. localStorage.setItem("Authorization", Authorization);
  228. localStorage.setItem("refreshToken", refreshToken);
  229. localStorage.setItem("expiresTime", expiresTime);
  230. this.expiresTime = expiresTime
  231. this.toExpiresTime = new Date(this.expiresTime).getTime() - new Date().getTime();
  232. }
  233. })
  234. }
  235. },
  236. };
  237. </script>
  238. <style scoped lang="less">
  239. .pageMenu {
  240. position: fixed;
  241. top: 0;
  242. left: 0;
  243. right: 0;
  244. bottom: 0;
  245. z-index: 666;
  246. width: 150px;
  247. height: 100%;
  248. [class^="my-icon-"] {
  249. vertical-align: middle;
  250. text-align: center;
  251. font-size: 18px;
  252. background-size: contain;
  253. }
  254. }
  255. .widthFold {
  256. width: 60px;
  257. }
  258. .panel {
  259. position: absolute;
  260. left: 0;
  261. top: 0;
  262. bottom: 0;
  263. z-index: 9;
  264. width: 100%;
  265. height: 100%;
  266. background: @themeColor;
  267. }
  268. .icon,
  269. .iconFold {
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. height: 61px;
  274. border-bottom: 1px solid #ffffff;
  275. cursor: pointer;
  276. b {
  277. display: block;
  278. }
  279. }
  280. .iconFold {
  281. width: 60px;
  282. b {
  283. width: 28px;
  284. height: 38px;
  285. background: url("../../assets/common/image/menu/iconFold.png") center
  286. no-repeat;
  287. background-size: contain;
  288. }
  289. }
  290. .icon {
  291. width: 150px;
  292. b {
  293. width: 98px;
  294. height: 27px;
  295. background: url("../../assets/common/image/menu/icon.png") center
  296. no-repeat;
  297. background-size: contain;
  298. }
  299. }
  300. .el-submenu [class^="my-icon-"],
  301. .el-menu-item [class^="my-icon-"] {
  302. width: 24px;
  303. height: 18px;
  304. margin-right: 5px;
  305. }
  306. .indexMenu {
  307. padding-left: 15px !important;
  308. padding-right: 10px !important;
  309. span {
  310. color: #ffffff !important;
  311. }
  312. }
  313. .my-icon-home {
  314. background: url("../../assets/common/image/menu/home.png") center no-repeat;
  315. }
  316. .my-icon-menuA {
  317. background: url("../../assets/common/image/menu/menuA.png") center no-repeat;
  318. }
  319. .my-icon-menuB {
  320. background: url("../../assets/common/image/menu/menuB.png") center no-repeat;
  321. }
  322. .my-icon-menuC {
  323. background: url("../../assets/common/image/menu/menuC.png") center no-repeat;
  324. }
  325. .my-icon-menuD {
  326. background: url("../../assets/common/image/menu/menuD.png") center no-repeat;
  327. }
  328. .my-icon-menuE {
  329. background: url("../../assets/common/image/menu/menuE.png") center no-repeat;
  330. }
  331. .my-icon-menuF {
  332. background: url("../../assets/common/image/menu/menuF.png") center no-repeat;
  333. }
  334. .menuFold {
  335. li {
  336. display: flex;
  337. align-items: center;
  338. justify-content: center;
  339. height: 40px;
  340. margin-top: 20px;
  341. cursor: pointer;
  342. b {
  343. display: block;
  344. width: 20px;
  345. height: 20px;
  346. }
  347. }
  348. .isOpened {
  349. background-color: #2979cc;
  350. }
  351. }
  352. .el-menu {
  353. border-right-color: @themeColor;
  354. /deep/ .el-submenu__title,
  355. .el-menu-item {
  356. color: #d7e7fe;
  357. &.is-active {
  358. color: #ffffff;
  359. font-weight: bold;
  360. }
  361. }
  362. /deep/ .el-submenu__title {
  363. padding-left: 15px !important;
  364. padding-right: 10px;
  365. span {
  366. color: #ffffff;
  367. }
  368. }
  369. /deep/ .el-submenu__icon-arrow {
  370. right: 10px;
  371. }
  372. /deep/ .el-submenu__title i,
  373. /deep/ .el-menu-item i {
  374. color: #ffffff;
  375. }
  376. /deep/ .el-submenu .el-menu-item {
  377. min-width: auto;
  378. width: 100%;
  379. padding: 0;
  380. padding-left: 30px !important;
  381. }
  382. }
  383. .el-submenu.is-active {
  384. /deep/ .el-submenu__title {
  385. background-color: #2979cc !important;
  386. }
  387. }
  388. .el-submenu.is-active.is-opened {
  389. /deep/ .el-submenu__title {
  390. background-color: @themeColor !important;
  391. }
  392. }
  393. .el-submenu.is-opened {
  394. .el-menu,
  395. .el-menu-item {
  396. background-color: #2979cc !important;
  397. }
  398. }
  399. .hasList {
  400. /deep/ .el-menu-item {
  401. color: #d7e7fe;
  402. }
  403. /deep/ .is-active {
  404. background-color: #3982eb !important;
  405. color: #ffffff;
  406. }
  407. }
  408. .userIcon {
  409. > div {
  410. position: fixed;
  411. bottom: 30px;
  412. }
  413. }
  414. </style>