From b018653dc23a0aee7bf04274e9666a3c8cd8b9b3 Mon Sep 17 00:00:00 2001 From: qinjian Date: Wed, 20 Aug 2025 11:08:27 +0800 Subject: [PATCH] =?UTF-8?q?config:=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E6=B5=81=E5=9C=B0=E5=9D=80=E5=92=8C?= =?UTF-8?q?TCP=E4=BB=A3=E7=90=86=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 97 ------------------- .vscode/settings.json | 3 - README.md | 9 ++ .../wuyuanbiaoba/components/CameraView.jsx | 3 +- server/tcpProxy/index.js | 4 +- 5 files changed, 14 insertions(+), 102 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c95f840..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "开发模式", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "npm", - "skipFiles": [ - "/**" - ], - "runtimeArgs": [ - "run", - "start", - "--", - "--inspect-brk" - ], - "console": "integratedTerminal", - "env": { - /* - 参数都写在这里 省事儿 - 修改后需重启 - */ - "NODE_ENV": "development", - "PORT": "5000", - // - "FS_QINIU_DOMAIN": "https://resources-test.anxinyun.cn", - "FS_QINIU_ACTION": "https://up-z0.qiniup.com", - "FS_QINIU_ASSETS_DIR": "temp_v5", - // - "FS_SOCKET_URL": "ws://localhost:4000", - // - "API": "http://localhost:4000", - // TCP代理配置 - "TCP_HOST": "10.8.30.179", - "TCP_PORT": "2230", - } - }, - { - "type": "node", - "request": "launch", - "name": "本地构建", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "npm", - "skipFiles": [ - "/**" - ], - "runtimeArgs": [ - "run", - "build", - // "--", - // "--inspect-brk" - ], - "console": "integratedTerminal", - "env": {} - }, - { - "type": "node", - "request": "launch", - "name": "生产模式", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "npm", - "skipFiles": [ - "/**" - ], - "runtimeArgs": [ - "run", - "start", - "--", - "--inspect-brk" - ], - "console": "integratedTerminal", - "env": { - /* - 参数都写在这里 省事儿 - 修改后需重启 - */ - "NODE_ENV": "production", - "PORT": "5100", - /* ... */ - "FS_QINIU_DOMAIN": "https://resources-test.anxinyun.cn", - "FS_QINIU_ACTION": "https://up-z0.qiniup.com", - "FS_QINIU_ASSETS_DIR": "temp_v5", - // - "FS_SOCKET_URL": "ws://localhost:4000", - // - "API": "http://localhost:4000", - "TCP_HOST": "127.0.0.1", - "TCP_PORT": "2230", - } - }, - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5be3c7c..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.tabSize": 3 -} \ No newline at end of file diff --git a/README.md b/README.md index 1bc3f0f..c59587e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,22 @@ # 无源标靶上位机 ## Docker + ### 构建镜像 ```bash docker build -t passive-targeting-web . ``` + ### 运行容器 ```bash docker run -d -p 8080:8080 -p 8081:8081 --name passive-targeting-web passive-targeting-web ``` + +## 开发注意事项 + +- 请确保在开发环境中,`server/tcpProxy/index.js` 文件中的 `TCP_HOST` 设置为下位机的实际 IP 地址 +- 提交代码前,请将 `TCP_HOST` 设置回去 +- 确保在生产环境中,`client\src\sections\wuyuanbiaoba\components\CameraView.jsx`,摄像头流的 streamUrl 指向正确的地址 +- 提交代码前,请将 `streamUrl` 设置回去 diff --git a/client/src/sections/wuyuanbiaoba/components/CameraView.jsx b/client/src/sections/wuyuanbiaoba/components/CameraView.jsx index 6e1adb7..10bd9f6 100644 --- a/client/src/sections/wuyuanbiaoba/components/CameraView.jsx +++ b/client/src/sections/wuyuanbiaoba/components/CameraView.jsx @@ -50,7 +50,8 @@ const CameraView = ({ const maxRectangles = 5; // 摄像头流地址 - const streamUrl = import.meta.env.MODE === 'development'? 'http://10.8.30.179:2240/video_flow' :"http://127.0.0.1:2240/video_flow"; + const streamUrl = `http://${window.location.hostname}:2240/video_flow`; // 生产用 + // const streamUrl = `http://10.8.30.179:2240/video_flow`; //开发用 // 应用变换 const applyTransform = () => { diff --git a/server/tcpProxy/index.js b/server/tcpProxy/index.js index 1057232..afba718 100644 --- a/server/tcpProxy/index.js +++ b/server/tcpProxy/index.js @@ -1,7 +1,8 @@ const net = require('net'); const WebSocket = require('ws'); // TCP代理配置 -const TCP_HOST = process.env.NODE_ENV === 'development'? '10.8.30.179' : '127.0.0.1'; +const TCP_HOST = '127.0.0.1'; // 因为下位机和上位机在同一台机器上,所以使用localhost +// const TCP_HOST = '10.8.30.179'; //开发环境配置,开发时请解开这行注释,并且与下位机开发人员确认IP地址,提交代码别忘记注释掉 const TCP_PORT = 2230; // 创建独立的WebSocket服务器用于TCP代理 @@ -27,6 +28,7 @@ function setupTcpProxy(conf) { // TCP连接成功 tcpClient.connect(process.env.TCP_PORT || TCP_PORT, process.env.TCP_HOST || TCP_HOST, () => { + console.log(process.env); console.log(`TCP连接已建立到 ${TCP_HOST}:${TCP_PORT}`); });