feat: 区别不同的小程序的缓存问题
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
import { useAppStore } from "@/store";
|
||||
import { getStorageSyncToken } from "@/constant/token";
|
||||
import { removeStorageSyncToken } from "@/constant/token";
|
||||
|
||||
/// 请求流式数据的API
|
||||
const API = "/agent/assistant/chat";
|
||||
@@ -72,7 +74,7 @@ const stopAbortTask = () => {
|
||||
|
||||
const agentChatStream = (params, onChunk) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = uni.getStorageSync("token");
|
||||
const token = getStorageSyncToken();
|
||||
const requestId = Date.now().toString(); // 生成唯一请求ID
|
||||
|
||||
// 重置状态
|
||||
@@ -130,7 +132,7 @@ const agentChatStream = (params, onChunk) => {
|
||||
res.statusCode
|
||||
);
|
||||
if (res.statusCode === 424) {
|
||||
uni.setStorageSync("token", "");
|
||||
removeStorageSyncToken();
|
||||
goLogin();
|
||||
}
|
||||
if (onChunk) {
|
||||
@@ -144,8 +146,7 @@ const agentChatStream = (params, onChunk) => {
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
`❌ 请求 [${requestId}] ${
|
||||
isAborted ? "已终止" : "已过期"
|
||||
`❌ 请求 [${requestId}] ${isAborted ? "已终止" : "已过期"
|
||||
},忽略complete回调`
|
||||
);
|
||||
}
|
||||
@@ -240,7 +241,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