From 6bafa93755499c46192e5919a6f993852d2e3f6a Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 30 Mar 2021 23:08:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=95=E5=8F=B7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/README.md | 2 +- src/assets/js/init.js | 2 +- src/plugin.json | 2 +- src/preload.js | 15 +++++++++------ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cdf6a97..3f1fa8c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# 快捷命令 V2.3.5 +# 快捷命令 V2.3.6 [![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) diff --git a/src/README.md b/src/README.md index cdf6a97..3f1fa8c 100644 --- a/src/README.md +++ b/src/README.md @@ -1,6 +1,6 @@ -# 快捷命令 V2.3.5 +# 快捷命令 V2.3.6 [![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) diff --git a/src/assets/js/init.js b/src/assets/js/init.js index 3bdc18e..5328eed 100644 --- a/src/assets/js/init.js +++ b/src/assets/js/init.js @@ -38,7 +38,7 @@ let oldVersionFix = () => { } let showChangeLog = () => { - let ignoreVersions = ['2.3.5'] + let ignoreVersions = ['2.3.5', '2.3.6'] if (ignoreVersions.includes(pluginInfo().version)) return UTOOLS.putDB(pluginInfo().version, UTOOLS.DBPRE.CFG + 'version') utools.createBrowserWindow('./helps/CHANGELOG.html', { width: 1280, height: 920 }) diff --git a/src/plugin.json b/src/plugin.json index 45f91e5..2970fa4 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -4,7 +4,7 @@ "main": "index.html", "homepage": "https://github.com/fofolee/uTools-quickcommand", "publishPage": "https://yuanliao.info/d/424", - "version": "2.3.5", + "version": "2.3.6", "author": "云之轩", "unpack":"autopep8.py", "logo": "logo.png", diff --git a/src/preload.js b/src/preload.js index 9819bda..627d17c 100644 --- a/src/preload.js +++ b/src/preload.js @@ -395,17 +395,19 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function (cmdline 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)) { + cmdline = cmdline.replace(/"/g, `\\"`) if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` command = `wt ${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" @@ -419,6 +421,7 @@ let getCommandToLaunchTerminal = (cmdline, dir) => { end tell'` } } + console.log(command); return command } @@ -445,7 +448,7 @@ let GetFilePath = (Path, File) => { let getSleepCodeByShell = ms => { var cmd, tempFilePath if (utools.isWindows()) { - tempFilePath = getQuickCommandScriptFile('vbs') + tempFilePath = getQuickcommandTempFile('vbs') cmd = `echo set ws=CreateObject("Wscript.Shell") > ${tempFilePath} && echo Wscript.sleep ${ms} >> ${tempFilePath} && cscript /nologo ${tempFilePath}` } else { cmd = `sleep ${ms / 1000}` @@ -664,7 +667,7 @@ hexEncode = text => Buffer.from(text, 'utf8').toString('hex') hexDecode = text => Buffer.from(text, 'hex').toString('utf8') py_beautify = (code, cb) => { - var file = getQuickCommandScriptFile('py') + var file = getQuickcommandTempFile('py') fs.writeFile(file, code, { encoding: 'utf8' }, err => { var cmd = `python "${GetFilePath('assets/plugins', 'autopep8.py')}" "${file}"` child_process.exec(cmd, { encoding: "buffer" }, (err, stdout, stderr) => { @@ -676,8 +679,8 @@ py_beautify = (code, cb) => { processPlatform = process.platform -getQuickCommandScriptFile = ext => { - return path.join(os.tmpdir(), `QuickCommandTempScript.${ext}`) +getQuickcommandTempFile = ext => { + return path.join(os.tmpdir(), `quickcommandTempFile.${ext}`) } getBase64Ico = async filepath => { @@ -821,7 +824,7 @@ runCodeFile = (cmd, option, terminal, callback) => { ext = option.ext, charset = option.charset, scptarg = option.scptarg || ""; - let script = getQuickCommandScriptFile(ext) + let script = getQuickcommandTempFile(ext) // 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题 if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode); fs.writeFileSync(script, cmd);