Header.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div>
  3. <!-- //根据平台不同传不同参0后台(管理员)1老师2学生 eduIdentity
  4. {{userInfo.eduIdentity}}
  5. 管理员 -->
  6. <div v-if="userInfo.eduIdentity == 0" style="display: flex; width: 100vw; justify-content: space-between; align-items: center">
  7. <div style="display: flex; padding-left: 10%">
  8. <div style="width: 120px; height: 55px; background-color: brown" />
  9. <a-menu v-model:selectedKeys="current" mode="horizontal" theme="light" style="line-height: 55px">
  10. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">资源管理</a-menu-item>
  11. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">全院课程</a-menu-item>
  12. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">全院开课</a-menu-item>
  13. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">数据挖掘</a-menu-item>
  14. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">镜像控制台</a-menu-item>
  15. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">专业</a-menu-item>
  16. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">院系</a-menu-item>
  17. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">组织机构</a-menu-item>
  18. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">后台管理</a-menu-item>
  19. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">资源任务分配</a-menu-item>
  20. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">统计分析</a-menu-item>
  21. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">论坛</a-menu-item>
  22. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">站内信</a-menu-item>
  23. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">公告发布</a-menu-item>
  24. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">管理员登录</a-menu-item>
  25. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceManagement">密码找回</a-menu-item>
  26. </a-menu>
  27. </div>
  28. <div class="header-right">
  29. <div style="display: flex">
  30. <UserOutlined :style="{ fontSize: '16px', color: '#00000083' }" />
  31. <div style="width: 5px"></div>
  32. <span style="font-size: 12px; color: #00000083">登录</span>
  33. </div>
  34. <div style="width: 20px"></div>
  35. <div style="display: flex">
  36. <span style="font-size: 12px; color: #00000083">注册</span>
  37. </div>
  38. </div>
  39. </div>
  40. <div v-if="userInfo.eduIdentity == 1" style="display: flex; width: 100vw; justify-content: space-between; align-items: center">
  41. <div style="display: flex; padding-left: 10%">
  42. <div style="width: 120px; height: 55px; background-color: brown" />
  43. <a-menu v-model:selectedKeys="current" mode="horizontal" theme="light" style="line-height: 55px">
  44. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/resourceCenter">资源中心</a-menu-item>
  45. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/personalResources">个人资源</a-menu-item>
  46. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">课程管理</a-menu-item>
  47. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">问答管理</a-menu-item>
  48. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">班级管理</a-menu-item>
  49. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">考试管理</a-menu-item>
  50. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">问卷管理</a-menu-item>
  51. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">试题管理</a-menu-item>
  52. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">统计分析</a-menu-item>
  53. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">个人中心</a-menu-item>
  54. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">论坛</a-menu-item>
  55. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">站内信</a-menu-item>
  56. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">课程公告发布</a-menu-item>
  57. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">登录</a-menu-item>
  58. <a-menu-item style="margin-left: 10px; margin-right: 10px" key="portal/courseManagement">密码找回</a-menu-item>
  59. </a-menu>
  60. </div>
  61. <div class="header-right">
  62. <div style="display: flex">
  63. <UserOutlined :style="{ fontSize: '16px', color: '#00000083' }" />
  64. <div style="width: 5px"></div>
  65. <span style="font-size: 12px; color: #00000083">登录</span>
  66. </div>
  67. <div style="width: 20px"></div>
  68. <div style="display: flex">
  69. <span style="font-size: 12px; color: #00000083">注册</span>
  70. </div>
  71. </div>
  72. </div>
  73. <div v-if="userInfo.eduIdentity == 2" class="fcbc">
  74. <div class="headerBtn">
  75. <div style="width: 120px; background-color: brown;" ></div>
  76. <a-menu v-model:selectedKeys="current" mode="horizontal">
  77. <a-menu-item key="portal/resourceCenter">资源中心</a-menu-item>
  78. <a-menu-item key="portal/courseCenter">课程中心</a-menu-item>
  79. <a-menu-item key="portal/resourceManagement">课程详情</a-menu-item>
  80. <a-sub-menu key="myList">
  81. <template #title>我的</template>
  82. <a-menu-item key="portal/personalResources">我的考试</a-menu-item>
  83. <a-menu-item key="portal/courseManagement">我的作业</a-menu-item>
  84. <a-menu-item key="portal/courseManagement">调查问卷</a-menu-item>
  85. </a-sub-menu>
  86. </a-menu>
  87. </div>
  88. <div class="header-right">
  89. <a-dropdown>
  90. <UserOutlined :style="{ fontSize: '16px', color: '#00000083' }" />
  91. <template #overlay>
  92. <a-menu>
  93. <a-menu-item key="portal/courseManagement">个人中心</a-menu-item>
  94. <a-menu-item key="portal/courseManagement">论坛</a-menu-item>
  95. <a-menu-item key="portal/courseManagement">站内信</a-menu-item>
  96. <a-menu-item key="portal/courseManagement">课程公告</a-menu-item>
  97. <a-menu-item key="portal/personalResources">学习足迹</a-menu-item>
  98. <a-menu-item key="portal/courseManagement">登录</a-menu-item>
  99. <a-menu-item key="portal/courseManagement">密码找回</a-menu-item>
  100. <a-menu-item key="outLogin" @click="handleUser('outLogin')">退出登陆</a-menu-item>
  101. </a-menu>
  102. </template>
  103. </a-dropdown>
  104. <div class="ml-2" @click="slogin">登录</div>
  105. <div class="ml-2">注册</div>
  106. </div>
  107. </div>
  108. <div class="line" style=""></div>
  109. </div>
  110. </template>
  111. <script setup>
  112. import { createVNode } from 'vue'
  113. import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
  114. import { Modal } from 'ant-design-vue'
  115. import loginApi from '@/api/auth/loginApi'
  116. import { message } from 'ant-design-vue'
  117. import { ref } from 'vue'
  118. import { useRouter, useRoute } from 'vue-router'
  119. const router = useRouter()
  120. const route = useRoute()
  121. const current = ref([route.path.slice(1)]) // 默认选中“资源中心”
  122. import tool from '@/utils/tool'
  123. const emit = defineEmits(['onChangeCurrent'])
  124. const userInfo = tool.data.get('USER_INFO')
  125. watch(
  126. () => current.value,
  127. (newVal, oldVal) => {
  128. if (newVal != oldVal) {
  129. emit('onChangeCurrent', newVal)
  130. }
  131. }
  132. )
  133. const slogin = () =>{
  134. router.push({
  135. path: '/slogin'
  136. })
  137. }
  138. const handleUser = (key) => {
  139. if (key === 'outLogin') {
  140. Modal.confirm({
  141. title: '提示',
  142. content: '确认退出当前用户?',
  143. icon: createVNode(ExclamationCircleOutlined),
  144. maskClosable: false,
  145. onOk() {
  146. // 取得缓存中的token
  147. const token = tool.data.get('TOKEN')
  148. const param = {
  149. token: token
  150. }
  151. message.loading('退出中...', 1)
  152. loginApi
  153. .logout(param)
  154. .then(() => {
  155. // 清理掉个人的一些信息
  156. tool.data.remove('TOKEN')
  157. tool.data.remove('USER_INFO')
  158. tool.data.remove('MENU')
  159. tool.data.remove('PERMISSIONS')
  160. tool.cookie.remove('Token')
  161. router.replace({ path: '/slogin' })
  162. })
  163. .catch(() => {
  164. tool.data.clear()
  165. router.replace({ path: '/slogin' })
  166. location.reload()
  167. })
  168. },
  169. onCancel() {}
  170. })
  171. }
  172. }
  173. </script>
  174. <style scoped lang="less">
  175. .header {
  176. display: flex;
  177. align-items: center;
  178. justify-content: space-between;
  179. padding: 0 50px;
  180. }
  181. .headerBtn {
  182. display: flex;
  183. padding-left: 10%;
  184. flex:1;
  185. :deep(.ant-menu-horizontal) {
  186. line-height: 55px;
  187. }
  188. }
  189. .header-right {
  190. display: flex;
  191. align-items: center;
  192. margin-right: 20%;
  193. }
  194. .fcbc {
  195. display: flex;
  196. width: 100%;
  197. justify-content: space-between;
  198. align-items: center;
  199. background-color: #fff;
  200. }
  201. .line {
  202. width: 100%;
  203. height: 0.25px;
  204. background-color: #00000013;
  205. }
  206. </style>