AppHeader.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <script setup>
  2. import("../assets/css/header.scss")
  3. import { ref, onMounted } from "vue";
  4. import serverConfig from '../serverConfig'
  5. import Logo from "../assets/img/logo.png"
  6. const userInfo = useUserInfoStore()
  7. const router = useRouter()
  8. // const language: any = useAppConfig().language
  9. // console.log(language)
  10. const activeNum = ref(0)
  11. onMounted(() => {
  12. // console.log("location", user)
  13. let path = location.pathname
  14. getActiveNum(path)
  15. })
  16. const getActiveNum = (path) => {
  17. if (path === '/' || path === '/cocopi' || path === '/download' || path === '/platform') {
  18. activeNum.value = 0
  19. } else if (path === '/eduCourse') {
  20. activeNum.value = 1
  21. } else if (path === '/teacherTrain' || path === '/solutions' || path === '/teacherTrain') {
  22. activeNum.value = 2
  23. } else if (path === '/joinEvent') {
  24. activeNum.value = 3
  25. } else if (path === '/about') {
  26. activeNum.value = 4
  27. } else if (path === '/login' || path === '/persion') {
  28. activeNum.value = 5
  29. } else {
  30. activeNum.value = 6
  31. }
  32. }
  33. const logout = () => {
  34. useFetch(serverConfig.server+"/api/logout", {
  35. method: 'GET',
  36. credentials: 'include',
  37. mode: 'cors'
  38. }).then(res => {
  39. if (res.data.value == 'logout') {
  40. router.push('/')
  41. activeNum.value = 0
  42. userInfo.value = {
  43. username: '',
  44. alias: "User",
  45. userid: "",
  46. isLoading: false,
  47. googleId: "",
  48. login: false
  49. }
  50. }
  51. })
  52. }
  53. </script>
  54. <template>
  55. <header>
  56. <div class="app-header">
  57. <div class="app-header-left">
  58. <nuxt-link to="/"><img class="logo" :src="Logo" alt="Logo" style="margin-top: 30px;" /></nuxt-link>
  59. </div>
  60. <div class="app-header-right">
  61. <ul>
  62. <li :class="activeNum === 0 ? 'active' : ''">
  63. <nuxt-link to="/" class="active-a" @click="activeNum = 0">产品</nuxt-link>
  64. <div class="dropdown" style="width: 80px;left: -10px;">
  65. <div>
  66. <nuxt-link to="/cocopi">产品介绍</nuxt-link>
  67. </div>
  68. <div>
  69. <nuxt-link to="/platform">配套工具</nuxt-link>
  70. </div>
  71. <div>
  72. <nuxt-link to="/download">下载中心</nuxt-link>
  73. </div>
  74. </div>
  75. </li>
  76. <li>
  77. <a href="//edu.cocorobo.cn" class="active-a" target="_blank" @click="activeNum = 6">课程</a>
  78. </li>
  79. <li >
  80. <a href="//cloud.cocorobo.cn" class="active-a" target="_blank" @click="activeNum = 6">可可智慧教育平台</a>
  81. </li>
  82. <li :class="activeNum === 2 ? 'active' : ''">
  83. <nuxt-link to="/solutions" class="active-a" @click="activeNum = 2">服务</nuxt-link>
  84. <div class="dropdown" style="width: 100px;left: -20px;">
  85. <div>
  86. <nuxt-link to="/solutions">整体解决方案</nuxt-link>
  87. </div>
  88. <div>
  89. <nuxt-link to="/teacherTrain">教师培训</nuxt-link>
  90. </div>
  91. </div>
  92. </li>
  93. <li :class="activeNum === 3 ? 'active' : ''">
  94. <nuxt-link to="/joinEvent" class="active-a" @click="activeNum = 3">活动</nuxt-link>
  95. </li>
  96. <li :class="activeNum === 4 ? 'active' : ''">
  97. <nuxt-link to="/about" class="active-a" @click="activeNum = 4">关于我们</nuxt-link>
  98. </li>
  99. <li :class="activeNum === 5 ? 'active' : ''">
  100. <nuxt-link :to="userInfo.username != ''?'/persion':'/login'" class="active-a" @click="activeNum = 5">{{ userInfo.username != "" ? userInfo.alias :
  101. "登录"
  102. }}</nuxt-link>
  103. <div v-if="userInfo.username != ''" class="dropdown" style="min-width: 90px;left: -10px;">
  104. <div>
  105. <nuxt-link to="/persion">编辑资料</nuxt-link>
  106. </div>
  107. <div>
  108. <span @click="logout()">注销</span>
  109. </div>
  110. </div>
  111. </li>
  112. </ul>
  113. </div>
  114. </div>
  115. </header>
  116. </template>
  117. <style lang="scss">
  118. .app-header {
  119. .app-header-right {
  120. ul {
  121. .active {
  122. .active-a {
  123. border-bottom: 2px solid #3681FC;
  124. }
  125. }
  126. li {
  127. position: relative;
  128. // width: 80px;
  129. padding: 0 18px;
  130. text-align: center;
  131. a {
  132. text-decoration: none;
  133. padding: 8px 0;
  134. color: #000000;
  135. }
  136. .dropdown {
  137. display: none;
  138. line-height: initial;
  139. width: 100%;
  140. position: absolute;
  141. top: 60px;
  142. background-color: #fff;
  143. z-index: 1;
  144. border-radius: 6px;
  145. border: 1px solid #E7E7E7;
  146. animation: frame 0.3s linear;
  147. animation-name: slidein;
  148. }
  149. }
  150. li:hover {
  151. .active-a:hover{
  152. color: #555;
  153. }
  154. .dropdown {
  155. display: block;
  156. padding: 8px;
  157. a {
  158. display: inline-block;
  159. font-size: 12px;
  160. padding: 5px;
  161. }
  162. span {
  163. display: inline-block;
  164. font-size: 12px;
  165. padding: 5px;
  166. cursor: pointer;
  167. }
  168. span:hover {
  169. background-color: #F3F7FD;
  170. }
  171. .active-a {
  172. color: #555 !important;
  173. }
  174. a:hover {
  175. background-color: #F3F7FD;
  176. color: #555;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. @keyframes slidein {
  184. from {
  185. top: 100%;
  186. }
  187. to {
  188. top: 60px;
  189. }
  190. }
  191. </style>