mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-23 20:44:42 +08:00
关闭窗口自动杀进程
This commit is contained in:
16
plugin/package-lock.json
generated
16
plugin/package-lock.json
generated
@@ -8,7 +8,8 @@
|
||||
"axios": "^0.24.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"lodash": "^4.17.21",
|
||||
"ses": "^0.15.15"
|
||||
"ses": "^0.15.15",
|
||||
"tree-kill": "^1.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
@@ -63,6 +64,14 @@
|
||||
"version": "0.15.15",
|
||||
"resolved": "https://registry.npmmirror.com/ses/-/ses-0.15.15.tgz",
|
||||
"integrity": "sha512-sJM4HRlM3VouA3RhRmS7wG5MRQPqZZnc6O4BvAefU7yeM+qp8EUfGAWQ9iB/X5cNh3+m5N9lC7DEpyxQ+E4D+w=="
|
||||
},
|
||||
"node_modules/tree-kill": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/tree-kill/-/tree-kill-1.2.2.tgz",
|
||||
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
|
||||
"bin": {
|
||||
"tree-kill": "cli.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -101,6 +110,11 @@
|
||||
"version": "0.15.15",
|
||||
"resolved": "https://registry.npmmirror.com/ses/-/ses-0.15.15.tgz",
|
||||
"integrity": "sha512-sJM4HRlM3VouA3RhRmS7wG5MRQPqZZnc6O4BvAefU7yeM+qp8EUfGAWQ9iB/X5cNh3+m5N9lC7DEpyxQ+E4D+w=="
|
||||
},
|
||||
"tree-kill": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/tree-kill/-/tree-kill-1.2.2.tgz",
|
||||
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
"axios": "^0.24.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"lodash": "^4.17.21",
|
||||
"ses": "^0.15.15"
|
||||
"ses": "^0.15.15",
|
||||
"tree-kill": "^1.2.2"
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ const axios = require('axios');
|
||||
const http = require('http');
|
||||
const url = require('url')
|
||||
const nodeFns = require("./lib/nodeFns")
|
||||
const kill = require('tree-kill')
|
||||
require('ses')
|
||||
|
||||
window._ = require("lodash")
|
||||
@@ -97,8 +98,8 @@ window.quickcommand = {
|
||||
},
|
||||
|
||||
// 关闭进程
|
||||
kill: function(pid, signal = 'SIGTERM') {
|
||||
process.kill(pid, signal)
|
||||
kill: function(pid, signal = 'SIGTERM', cb) {
|
||||
kill(pid, signal, cb)
|
||||
},
|
||||
|
||||
// dom 解析
|
||||
@@ -211,22 +212,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
|
||||
}
|
||||
|
||||
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
||||
let cd = ''
|
||||
if (utools.isWindows()) {
|
||||
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
||||
// 直接 existsSync wt.exe 无效
|
||||
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
|
||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
||||
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
||||
} else {
|
||||
cmdline = cmdline.replace(/"/g, `^"`)
|
||||
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
||||
command = `${cd} start "" cmd /k "${cmdline}"`
|
||||
}
|
||||
} else {
|
||||
let cd = ''
|
||||
if (utools.isWindows()) {
|
||||
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
||||
// 直接 existsSync wt.exe 无效
|
||||
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
|
||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
||||
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
||||
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
||||
} else {
|
||||
cmdline = cmdline.replace(/"/g, `^"`)
|
||||
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
||||
command = `${cd} start "" cmd /k "${cmdline}"`
|
||||
}
|
||||
} else {
|
||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
||||
if (fs.existsSync('/Applications/iTerm.app')) {
|
||||
command = `osascript -e 'tell application "iTerm"
|
||||
create window with default profile
|
||||
@@ -606,6 +607,7 @@ window.runCodeFile = (cmd, option, terminal, callback) => {
|
||||
// let stderr = err_chunks.join("");
|
||||
// callback(stdout, stderr)
|
||||
// })
|
||||
return child
|
||||
}
|
||||
|
||||
let httpServer
|
||||
@@ -666,4 +668,4 @@ window.quickcommandHttpServer = () => {
|
||||
run,
|
||||
stop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user