fix: 终端 bug fix

This commit is contained in:
fofolee 2021-03-28 10:25:44 +08:00
parent ee2056521f
commit a2a070d471
5 changed files with 8 additions and 39 deletions

View File

@ -1,6 +1,6 @@
# 快捷命令 V2.3.4
# 快捷命令 V2.3.5
[![GitHub stars](https://img.shields.io/github/stars/fofolee/uTools-quickcommand?style=flat-square)](https://github.com/fofolee/uTools-quickcommand/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fofolee/uTools-quickcommand?style=flat-square)](https://github.com/fofolee/uTools-quickcommand/network/members) [![GitHub license](https://img.shields.io/github/license/fofolee/uTools-quickcommand?style=flat-square)](https://github.com/fofolee/uTools-quickcommand/blob/master/LICENSE) [![version]( https://img.shields.io/badge/dynamic/json?color=f58142&label=version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Ffofolee%2FuTools-quickcommand%2Fmaster%2Fsrc%2Fplugin.json&style=flat-square)](https://github.com/fofolee/uTools-quickcommand/blob/master/src/helps/CHANGELOG.md) [![猿料](https://img.shields.io/badge/%E7%8C%BF%E6%96%99-%2Fd%2F424-red?style=flat-square)](https://yuanliao.info/d/424) [![评论](https://img.shields.io/badge/dynamic/json?color=%2350e3c2&label=%E8%AF%84%E8%AE%BA&query=%24.data.attributes.commentCount&url=https%3A%2F%2Fyuanliao.info%2Fapi%2Fdiscussions%2F424&style=flat-square)](https://yuanliao.info/d/424) [![下载](https://img.shields.io/badge/dynamic/json?label=%E4%B8%8B%E8%BD%BD&query=quickcommand&url=https%3A%2F%2Ffofolee.cn1.utools.club%2Fapi%2Fqcdownloads&style=flat-square)](https://yuanliao.info/d/424)

View File

@ -1,6 +1,6 @@
# 快捷命令 V2.3.4
# 快捷命令 V2.3.5
[![GitHub stars](https://img.shields.io/github/stars/fofolee/uTools-quickcommand?style=flat-square)](https://github.com/fofolee/uTools-quickcommand/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fofolee/uTools-quickcommand?style=flat-square)](https://github.com/fofolee/uTools-quickcommand/network/members) [![GitHub license](https://img.shields.io/github/license/fofolee/uTools-quickcommand?style=flat-square)](https://github.com/fofolee/uTools-quickcommand/blob/master/LICENSE) [![version]( https://img.shields.io/badge/dynamic/json?color=f58142&label=version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Ffofolee%2FuTools-quickcommand%2Fmaster%2Fsrc%2Fplugin.json&style=flat-square)](https://github.com/fofolee/uTools-quickcommand/blob/master/src/helps/CHANGELOG.md) [![猿料](https://img.shields.io/badge/%E7%8C%BF%E6%96%99-%2Fd%2F424-red?style=flat-square)](https://yuanliao.info/d/424) [![评论](https://img.shields.io/badge/dynamic/json?color=%2350e3c2&label=%E8%AF%84%E8%AE%BA&query=%24.data.attributes.commentCount&url=https%3A%2F%2Fyuanliao.info%2Fapi%2Fdiscussions%2F424&style=flat-square)](https://yuanliao.info/d/424) [![下载](https://img.shields.io/badge/dynamic/json?label=%E4%B8%8B%E8%BD%BD&query=quickcommand&url=https%3A%2F%2Ffofolee.cn1.utools.club%2Fapi%2Fqcdownloads&style=flat-square)](https://yuanliao.info/d/424)

View File

@ -38,7 +38,7 @@ let oldVersionFix = () => {
}
let showChangeLog = () => {
let ignoreVersions = []
let ignoreVersions = ['2.3.5']
if (ignoreVersions.includes(pluginInfo().version)) return
UTOOLS.putDB(pluginInfo().version, UTOOLS.DBPRE.CFG + 'version')
utools.createBrowserWindow('./helps/CHANGELOG.html', { width: 1280, height: 920 })

View File

@ -4,7 +4,7 @@
"main": "index.html",
"homepage": "https://github.com/fofolee/uTools-quickcommand",
"publishPage": "https://yuanliao.info/d/424",
"version": "2.3.4",
"version": "2.3.5",
"author": "云之轩",
"unpack":"autopep8.py",
"logo": "logo.png",

View File

@ -389,13 +389,13 @@ if (process.platform == 'win32') quickcommand.runVbs = function (script) {
// 在终端中执行
if (process.platform !== 'linux') quickcommand.runInTerminal = function (cmdline, dir) {
let command = getCommandToLaunchTerminal(cmdline.replace(/"/g, `\\"`), dir)
console.log(command);
let command = getCommandToLaunchTerminal(cmdline, dir)
child_process.exec(command)
}
let getCommandToLaunchTerminal = (cmdline, dir) => {
let cd = ''
cmdline = cmdline.replace(/"/g, `\\"`)
if (utools.isWindows()) {
let wtpath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/wt.exe')
if (fs.existsSync(wtpath)) {
@ -406,15 +406,9 @@ let getCommandToLaunchTerminal = (cmdline, dir) => {
command = `${cd} start "" cmd /k "${cmdline}"`
}
} else {
let iterm
if (fs.existsSync('/Applications/iTerm 2.app')) {
iterm = 'iTerm 2'
} else if (fs.existsSync('/Applications/iTerm.app')) {
iterm = 'iTerm'
}
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
if (iterm) {
command = `osascript -e 'tell application "${iterm}"
if (fs.existsSync('/Applications/iTerm.app')) {
command = `osascript -e 'tell application "iTerm"
create window with default profile
tell current session of current window to write text "clear && ${cd} ${cmdline}"
end tell'`
@ -849,31 +843,6 @@ runCodeFile = (cmd, option, terminal, callback) => {
}
// 在终端中输出
if (terminal) cmdline = getCommandToLaunchTerminal(cmdline)
// if (terminal) {
// if (utools.isWindows()) {
// if (bin.slice(-7) == 'csc.exe' || bin == 'gcc') {
// cmdline = cmdline.split("&&")
// cmdline = cmdline[0] + "&& start cmd /k " + cmdline[1]
// } else {
// cmdline = `start cmd /k ${cmdline}`
// }
// } else if(utools.isMacOs()){
// var appleScript = `if application "Terminal" is running then
// tell application "Terminal"
// do script "clear;${cmdline.replace(/"/g, `\\"`)}"
// activate
// end tell
// else
// tell application "Terminal"
// do script "clear;${cmdline.replace(/"/g, `\\"`)}" in window 1
// activate
// end tell
// end if`;
// cmdline = `osascript -e '${appleScript}'`
// } else {
// return message('Linux 不支持在终端输出')
// }
// }
child = child_process.spawn(cmdline, { encoding: 'buffer', shell: true })
// var chunks = [],
// err_chunks = [];