feat: 登录逻辑调整

This commit is contained in:
duanshuwen
2025-12-27 22:49:14 +08:00
parent ea56695099
commit 56ad450731
10 changed files with 93 additions and 75 deletions

View File

@@ -1,7 +1,7 @@
import { goLogin } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store";
import { getStorageSyncToken } from "@/constant/token";
import { removeStorageSyncToken } from "@/constant/token";
import { getAccessToken } from "@/constant/token";
import { removeAccessToken } from "@/constant/token";
/// 请求流式数据的API
const API = "/agent/assistant/chat";
@@ -74,7 +74,7 @@ const stopAbortTask = () => {
const agentChatStream = (params, onChunk) => {
return new Promise((resolve, reject) => {
const token = getStorageSyncToken();
const token = getAccessToken();
const requestId = Date.now().toString(); // 生成唯一请求ID
// 重置状态
@@ -132,7 +132,7 @@ const agentChatStream = (params, onChunk) => {
res.statusCode
);
if (res.statusCode === 424) {
removeStorageSyncToken();
removeAccessToken();
goLogin();
}
if (onChunk) {
@@ -146,7 +146,8 @@ const agentChatStream = (params, onChunk) => {
}
} else {
console.log(
`❌ 请求 [${requestId}] ${isAborted ? "已终止" : "已过期"
`❌ 请求 [${requestId}] ${
isAborted ? "已终止" : "已过期"
}忽略complete回调`
);
}
@@ -241,7 +242,7 @@ const weAtob = (string) => {
r2,
i = 0;
for (; i < string.length;) {
for (; i < string.length; ) {
bitmap =
(b64.indexOf(string.charAt(i++)) << 18) |
(b64.indexOf(string.charAt(i++)) << 12) |