mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-29 12:22:44 +08:00
修复反引号错误
This commit is contained in:
parent
fafe7465f2
commit
ae4461cfe7
@ -232,36 +232,35 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
||||||
let cd = ''
|
let cd, command;
|
||||||
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, `\\"`)
|
cmdline = cmdline.replace(/"/g, `\\"`);
|
||||||
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
cd = dir ? `-d "${dir.replace(/\\/g, '/')}"` : '';
|
||||||
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`;
|
||||||
} else {
|
} else {
|
||||||
cmdline = cmdline.replace(/"/g, `^"`)
|
cmdline = cmdline.replace(/"/g, `^"`);
|
||||||
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
cd = dir ? `cd /d "${dir.replace(/\\/g, '/')}" &&` : '';
|
||||||
command = `${cd} start "" cmd /k "${cmdline}"`
|
command = `${cd} start "" cmd /k "${cmdline}"`;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (utools.isMacOs()) {
|
||||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
cmdline = cmdline.replace(/"/g, `\\"`);
|
||||||
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
cd = dir ? `cd ${dir.replace(/ /g, '\\\\ ')} &&` : '';
|
||||||
if (fs.existsSync('/Applications/iTerm.app')) {
|
command = fs.existsSync('/Applications/iTerm.app') ?
|
||||||
command = `osascript -e 'tell application "iTerm"
|
`osascript -e 'tell application "iTerm"
|
||||||
create window with default profile
|
create window with default profile
|
||||||
tell current session of current window to write text "clear && ${cd} ${cmdline}"
|
tell current session of current window to write text "clear && ${cd} ${cmdline}"
|
||||||
end tell'`
|
end tell'` :
|
||||||
} else {
|
`osascript -e 'tell application "Terminal"
|
||||||
command = `osascript -e 'tell application "Terminal"
|
|
||||||
do script "clear && ${cd} ${cmdline}"
|
do script "clear && ${cd} ${cmdline}"
|
||||||
activate
|
activate
|
||||||
end tell'`
|
end tell'`;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
console.log(command);
|
console.log(command);
|
||||||
return command
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.pluginInfo = () => {
|
window.pluginInfo = () => {
|
||||||
@ -491,7 +490,6 @@ let getSandboxFuns = () => {
|
|||||||
shortCodes.forEach(f => {
|
shortCodes.forEach(f => {
|
||||||
sandbox[f.name] = f
|
sandbox[f.name] = f
|
||||||
})
|
})
|
||||||
// Object.assign(sandbox, nodeFns)
|
|
||||||
return sandbox
|
return sandbox
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,8 +499,6 @@ let liteErr = e => {
|
|||||||
return e.error ? e.error.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() : e.message
|
return e.error ? e.error.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() : e.message
|
||||||
}
|
}
|
||||||
|
|
||||||
utools.isDev() && (window.godMode = code => eval(code))
|
|
||||||
|
|
||||||
// vm 模块将无法在渲染进程中使用,改用 ses 来执行代码
|
// vm 模块将无法在渲染进程中使用,改用 ses 来执行代码
|
||||||
window.evalCodeInSandbox = (code, addVars = {}) => {
|
window.evalCodeInSandbox = (code, addVars = {}) => {
|
||||||
let sandboxWithAD = Object.assign(addVars, getSandboxFuns())
|
let sandboxWithAD = Object.assign(addVars, getSandboxFuns())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user