|
@@ -1,8 +1,9 @@
|
|
|
import {app, BrowserWindow, ipcMain, dialog} from 'electron';
|
|
|
-import {exec} from 'child_process';
|
|
|
+import {exec, spawn} from 'child_process';
|
|
|
import path from 'path';
|
|
|
import {fileURLToPath} from 'url';
|
|
|
|
|
|
+
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
|
@@ -19,8 +20,8 @@ function createWindow() {
|
|
|
});
|
|
|
|
|
|
win.webContents.openDevTools();
|
|
|
-
|
|
|
- win.loadURL('http://36.110.106.156:81');
|
|
|
+ win.loadURL('http://localhost:5173');
|
|
|
+
|
|
|
console.log('Window created and URL loaded');
|
|
|
}
|
|
|
|
|
@@ -110,33 +111,68 @@ ipcMain.on('docker-import', (event, sudoPassword, filePath, tag) => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
ipcMain.on('generate-world', (event, rosbag_path) => {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const serviceScript = 'sh /home/cicv/work/pji_desktop/run_map2gazabo.sh';
|
|
|
|
|
|
|
|
|
- const serviceProcess = spawn(serviceScript, [], { detached: true });
|
|
|
+ const serviceProcess = spawn('bash', ["/home/cicv/work/pji_desktop/run_map2gazebo.sh"], { detached: true });
|
|
|
|
|
|
|
|
|
serviceProcess.unref();
|
|
|
|
|
|
|
|
|
serviceProcess.stdout.on('data', (data) => {
|
|
|
- console.log(`Service output: ${data}`);
|
|
|
+ console.log(`第一个脚本的输出: ${data}`);
|
|
|
+
|
|
|
+ if (data.toString().includes('Service map2gazebo started')) {
|
|
|
+ startSecondScript();
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
+
|
|
|
serviceProcess.stderr.on('data', (data) => {
|
|
|
- console.error(`Service error: ${data}`);
|
|
|
+ console.error(`执行第一个脚本时出错: ${data}`);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ serviceProcess.on('close', (data) => {
|
|
|
+ console.log(`第二个脚本已关闭: ${data}`);
|
|
|
});
|
|
|
+
|
|
|
+ function startSecondScript() {
|
|
|
+
|
|
|
+ const script2 = exec('bash /home/cicv/work/pji_desktop/play_rosbag.sh /home/cicv/work/pji_desktop/map_bag/map.bag', (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ console.error(`执行第二个脚本时出错: ${error}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(`第二个脚本的输出: ${stdout}`);
|
|
|
+ });
|
|
|
+
|
|
|
+ script2.on('exit', (code) => {
|
|
|
+ console.log(`第二个脚本已退出,退出码: ${code}`);
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
+
|