feat: 登录逻辑调整
This commit is contained in:
@@ -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) |
|
||||
|
||||
Reference in New Issue
Block a user