|
@@ -26,7 +26,7 @@
|
|
|
</button>
|
|
|
<button class="reg" @click="userCenter" v-show="showToken">
|
|
|
<img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon3.png" alt="用户信息">{{
|
|
|
- username }}
|
|
|
+ username }}
|
|
|
</button>
|
|
|
<button class="reg" @click="goSearch">
|
|
|
<img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/searchicon.png" alt="搜索">搜索
|
|
@@ -68,7 +68,7 @@
|
|
|
<script setup>
|
|
|
//1.加载基本依赖 start ---------------------------------------->
|
|
|
import { ref, watch, onMounted } from 'vue'
|
|
|
-import { ElDialog,ElMessage} from 'element-plus'
|
|
|
+import { ElDialog, ElMessage } from 'element-plus'
|
|
|
import { getToken, setToken, removeToken } from '@/store/useCookieStore'
|
|
|
import { setTicket, removeTicket } from '@/store/useticketStore'
|
|
|
//网站地址
|
|
@@ -155,17 +155,17 @@ let userCenter = () => {
|
|
|
|
|
|
// 添加点击事件处理函数
|
|
|
const handleClickOutside = (event) => {
|
|
|
- // 获取用户信息菜单元素
|
|
|
- const userInfoMenu = document.querySelector('.userInfo11');
|
|
|
- // 获取用户按钮元素
|
|
|
- const userButton = document.querySelector('.reg img[alt="用户信息"]')?.parentElement;
|
|
|
-
|
|
|
- // 如果点击的不是菜单本身且不是用户按钮,则隐藏菜单
|
|
|
- if (userInfoMenu &&
|
|
|
- !userInfoMenu.contains(event.target) &&
|
|
|
- !userButton?.contains(event.target)) {
|
|
|
- isShow.value = false;
|
|
|
- }
|
|
|
+ // 获取用户信息菜单元素
|
|
|
+ const userInfoMenu = document.querySelector('.userInfo11');
|
|
|
+ // 获取用户按钮元素
|
|
|
+ const userButton = document.querySelector('.reg img[alt="用户信息"]')?.parentElement;
|
|
|
+
|
|
|
+ // 如果点击的不是菜单本身且不是用户按钮,则隐藏菜单
|
|
|
+ if (userInfoMenu &&
|
|
|
+ !userInfoMenu.contains(event.target) &&
|
|
|
+ !userButton?.contains(event.target)) {
|
|
|
+ isShow.value = false;
|
|
|
+ }
|
|
|
}
|
|
|
//2.登录逻辑 end ---------------------------------------->
|
|
|
|
|
@@ -185,7 +185,7 @@ let exit = () => {
|
|
|
token1.value = getToken()
|
|
|
isShow.value = false;
|
|
|
let tokendata = getToken()
|
|
|
-
|
|
|
+
|
|
|
//王鹏
|
|
|
// let url = $BwebUrl + '/auth/logout.php?backurl=' + $CwebUrl + '&admintoken=' + tokendata;
|
|
|
// console.log("用户退出登录======token为:", tokendata,url)
|
|
@@ -246,8 +246,12 @@ let getLogo = async () => {
|
|
|
method: 'GET',
|
|
|
query: {},
|
|
|
});
|
|
|
- logo.value = responseStatus.data.logo;
|
|
|
- webSiteName.value = responseStatus.data.website_name;
|
|
|
+ if (responseStatus.code == 200) {
|
|
|
+ logo.value = responseStatus.data.logo;
|
|
|
+ webSiteName.value = responseStatus.data.website_name;
|
|
|
+ } else if (responseStatus.code == 0) {
|
|
|
+ window.location.href = $CwebUrl + '/404';
|
|
|
+ }
|
|
|
}
|
|
|
getLogo();
|
|
|
//3.跳转菜单逻辑 end ---------------------------------------->
|
|
@@ -259,7 +263,7 @@ let adImg = ref({})
|
|
|
//5.获取登录状态 start ---------------------------------------->
|
|
|
// 在组件卸载时移除事件监听
|
|
|
onUnmounted(() => {
|
|
|
- document.removeEventListener('click', handleClickOutside);
|
|
|
+ document.removeEventListener('click', handleClickOutside);
|
|
|
})
|
|
|
|
|
|
onMounted(async () => {
|
|
@@ -273,12 +277,12 @@ onMounted(async () => {
|
|
|
const token = getToken();
|
|
|
const { $webUrl, $CwebUrl } = useNuxtApp();
|
|
|
|
|
|
- if(token == undefined){
|
|
|
+ if (token == undefined) {
|
|
|
//如果没有获取到token 不访问后端获取在线状态
|
|
|
console.log("没有获取到token!无需查询登录状态!")
|
|
|
showToken.value = false;
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//如果获取到了token 访问后端查询状态
|
|
|
console.log("已获取到用户token,开始查询登录状态!")
|
|
|
const queryParams = new URLSearchParams({
|
|
@@ -296,7 +300,7 @@ onMounted(async () => {
|
|
|
});
|
|
|
const result = await responseStatus.json();
|
|
|
console.log(result)
|
|
|
-
|
|
|
+
|
|
|
if (result.code == 200) {
|
|
|
console.log("用户已经登录!");
|
|
|
showToken.value = true;
|
|
@@ -423,7 +427,8 @@ header {
|
|
|
|
|
|
.headerNav .left>span {
|
|
|
margin-right: 20px;
|
|
|
- a{
|
|
|
+
|
|
|
+ a {
|
|
|
color: #666666;
|
|
|
}
|
|
|
}
|