mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 13:02:46 +08:00
pythonc编码设置
This commit is contained in:
parent
d659fdcc88
commit
f580660ac7
@ -194,11 +194,13 @@ window.temporaryStoreSoldOut = () => {
|
|||||||
// python -c
|
// python -c
|
||||||
window.runPythonCommand = py => {
|
window.runPythonCommand = py => {
|
||||||
try {
|
try {
|
||||||
return child_process.execFileSync("python", ["-c", py], {
|
let result = child_process.execFileSync("python", ["-c", py], {
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
|
encoding: 'buffer'
|
||||||
})
|
})
|
||||||
|
return iconv.decode(result, utools.isWindows() ? 'gbk' : 'utf8').trim()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
utools.showNotification(e)
|
alert(e)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,22 +212,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
||||||
let cd = ''
|
let cd = ''
|
||||||
if (utools.isWindows()) {
|
if (utools.isWindows()) {
|
||||||
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
||||||
// 直接 existsSync wt.exe 无效
|
// 直接 existsSync wt.exe 无效
|
||||||
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('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 {
|
|
||||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
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')) {
|
if (fs.existsSync('/Applications/iTerm.app')) {
|
||||||
command = `osascript -e 'tell application "iTerm"
|
command = `osascript -e 'tell application "iTerm"
|
||||||
create window with default profile
|
create window with default profile
|
||||||
@ -573,4 +575,4 @@ window.runCodeFile = (cmd, option, terminal, callback) => {
|
|||||||
// let stderr = err_chunks.join("");
|
// let stderr = err_chunks.join("");
|
||||||
// callback(stdout, stderr)
|
// callback(stdout, stderr)
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user