This commit is contained in:
lik
2026-06-04 10:00:59 +08:00
parent 2b28b46aed
commit 1fce05cbfb
2 changed files with 38 additions and 34 deletions

View File

@@ -81,7 +81,7 @@ export default class WebSocketServerManager {
}
if (msg.type === 'chat' || msg.type === 'clear') {
if (msg.agent === 'escort-admin') {
if (msg.agent === 'escort-admin') {
const userInfo = await this.getUserInfo(msg.token, msg.userId);
adminAgent.streamChat(userInfo, [msg], (source, type, content, id) => {
ws.send(JSON.stringify({ source, type, content, id }));
@@ -134,18 +134,23 @@ export default class WebSocketServerManager {
}
async getUserInfo(token, userId) {
if (!token && !userId) return null;
try {
if (!token && !userId) return null;
const url = "http://127.0.0.1:9010/user/userInfo";
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
token,
userId
})
});
const data = await res.json();
return data.data.user;
const url = "http://127.0.0.1:9010/user/userInfo";
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
token,
userId
})
});
const data = await res.json();
return data.data.user;
} catch (error) {
console.error('Error fetching user info:', error);
return null;
}
}
}