feat: 更新WsProxyManager注册逻辑,添加isLogin参数并优化HTML响应处理

This commit is contained in:
2026-03-05 04:31:45 +08:00
parent bbdf9f087d
commit 2518f6bba3
2 changed files with 13 additions and 9 deletions

View File

@@ -59,9 +59,14 @@ export const UserV1Proxy = async (req: IncomingMessage, res: ServerResponse, opt
if (!client) {
if (isGet) {
if (isAdmin) {
const html = createStudioAppListHtml({ user, appIds: ids, userAppKey, infoList });
// const html = createStudioAppListHtml({ user, appIds: ids, userAppKey, infoList });
// res.writeHead(200, { 'Content-Type': 'text/html' });
// res.end(html);
// https://kevisual.cn/root/v1-manager/
const html = await fetch(`${baseProxyUrl}/root/v1-manager/index.html`).then(res => res.text());
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(html);
res.end(renderServerHtml({ user, appIds: ids, userAppKey, infoList }, html));
return true;
} else {
opts?.createNotFoundPage?.('应用访问失败');
}
@@ -74,9 +79,9 @@ export const UserV1Proxy = async (req: IncomingMessage, res: ServerResponse, opt
const path = searchParams.get('path');
if (!path) {
// 显示前端页面
const html = fetch(`${baseProxyUrl}/root/router-studio/index.html`).then(res => res.text());
const html = await fetch(`${baseProxyUrl}/root/router-studio/index.html`).then(res => res.text());
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(await html);
res.end(html);
return true;
}
let message: any = data;
@@ -106,7 +111,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse, opts?: {
// 获取所有的管理员的应用列表
const { ids, infoList } = wsProxyManager.getIdsInfo(user + '--');
if (isGet) {
const html = createStudioAppListHtml({ user, appIds: ids, userAppKey, infoList });
const html = await fetch(`${baseProxyUrl}/root/v1-manager/index.html`).then(res => res.text());
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(html);
return;
@@ -122,7 +127,6 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse, opts?: {
return;
}
if (path === 'connected') {
client.sendConnected();
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ code: 200, message: '应用已连接' }));