兼容老版本

This commit is contained in:
fofolee 2022-04-21 10:32:42 +08:00
parent bb247ee8c8
commit 1edd928927

View File

@ -209,22 +209,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
@ -474,7 +474,13 @@ let getSandboxFuns = () => {
electron: electron, electron: electron,
axios: axios, axios: axios,
Audio: Audio, Audio: Audio,
fetch: fetch fetch: fetch,
// 兼容老版本
fs: fs,
path: path,
os: os,
child_process: child_process,
util: util,
} }
shortCodes.forEach(f => { shortCodes.forEach(f => {
sandbox[f.name] = f sandbox[f.name] = f
@ -668,4 +674,4 @@ window.quickcommandHttpServer = () => {
run, run,
stop stop
} }
} }