From a00988529d992ad2b31f0a915d9365a127d6ae11 Mon Sep 17 00:00:00 2001
From: "34701892@qq.com" <34701892@qq.com>
Date: Wed, 21 Jan 2026 13:32:50 +0800
Subject: [PATCH] =?UTF-8?q?fix(rank):=20=E4=BF=AE=E5=A4=8D=E6=9C=AA?=
=?UTF-8?q?=E5=AE=9A=E4=B9=89token=E6=97=B6=E7=9A=84=E7=99=BB=E5=BD=95?=
=?UTF-8?q?=E5=BC=B9=E7=AA=97=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
处理当Session中token为"undefined"字符串时的异常情况,移除无效token并显示登录弹窗
---
src/pages/realtimeInfo/pc/rank.vue | 103 ++++++++++++++++++++---------
1 file changed, 70 insertions(+), 33 deletions(-)
diff --git a/src/pages/realtimeInfo/pc/rank.vue b/src/pages/realtimeInfo/pc/rank.vue
index 8d53367..d4f7274 100644
--- a/src/pages/realtimeInfo/pc/rank.vue
+++ b/src/pages/realtimeInfo/pc/rank.vue
@@ -16,11 +16,16 @@
-->
-
+
+
-
+
@@ -93,15 +111,19 @@ const newsList = ref([]);
function formatTime(timestamp) {
const date = new Date(Number(timestamp).toString().length === 10 ? timestamp * 1000 : timestamp);
- return [
- date.getFullYear(),
- (date.getMonth() + 1).toString().padStart(2, '0'),
- date.getDate().toString().padStart(2, '0')
- ].join('-') + ' ' + [
- date.getHours().toString().padStart(2, '0'),
- date.getMinutes().toString().padStart(2, '0'),
- date.getSeconds().toString().padStart(2, '0')
- ].join(':');
+ return (
+ [
+ date.getFullYear(),
+ (date.getMonth() + 1).toString().padStart(2, "0"),
+ date.getDate().toString().padStart(2, "0"),
+ ].join("-") +
+ " " +
+ [
+ date.getHours().toString().padStart(2, "0"),
+ date.getMinutes().toString().padStart(2, "0"),
+ date.getSeconds().toString().padStart(2, "0"),
+ ].join(":")
+ );
}
async function getNewsList() {
@@ -143,6 +165,10 @@ function currentChange(page) {
onMounted(async (e) => {
console.log("🚀 ~ route.query:", route.query);
+ console.log(`🚀 ~ Session.get("token"):`, Session.get("token"));
+ if (Session.get("token") == "undefined") {
+ Session.remove("token");
+ }
if (route.query?.token && (!Session.get("token") || Session.get("token") == "undefined")) {
uni.showLoading({
title: "加载中",
@@ -172,12 +198,11 @@ onMounted(async (e) => {
}
});
} else {
- if (!Session.get("token")) {
+ if (!Session.get("token") || Session.get("token") == "undefined") {
LoginShow.value = true;
}
}
-
// 解构路由参数,排除token
const { token, ...otherQuery } = route.query;
// 若存在token,替换路由清除参数
@@ -269,7 +294,9 @@ const handlePopupErrorCallback = () => {
justify-content: center;
align-items: center;
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: 500;
font-size: 18px;
color: #ffffff;
@@ -292,7 +319,9 @@ const handlePopupErrorCallback = () => {
}
.nol_num {
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: 500;
font-size: 20px;
color: #93a2b3;
@@ -313,7 +342,9 @@ const handlePopupErrorCallback = () => {
}
.item_title {
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: bold;
font-size: 20px;
color: #1a1a1a;
@@ -321,7 +352,9 @@ const handlePopupErrorCallback = () => {
}
.item_summary {
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: normal;
font-size: 16px;
color: #333333;
@@ -353,7 +386,9 @@ const handlePopupErrorCallback = () => {
margin-bottom: 10rpx;
.time {
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: 400;
font-size: 14px;
color: #919191;
@@ -363,7 +398,9 @@ const handlePopupErrorCallback = () => {
}
.score {
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: 600;
font-size: 18px;
color: #ffa800;
@@ -386,8 +423,6 @@ const handlePopupErrorCallback = () => {
border-radius: 8px;
background: #0062d9;
margin-right: 5px;
-
-
}
.input {
@@ -409,7 +444,9 @@ const handlePopupErrorCallback = () => {
background: #007aff;
color: white;
- font-family: PingFangSC, PingFang SC;
+ font-family:
+ PingFangSC,
+ PingFang SC;
font-weight: 400;
font-size: 18px;
color: #ffffff;
@@ -432,7 +469,7 @@ const handlePopupErrorCallback = () => {
:deep(.el-input__inner::placeholder) {
color: #ccced3;
- font-family: 'PingFang SC';
+ font-family: "PingFang SC";
font-size: 16px;
font-style: normal;
font-weight: 400;