| | |
| | | <el-menu-item index="/certified-products" class="!px-4">能效产品</el-menu-item> |
| | | <el-menu-item index="/eec-label-search" class="!px-4">证书查询</el-menu-item> |
| | | <el-menu-item index="/news-detail/99" class="!px-4">补贴政策</el-menu-item> |
| | | <el-menu-item class="!px-4" @click="linkClick(' http://www.xpump.net/web/#/CN/Index')">查泵网</el-menu-item> |
| | | <el-menu-item index="/select-selpara" class="!px-4" @click="linkClick">查泵网</el-menu-item> |
| | | </el-menu> |
| | | </nav> |
| | | |
| | |
| | | <template v-if="!userInfo"> |
| | | <a href="#" class="hover:text-blue-500">注册</a> |
| | | <span class="mx-2">·</span> |
| | | <router-link to="/login" class="hover:text-blue-500">登录</router-link> |
| | | <a @click="toLogin" class="hover:text-blue-500">登录</a> |
| | | </template> |
| | | <template v-else> |
| | | <span class="text-blue-500 mr-2">{{ userInfo.username }}</span> |
| | | <span class="text-blue-500 mr-2">{{ userInfo.RealName }}</span> |
| | | <a href="#" class="hover:text-blue-500" @click.prevent="handleLogout">退出</a> |
| | | </template> |
| | | </div> |
| | |
| | | import { ElMessage } from 'element-plus'; |
| | | import { computed, ref } from 'vue'; |
| | | import { useRoute, useRouter } from 'vue-router'; |
| | | import { useLogin } from '@/stores/useLogin'; |
| | | |
| | | const loginStore = useLogin(); |
| | | |
| | | const route = useRoute(); |
| | | const router = useRouter(); |
| | |
| | | |
| | | // 获取用户信息 |
| | | const userInfo = computed(() => { |
| | | const info = localStorage.getItem('userInfo'); |
| | | return info ? JSON.parse(info) : null; |
| | | const UserInfo = loginStore.getUserInfo(); |
| | | return UserInfo ? UserInfo : null; |
| | | }); |
| | | |
| | | const toLogin = () => { |
| | | router.replace({ |
| | | path: '/login', |
| | | query: { |
| | | redirectPath: route.fullPath, |
| | | }, |
| | | }); |
| | | }; |
| | | // 处理登出 |
| | | const handleLogout = () => { |
| | | localStorage.removeItem('userInfo'); |
| | | loginStore.logOut(); |
| | | ElMessage.success('已退出登录'); |
| | | router.push('/login'); |
| | | router.replace({ |
| | | path: '/login', |
| | | query: { redirectPath: route.fullPath }, |
| | | }); |
| | | }; |
| | | |
| | | const linkClick = (url) => { |
| | | window.open(url, '_blank'); |
| | | const linkClick = () => { |
| | | router.push('/select-selpara'); |
| | | }; |
| | | </script> |
| | | |