This commit is contained in:
2026-01-30 10:40:25 +08:00
parent 25aa9e9cbe
commit 099880ab72
2 changed files with 5 additions and 8 deletions

11
App.tsx
View File

@@ -120,7 +120,6 @@ class Api {
// 处理消息
ws.onmessage = (event) => {
try {
console.log('[WebSocket] 收到消息:', event.data);
const msg = JSON.parse(event.data);
// 处理响应消息
@@ -159,7 +158,6 @@ class Api {
},
// onError: TCP错误 → 通知服务器
(error: string) => {
console.error('[代理] TCP错误:', error);
ws.send(JSON.stringify({
type: 'proxyClose',
messageId: msg.messageId
@@ -167,15 +165,16 @@ class Api {
}
).then(success => {
if (success) {
// 回复就绪
ws.send(JSON.stringify({
type: 'proxyReady',
messageId: msg.messageId
}));
console.log('[代理] TCP连接已建立');
}
}).catch(err => {
console.error('[代理] 创建失败:', err);
ws.send(JSON.stringify({
type: 'proxyClose',
messageId: msg.messageId
}));
});
}
@@ -184,14 +183,12 @@ class Api {
if (TcpProxy && typeof TcpProxy.writeProxy === 'function') {
TcpProxy.writeProxy(msg.messageId, msg.data.data).then(success => {
if (!success) {
// 写入失败,通知服务器关闭
ws.send(JSON.stringify({
type: 'proxyClose',
messageId: msg.messageId
}));
}
}).catch(err => {
console.error('[代理] 写入失败:', err);
ws.send(JSON.stringify({
type: 'proxyClose',
messageId: msg.messageId