feat: 更新@kevisual/api依赖版本至0.0.62,优化WsProxyManager和请求处理逻辑
This commit is contained in:
@@ -123,7 +123,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse, opts?: {
|
||||
const client = wsProxyManager.get(appId!)!;
|
||||
if (!client) {
|
||||
res.writeHead(404, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ message: '应用未找到' }));
|
||||
res.end(JSON.stringify({ code: 404, message: '应用未找到' }));
|
||||
return;
|
||||
}
|
||||
if (path === 'connected') {
|
||||
@@ -132,6 +132,24 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse, opts?: {
|
||||
res.end(JSON.stringify({ code: 200, message: '应用已连接' }));
|
||||
return;
|
||||
}
|
||||
if (path === 'rename') {
|
||||
const newId = url.searchParams.get('newId') || '';
|
||||
if (!newId) {
|
||||
res.writeHead(400, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ code: 400, message: 'newId 参数缺失' }));
|
||||
return;
|
||||
}
|
||||
const wsMessage = wsProxyManager.get(newId!)!;
|
||||
if (wsMessage) {
|
||||
res.writeHead(400, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ code: 400, message: 'newId 已存在' }));
|
||||
return;
|
||||
}
|
||||
wsProxyManager.changeId(appId, newId);
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ code: 200, message: '应用重命名成功' }));
|
||||
return;
|
||||
}
|
||||
}
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ code: 200, data: { ids, infoList } }));
|
||||
|
||||
Reference in New Issue
Block a user