Manage.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <script setup lang="ts">
  2. import { onMounted, ref, nextTick, getCurrentInstance, reactive, onBeforeUnmount } from 'vue';
  3. import utils from "../util/common";
  4. import { useRoute } from "vue-router";
  5. import router from '../router/index'
  6. // import { removeToken } from "../util/tokenUtil";
  7. import { useUserInfo } from '@/stores/userInfo';
  8. const home = ref("");
  9. const avatar = ref("");
  10. const userName = ref("未知用户");
  11. const route = useRoute();////必须写在外面
  12. const gotoHome = () => {
  13. ///根据用户判断,如果是教师则返回后台
  14. let path = route.path;
  15. console.log(path);
  16. if (path.indexOf("/CourseEditor") >= 0 || path.indexOf("/CourseMng") >= 0) {
  17. router.push({
  18. path: "/CourseMng",
  19. });
  20. return;
  21. }
  22. router.push({
  23. path: "/TaskMng",
  24. });
  25. }
  26. const logOut = () => {
  27. const userInfo = useUserInfo();
  28. userInfo.removeToken();
  29. router.push({
  30. path: "/",
  31. });
  32. }
  33. onMounted(() => {
  34. const userInfo = useUserInfo();
  35. userName.value = userInfo.nickName;
  36. if (userInfo.userType != 1) {
  37. router.push({
  38. path: "/",
  39. });
  40. }
  41. });
  42. </script>
  43. <template>
  44. <el-container class="el-wrapper">
  45. <el-header class="header-title-wrap">
  46. <div class="header-title">排水管网运维养护虚拟仿真教学平台</div>
  47. <div class="header-opts">
  48. <el-popover trigger="click">
  49. <template #reference>
  50. <div class="user-wrap">
  51. <el-avatar>
  52. <el-icon :size="24"><Avatar /></el-icon>
  53. </el-avatar>
  54. <span class="user-name">{{userName}}</span>
  55. </div>
  56. </template>
  57. <el-col>
  58. <div @click="logOut" style="cursor:pointer;">
  59. <a class="drawdown-item">
  60. <el-icon style="vertical-align: middle;margin:-3px 0.5rem 0 0; height:1.2rem; line-height:1rem;">
  61. <SwitchButton />
  62. </el-icon>
  63. <span>退出登录</span>
  64. </a>
  65. </div>
  66. </el-col>
  67. </el-popover>
  68. <a class="back-btn" @click="gotoHome" v-if="route.path.toLowerCase().indexOf('taskmng')<1" style="" title="返回"></a>
  69. </div>
  70. </el-header>
  71. <el-container class="el-main">
  72. <router-view />
  73. </el-container>
  74. </el-container>
  75. </template>
  76. <style scoped>
  77. .el-wrapper {
  78. display: grid;
  79. height: 100%;
  80. width: 100%;
  81. overflow: hidden;
  82. grid-template-rows: 60px 1fr;
  83. }
  84. .el-container {
  85. width: 100%;
  86. padding: 0;
  87. overflow: hidden;
  88. }
  89. .header-title-wrap {
  90. width: 100%;
  91. color: #fff;
  92. background-color: var(--el-color-primary);
  93. display: flex;
  94. justify-content: space-between;
  95. }
  96. .el-aside {
  97. transition: width 0.5s ease;
  98. }
  99. .container-main {
  100. transition: width 0.5s ease;
  101. }
  102. .el-menu {
  103. transition: width 0.5s ease;
  104. }
  105. .el-main {
  106. height: calc(100vh - 60px);
  107. /* background:#ccc;*/
  108. display: flex;
  109. background-color: rgb(246,246,246);
  110. }
  111. .header-title {
  112. background-color: var(--el-color-primary);
  113. font-weight: bold;
  114. font-size: 1.5rem;
  115. line-height: 60px;
  116. justify-self: flex-start;
  117. width: 30rem;
  118. }
  119. .header-opts {
  120. margin-right: 1rem;
  121. display: flex;
  122. align-items: center;
  123. }
  124. .header-opts > .el-avatar {
  125. margin-right: 1rem;
  126. cursor: pointer;
  127. }
  128. .user-wrap {
  129. display: flex;
  130. justify-self: flex-start;
  131. vertical-align: middle;
  132. height: 100%;
  133. align-items: center;
  134. cursor: pointer;
  135. }
  136. .user-name {
  137. margin-left: 0.5rem;
  138. }
  139. .log-out {
  140. justify-self: flex-end;
  141. line-height: 60px;
  142. cursor: pointer;
  143. }
  144. .header-bread {
  145. height: 3rem;
  146. display: flex;
  147. align-items: center;
  148. color: var(--el-text-color-regular);
  149. }
  150. .el-breadcrumb {
  151. line-height: 3rem;
  152. }
  153. .avatar {
  154. }
  155. .el-avatar {
  156. background: none;
  157. }
  158. .back-btn {
  159. margin-right: 0rem;
  160. margin-left:2rem;
  161. display: flex;
  162. align-self: center;
  163. background-image:url(@/assets/techer/task-back.png);
  164. height:2rem;
  165. width:2rem;
  166. background-size:2rem;
  167. background-repeat:no-repeat;
  168. background-position:center;
  169. }
  170. .drawdown-item {
  171. display: block;
  172. height: 2rem;
  173. line-height: 2rem;
  174. font-size: 1rem;
  175. text-decoration: none;
  176. color: var(--el-color-primary);
  177. }
  178. .container-main {
  179. }
  180. .el-aside {
  181. height: 100%;
  182. border-right: 1px solid var(--el-border-color);
  183. }
  184. .el-menu {
  185. height: calc(100vh - 60px);
  186. border-right: none !important;
  187. }
  188. .header-bread {
  189. height: 3rem;
  190. }
  191. .el-breadcrumb {
  192. line-height: 3rem;
  193. }
  194. .bread {
  195. }
  196. .el-main-inner {
  197. overflow: hidden;
  198. box-sizing: border-box;
  199. }
  200. </style>