fix: 商品详情页未登录时不触发登录跳转
Build and Push Docker Image / build-and-push (push) Successful in 1m0s
Build and Push Docker Image / deploy (push) Successful in 7s

- request.ts: 增加 silent 选项支持静默请求
- request.ts: 公开接口 401 不显示消息也不跳转
- ProductDetail.vue: fetchUserCredits 先检查 token,未登录直接跳过请求
This commit is contained in:
2026-07-13 00:52:08 +00:00
parent 6af4ac907e
commit 7b81d2944a
2 changed files with 23 additions and 8 deletions
+7 -1
View File
@@ -93,10 +93,16 @@ function hasEnoughCredit(): boolean {
// 获取用户资格信息
async function fetchUserCredits() {
// 未登录时静默跳过,不发起请求
const token = localStorage.getItem('token')
if (!token) return
try {
const res: any = await userApi.getProfile()
userCredits.value = res.data?.purchase_credits || 0
} catch {}
} catch {
// 静默处理错误
}
}
onMounted(async () => {