fix: 修复WorkflowPageV3组件TypeScript错误和清理副本文件
详细说明: - 修复WorkflowPageV3.tsx中的TypeScript类型错误 - 移除未使用的executionTimeoutRef变量 - 修复style标签的jsx属性问题 - 将deprecated的substr()改为substring() - 清理n8n目录下的副本文件 - 添加server.js和start脚本用于静态文件服务 影响的文件: - web_frontend/exhibition-demo/src/pages/WorkflowPageV3.tsx - web_frontend/exhibition-demo/src/components/ResultModal.tsx - web_frontend/web_result/server.js (新增) - web_frontend/web_result/start.bat (新增) - web_frontend/web_result/start.sh (新增) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
99
web_frontend/web_result/server.js
Normal file
99
web_frontend/web_result/server.js
Normal file
@@ -0,0 +1,99 @@
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
const PORT = 4155;
|
||||
const HOST = '0.0.0.0';
|
||||
|
||||
// MIME 类型映射
|
||||
const mimeTypes = {
|
||||
'.html': 'text/html; charset=utf-8',
|
||||
'.css': 'text/css',
|
||||
'.js': 'text/javascript',
|
||||
'.json': 'application/json',
|
||||
'.png': 'image/png',
|
||||
'.jpg': 'image/jpeg',
|
||||
'.jpeg': 'image/jpeg',
|
||||
'.gif': 'image/gif',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.ico': 'image/x-icon',
|
||||
'.woff': 'font/woff',
|
||||
'.woff2': 'font/woff2',
|
||||
'.ttf': 'font/ttf',
|
||||
'.eot': 'font/eot'
|
||||
};
|
||||
|
||||
// 创建服务器
|
||||
const server = http.createServer((req, res) => {
|
||||
// 解析 URL
|
||||
const parsedUrl = url.parse(req.url);
|
||||
let pathname = decodeURIComponent(parsedUrl.pathname);
|
||||
|
||||
// 默认文件
|
||||
if (pathname === '/') {
|
||||
pathname = '/index.html';
|
||||
}
|
||||
|
||||
// 构建文件路径
|
||||
const filePath = path.join(__dirname, pathname);
|
||||
|
||||
// 安全检查:确保文件路径在当前目录内
|
||||
if (!filePath.startsWith(__dirname)) {
|
||||
res.writeHead(403);
|
||||
res.end('Forbidden');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查文件是否存在
|
||||
fs.stat(filePath, (err, stats) => {
|
||||
if (err) {
|
||||
// 文件不存在
|
||||
res.writeHead(404);
|
||||
res.end('Not Found');
|
||||
return;
|
||||
}
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
// 如果是目录,尝试加载 index.html
|
||||
const indexPath = path.join(filePath, 'index.html');
|
||||
fs.stat(indexPath, (err, stats) => {
|
||||
if (err) {
|
||||
res.writeHead(404);
|
||||
res.end('Not Found');
|
||||
return;
|
||||
}
|
||||
serveFile(indexPath, res);
|
||||
});
|
||||
} else {
|
||||
// 提供文件
|
||||
serveFile(filePath, res);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 提供文件的函数
|
||||
function serveFile(filePath, res) {
|
||||
const ext = path.extname(filePath);
|
||||
const contentType = mimeTypes[ext] || 'application/octet-stream';
|
||||
|
||||
fs.readFile(filePath, (err, content) => {
|
||||
if (err) {
|
||||
res.writeHead(500);
|
||||
res.end('Internal Server Error');
|
||||
return;
|
||||
}
|
||||
|
||||
res.writeHead(200, { 'Content-Type': contentType });
|
||||
res.end(content);
|
||||
});
|
||||
}
|
||||
|
||||
// 启动服务器
|
||||
server.listen(PORT, HOST, () => {
|
||||
console.log('======================================');
|
||||
console.log(' Web Result 静态服务器');
|
||||
console.log(` 运行地址: http://localhost:${PORT}`);
|
||||
console.log(' 按 Ctrl+C 停止服务器');
|
||||
console.log('======================================');
|
||||
});
|
||||
67
web_frontend/web_result/start.bat
Normal file
67
web_frontend/web_result/start.bat
Normal file
@@ -0,0 +1,67 @@
|
||||
@echo off
|
||||
chcp 65001 >nul 2>&1
|
||||
REM Web Result 静态服务器启动脚本 (Node.js版)
|
||||
REM 端口: 4155
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM 显示启动横幅
|
||||
echo ======================================
|
||||
echo Web Result 静态服务器
|
||||
echo 端口: 4155
|
||||
echo ======================================
|
||||
echo.
|
||||
|
||||
REM 获取脚本所在目录
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%"
|
||||
|
||||
REM 切换到脚本所在目录
|
||||
cd /d "%SCRIPT_DIR%"
|
||||
|
||||
REM 检查 Node.js
|
||||
where node >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [错误] Node.js 未安装
|
||||
echo 请先安装 Node.js: https://nodejs.org
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [信息] Node.js 版本:
|
||||
node --version
|
||||
echo.
|
||||
|
||||
REM 检查端口 4155 是否被占用
|
||||
netstat -ano | findstr :4155 >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
echo [警告] 端口 4155 已被占用
|
||||
echo [信息] 正在查看占用进程...
|
||||
netstat -ano | findstr :4155
|
||||
echo.
|
||||
|
||||
set /p "kill_process=是否终止占用进程?(y/N): "
|
||||
if /I "!kill_process!"=="y" (
|
||||
echo [信息] 正在终止占用进程...
|
||||
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :4155') do (
|
||||
taskkill /PID %%a /F >nul 2>&1
|
||||
)
|
||||
echo [成功] 进程已终止
|
||||
timeout /t 1 /nobreak >nul
|
||||
) else (
|
||||
echo [错误] 无法启动服务器,端口被占用
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM 启动服务器
|
||||
echo [信息] 正在启动服务器...
|
||||
echo [信息] 访问地址: http://localhost:4155
|
||||
echo [提示] 按 Ctrl+C 停止服务器
|
||||
echo.
|
||||
|
||||
REM 使用 Node.js 启动服务器
|
||||
node server.js
|
||||
|
||||
pause
|
||||
59
web_frontend/web_result/start.sh
Executable file
59
web_frontend/web_result/start.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Web Result 静态服务器启动脚本 (Node.js版)
|
||||
# 端口: 4155
|
||||
|
||||
# 颜色定义
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
# 获取脚本所在目录
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
echo -e "${BLUE}======================================${NC}"
|
||||
echo -e "${BLUE} Web Result 静态服务器${NC}"
|
||||
echo -e "${BLUE} 端口: 4155${NC}"
|
||||
echo -e "${BLUE}======================================${NC}"
|
||||
echo
|
||||
|
||||
# 切换到脚本所在目录
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# 检查 Node.js
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo -e "${RED}[错误] Node.js 未安装${NC}"
|
||||
echo -e "${YELLOW}请先安装 Node.js: https://nodejs.org${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}[信息] Node.js 版本: $(node --version)${NC}"
|
||||
|
||||
# 检查端口是否被占用
|
||||
if lsof -Pi :4155 -sTCP:LISTEN -t >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}[警告] 端口 4155 已被占用${NC}"
|
||||
echo -e "${BLUE}[信息] 正在查看占用进程...${NC}"
|
||||
lsof -i :4155
|
||||
|
||||
read -p "是否终止占用进程?(y/N): " kill_process
|
||||
if [[ $kill_process =~ ^[Yy]$ ]]; then
|
||||
echo -e "${BLUE}[信息] 正在终止占用进程...${NC}"
|
||||
lsof -ti:4155 | xargs kill -9
|
||||
echo -e "${GREEN}[成功] 进程已终止${NC}"
|
||||
sleep 1
|
||||
else
|
||||
echo -e "${RED}[错误] 无法启动服务器,端口被占用${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 启动服务器
|
||||
echo -e "${GREEN}[信息] 正在启动服务器...${NC}"
|
||||
echo -e "${GREEN}[信息] 访问地址: http://localhost:4155${NC}"
|
||||
echo -e "${YELLOW}[提示] 按 Ctrl+C 停止服务器${NC}"
|
||||
echo
|
||||
|
||||
# 使用 Node.js 启动服务器
|
||||
node server.js
|
||||
Reference in New Issue
Block a user