From 09d254cd2a086231c92cfe17e053c42b175e7f54 Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 19 Apr 2022 20:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/preload.js | 34 ++++++++++++++++++---------------- src/App.vue | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/plugin/preload.js b/plugin/preload.js index a13495b..2d8520a 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -219,22 +219,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}"` + 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 { - 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, `\\\\ `)} &&` + 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 @@ -499,6 +499,8 @@ let liteErr = e => { return e.error ? e.error.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() : e.message } +utools.isDev() && (window.godMode = code => eval(code)) + // vm 模块将无法在渲染进程中使用,改用简单的沙箱来执行代码 let createSandbox = (code, sandbox, async = false) => { if (!async) code = `return (${code})` @@ -676,4 +678,4 @@ window.quickcommandHttpServer = () => { run, stop } -} +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index bfd8542..cd762cb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,7 +29,7 @@ export default defineComponent({ }, methods: { init() { - window.root = this; + utools.isDev() && (window.root = this); window.utools = window.getuToolsLite(); if (!this.checkVer()) return; this.startUp();