@@ -69,55 +69,19 @@ app.on('window-all-closed', () => {
6969} ) ;
7070
7171app . on ( 'before-quit' , ( event ) => {
72- // const isWindows = os.platform() === 'win32';
73- // let ports = [10821, 10822, 10824]; // 日常端口、测试包端口、线上包端口
74- // for (let port of ports) {
75- // let command = '';
76- // if (isWindows) {
77- // command = `netstat -ano | findstr:${port}`;
78- // } else {
79- // command = `lsof -i :${port} | awk '{print $2}'`;
80- // }
81-
82- // exec(command, (err, stdout) => {
83- // if (err) {
84- // console.error(`exec error: ${err}`);
85- // return;
86- // }
87-
88- // let pidArr = [];
89- // if (isWindows) {
90- // const lines = stdout.trim().split('\n');
91- // pidArr = lines.map((line) => line.trim().split(/\s+/)[4]).filter((pid) => !isNaN(pid));
92- // } else {
93- // pidArr = stdout.trim().split('\n');
94- // }
95-
96- // if (pidArr.length) {
97- // try {
98- // (pidArr || []).forEach((pid) => {
99- // !!pid && !isNaN(pid) && process.kill(pid);
100- // });
101- // } catch (error) {
102- // console.error(`Error killing process: ${error}`);
103- // }
104- // }
105- // });
106- // }
107- try {
108- const request = net . request ( {
109- headers : {
110- 'Content-Type' : 'application/json' ,
111- } ,
112- method : 'POST' ,
113- url : 'http://127.0.0.1:10824/api/system/stop' ,
114- } ) ;
115- request . end ( ) ;
116- } catch ( error ) { }
72+ mainWindow . webContents . send ( 'before-quit-app' ) ;
11773} ) ;
11874
11975ipcMain . handle ( 'get-product-name' , ( event ) => {
12076 const exePath = app . getPath ( 'exe' ) ;
12177 const { name } = path . parse ( exePath ) ;
12278 return name ;
12379} ) ;
80+
81+ // 注册退出应用事件
82+ ipcMain . on ( 'quit-app' , ( event ) => {
83+ app . quit ( ) ;
84+ } ) ;
85+
86+
87+
0 commit comments