mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-29 20:32:44 +08:00
pythonc编码设置
This commit is contained in:
parent
d659fdcc88
commit
f580660ac7
@ -194,11 +194,13 @@ window.temporaryStoreSoldOut = () => {
|
||||
// python -c
|
||||
window.runPythonCommand = py => {
|
||||
try {
|
||||
return child_process.execFileSync("python", ["-c", py], {
|
||||
let result = child_process.execFileSync("python", ["-c", py], {
|
||||
windowsHide: true,
|
||||
encoding: 'buffer'
|
||||
})
|
||||
return iconv.decode(result, utools.isWindows() ? 'gbk' : 'utf8').trim()
|
||||
} catch (e) {
|
||||
utools.showNotification(e)
|
||||
alert(e)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@ -210,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user