西藏巴青项目

ScreenNavBar.vue 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <header class="screen-nav">
  3. <div class="screen-nav-left">
  4. <div
  5. class="screen-nav-left-item"
  6. v-for="item in leftNav"
  7. :key="item.name"
  8. @click="goNav(item)"
  9. :class="{ active: isActive(item) }"
  10. >
  11. <div class="screen-nav-item-zh">
  12. {{ item.zh }}
  13. </div>
  14. <div class="screen-nav-item-bo">{{ item.bo }}</div>
  15. </div>
  16. </div>
  17. <div class="screen-nav-right">
  18. <div
  19. class="screen-nav-right-item"
  20. v-for="item in rightNav"
  21. :key="item.name"
  22. @click="goNav(item)"
  23. :class="{ active: isActive(item) }"
  24. >
  25. <div class="screen-nav-item-zh">
  26. {{ item.zh }}
  27. </div>
  28. <div class="screen-nav-item-bo">
  29. {{ item.bo }}
  30. </div>
  31. </div>
  32. </div>
  33. <div class="logout" @click.stop="onLogout">
  34. <div class="screen-nav-item-zh">
  35. {{ logoutNav.zh }}
  36. </div>
  37. <div class="screen-nav-item-bo">
  38. {{ logoutNav.bo }}
  39. </div>
  40. </div>
  41. </header>
  42. </template>
  43. <script setup>
  44. import { computed } from "vue";
  45. import { useRoute, useRouter } from "vue-router";
  46. import { logout } from "@/api/login";
  47. import { removeToken } from "@/utils/auth";
  48. import { resetScreenAutoLoginState } from "@/utils/screenAutoLogin";
  49. const router = useRouter();
  50. const route = useRoute();
  51. const leftNav = [
  52. { name: "ScreenHome", path: "/home", zh: "首页", bo: "གཙོ་ངོས།" },
  53. {
  54. name: "LivestockResources",
  55. path: "/livestock-resources",
  56. zh: "畜牧资源",
  57. bo: "སྐྱེས་ཁམས་ཐོན་ཁུངས།",
  58. },
  59. {
  60. name: "EpidemicRisk",
  61. path: "/epidemic-risk",
  62. zh: "疫病风险",
  63. bo: "ནད་རིམས་ཉེན་ཁ།",
  64. },
  65. ];
  66. const rightNav = [
  67. {
  68. name: "TradeSales",
  69. path: "/trade-sales",
  70. zh: "交易销售",
  71. bo: "འབྲེལ་གཏོང་ཚོང་འབུལ།",
  72. },
  73. {
  74. name: "CommonProsperity",
  75. path: "/common-prosperity",
  76. zh: "共同富裕",
  77. bo: "སྤྱི་འགྲོས་ཕྱུག་པོ།",
  78. },
  79. ];
  80. const logoutNav = {
  81. name: "Logout",
  82. path: "/logout",
  83. zh: "退出登录",
  84. bo: "ཕྱིར་ལོག་འཛུལ་བ།",
  85. };
  86. const activeName = computed(() => route.name);
  87. function isActive(item) {
  88. return item.name && activeName.value === item.name;
  89. }
  90. function goNav(item) {
  91. if (item.path) router.push(item.path);
  92. }
  93. function onLogout() {
  94. logout().catch(() => {});
  95. removeToken();
  96. resetScreenAutoLoginState();
  97. router.replace({ path: "/login" });
  98. }
  99. </script>
  100. <style scoped>
  101. .screen-nav {
  102. width: 100%;
  103. height: 100px;
  104. position: relative;
  105. font-family: inherit;
  106. pointer-events: none;
  107. background: url("../assets/header.png") no-repeat center center;
  108. }
  109. .screen-nav-left {
  110. position: absolute;
  111. left: 60px;
  112. top: 30px;
  113. display: flex;
  114. }
  115. .screen-nav-left-item {
  116. width: 179px;
  117. height: 63px;
  118. background: url("../assets/nav/btn.png") no-repeat center center;
  119. background-size: 100% 100%;
  120. text-align: center;
  121. box-sizing: border-box;
  122. padding: 5px 10px;
  123. cursor: pointer;
  124. margin-right: 10px;
  125. pointer-events: auto;
  126. }
  127. .screen-nav-left-item:hover {
  128. background: url("../assets/nav/btn_active.png") no-repeat center center;
  129. background-size: 100% 100%;
  130. }
  131. .screen-nav-left-item.active {
  132. background: url("../assets/nav/btn_active.png") no-repeat center center;
  133. background-size: 100% 100%;
  134. }
  135. .screen-nav-right {
  136. position: absolute;
  137. right: 240px;
  138. top: 30px;
  139. display: flex;
  140. }
  141. .screen-nav-right-item {
  142. width: 179px;
  143. height: 63px;
  144. background: url("../assets/nav/btn.png") no-repeat center center;
  145. background-size: 100% 100%;
  146. text-align: center;
  147. box-sizing: border-box;
  148. padding: 5px 10px;
  149. cursor: pointer;
  150. margin-right: 10px;
  151. pointer-events: auto;
  152. }
  153. .screen-nav-right-item:hover {
  154. background: url("../assets/nav/btn_active.png") no-repeat center center;
  155. background-size: 100% 100%;
  156. }
  157. .screen-nav-right-item.active {
  158. background: url("../assets/nav/btn_active.png") no-repeat center center;
  159. background-size: 100% 100%;
  160. }
  161. .logout {
  162. width: 179px;
  163. height: 63px;
  164. text-align: center;
  165. box-sizing: border-box;
  166. padding: 5px 10px;
  167. cursor: pointer;
  168. position: absolute;
  169. right: 70px;
  170. top: 30px;
  171. pointer-events: auto;
  172. }
  173. .screen-nav-item-zh {
  174. font-size: 18px;
  175. color: #fff;
  176. }
  177. .screen-nav-item-bo {
  178. font-size: 14px;
  179. color: #fff;
  180. }
  181. .logout:hover .screen-nav-item-zh {
  182. color: #16A769;
  183. }
  184. .logout:hover .screen-nav-item-bo {
  185. color: #16A769;
  186. }
  187. </style>