fix: 修复引号bug

This commit is contained in:
fofolee 2021-03-30 23:08:42 +08:00
parent 59cd8f6191
commit 6bafa93755
5 changed files with 13 additions and 10 deletions

View File

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

View File

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

View File

@ -395,17 +395,19 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function (cmdline
let getCommandToLaunchTerminal = (cmdline, dir) => { let getCommandToLaunchTerminal = (cmdline, dir) => {
let cd = '' let cd = ''
cmdline = cmdline.replace(/"/g, `\\"`)
if (utools.isWindows()) { if (utools.isWindows()) {
let wtpath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/wt.exe') let wtpath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/wt.exe')
if (fs.existsSync(wtpath)) { if (fs.existsSync(wtpath)) {
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
command = `wt ${cd} cmd /k "${cmdline}"` command = `wt ${cd} cmd /k "${cmdline}"`
} else { } else {
cmdline = cmdline.replace(/"/g, `^"`)
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&` if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
command = `${cd} start "" cmd /k "${cmdline}"` command = `${cd} start "" cmd /k "${cmdline}"`
} }
} else { } else {
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&` if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
if (fs.existsSync('/Applications/iTerm.app')) { if (fs.existsSync('/Applications/iTerm.app')) {
command = `osascript -e 'tell application "iTerm" command = `osascript -e 'tell application "iTerm"
@ -419,6 +421,7 @@ let getCommandToLaunchTerminal = (cmdline, dir) => {
end tell'` end tell'`
} }
} }
console.log(command);
return command return command
} }
@ -445,7 +448,7 @@ let GetFilePath = (Path, File) => {
let getSleepCodeByShell = ms => { let getSleepCodeByShell = ms => {
var cmd, tempFilePath var cmd, tempFilePath
if (utools.isWindows()) { 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}` cmd = `echo set ws=CreateObject("Wscript.Shell") > ${tempFilePath} && echo Wscript.sleep ${ms} >> ${tempFilePath} && cscript /nologo ${tempFilePath}`
} else { } else {
cmd = `sleep ${ms / 1000}` cmd = `sleep ${ms / 1000}`
@ -664,7 +667,7 @@ hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
hexDecode = text => Buffer.from(text, 'hex').toString('utf8') hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
py_beautify = (code, cb) => { py_beautify = (code, cb) => {
var file = getQuickCommandScriptFile('py') var file = getQuickcommandTempFile('py')
fs.writeFile(file, code, { encoding: 'utf8' }, err => { fs.writeFile(file, code, { encoding: 'utf8' }, err => {
var cmd = `python "${GetFilePath('assets/plugins', 'autopep8.py')}" "${file}"` var cmd = `python "${GetFilePath('assets/plugins', 'autopep8.py')}" "${file}"`
child_process.exec(cmd, { encoding: "buffer" }, (err, stdout, stderr) => { child_process.exec(cmd, { encoding: "buffer" }, (err, stdout, stderr) => {
@ -676,8 +679,8 @@ py_beautify = (code, cb) => {
processPlatform = process.platform processPlatform = process.platform
getQuickCommandScriptFile = ext => { getQuickcommandTempFile = ext => {
return path.join(os.tmpdir(), `QuickCommandTempScript.${ext}`) return path.join(os.tmpdir(), `quickcommandTempFile.${ext}`)
} }
getBase64Ico = async filepath => { getBase64Ico = async filepath => {
@ -821,7 +824,7 @@ runCodeFile = (cmd, option, terminal, callback) => {
ext = option.ext, ext = option.ext,
charset = option.charset, charset = option.charset,
scptarg = option.scptarg || ""; scptarg = option.scptarg || "";
let script = getQuickCommandScriptFile(ext) let script = getQuickcommandTempFile(ext)
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题 // 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode); if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode);
fs.writeFileSync(script, cmd); fs.writeFileSync(script, cmd);