| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <template>
- <header class="screen-nav">
- <div class="screen-nav-left">
- <div
- class="screen-nav-left-item"
- v-for="item in leftNav"
- :key="item.name"
- @click="goNav(item)"
- :class="{ active: isActive(item) }"
- >
- <div class="screen-nav-item-zh">
- {{ item.zh }}
- </div>
- <div class="screen-nav-item-bo">{{ item.bo }}</div>
- </div>
- </div>
- <div class="screen-nav-right">
- <div
- class="screen-nav-right-item"
- v-for="item in rightNav"
- :key="item.name"
- @click="goNav(item)"
- :class="{ active: isActive(item) }"
- >
- <div class="screen-nav-item-zh">
- {{ item.zh }}
- </div>
- <div class="screen-nav-item-bo">
- {{ item.bo }}
- </div>
- </div>
- </div>
- <div class="logout" @click.stop="onLogout">
- <div class="screen-nav-item-zh">
- {{ logoutNav.zh }}
- </div>
- <div class="screen-nav-item-bo">
- {{ logoutNav.bo }}
- </div>
- </div>
- </header>
- </template>
- <script setup>
- import { computed } from "vue";
- import { useRoute, useRouter } from "vue-router";
- import { logout } from "@/api/login";
- import { removeToken } from "@/utils/auth";
- import { resetScreenAutoLoginState } from "@/utils/screenAutoLogin";
- const router = useRouter();
- const route = useRoute();
- const leftNav = [
- { name: "ScreenHome", path: "/home", zh: "首页", bo: "གཙོ་ངོས།" },
- {
- name: "LivestockResources",
- path: "/livestock-resources",
- zh: "畜牧资源",
- bo: "སྐྱེས་ཁམས་ཐོན་ཁུངས།",
- },
- {
- name: "EpidemicRisk",
- path: "/epidemic-risk",
- zh: "疫病风险",
- bo: "ནད་རིམས་ཉེན་ཁ།",
- },
- ];
- const rightNav = [
- {
- name: "TradeSales",
- path: "/trade-sales",
- zh: "交易销售",
- bo: "འབྲེལ་གཏོང་ཚོང་འབུལ།",
- },
- {
- name: "CommonProsperity",
- path: "/common-prosperity",
- zh: "共同富裕",
- bo: "སྤྱི་འགྲོས་ཕྱུག་པོ།",
- },
- ];
- const logoutNav = {
- name: "Logout",
- path: "/logout",
- zh: "退出登录",
- bo: "ཕྱིར་ལོག་འཛུལ་བ།",
- };
- const activeName = computed(() => route.name);
- function isActive(item) {
- return item.name && activeName.value === item.name;
- }
- function goNav(item) {
- if (item.path) router.push(item.path);
- }
- function onLogout() {
- logout().catch(() => {});
- removeToken();
- resetScreenAutoLoginState();
- router.replace({ path: "/login" });
- }
- </script>
- <style scoped>
- .screen-nav {
- width: 100%;
- height: 100px;
- position: relative;
- font-family: inherit;
- pointer-events: none;
- background: url("../assets/header.png") no-repeat center center;
- }
- .screen-nav-left {
- position: absolute;
- left: 60px;
- top: 30px;
- display: flex;
- }
- .screen-nav-left-item {
- width: 179px;
- height: 63px;
- background: url("../assets/nav/btn.png") no-repeat center center;
- background-size: 100% 100%;
- text-align: center;
- box-sizing: border-box;
- padding: 5px 10px;
- cursor: pointer;
- margin-right: 10px;
- pointer-events: auto;
- }
- .screen-nav-left-item:hover {
- background: url("../assets/nav/btn_active.png") no-repeat center center;
- background-size: 100% 100%;
- }
- .screen-nav-left-item.active {
- background: url("../assets/nav/btn_active.png") no-repeat center center;
- background-size: 100% 100%;
- }
- .screen-nav-right {
- position: absolute;
- right: 240px;
- top: 30px;
- display: flex;
- }
- .screen-nav-right-item {
- width: 179px;
- height: 63px;
- background: url("../assets/nav/btn.png") no-repeat center center;
- background-size: 100% 100%;
- text-align: center;
- box-sizing: border-box;
- padding: 5px 10px;
- cursor: pointer;
- margin-right: 10px;
- pointer-events: auto;
- }
- .screen-nav-right-item:hover {
- background: url("../assets/nav/btn_active.png") no-repeat center center;
- background-size: 100% 100%;
- }
- .screen-nav-right-item.active {
- background: url("../assets/nav/btn_active.png") no-repeat center center;
- background-size: 100% 100%;
- }
- .logout {
- width: 179px;
- height: 63px;
- text-align: center;
- box-sizing: border-box;
- padding: 5px 10px;
- cursor: pointer;
- position: absolute;
- right: 70px;
- top: 30px;
- pointer-events: auto;
- }
- .screen-nav-item-zh {
- font-size: 18px;
- color: #fff;
- }
- .screen-nav-item-bo {
- font-size: 14px;
- color: #fff;
- }
- .logout:hover .screen-nav-item-zh {
- color: #16A769;
- }
- .logout:hover .screen-nav-item-bo {
- color: #16A769;
- }
- </style>
|