From 724e969f0796c55b624409c5c7971fdf6b204455 Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 19 Apr 2022 15:00:01 +0800 Subject: [PATCH] =?UTF-8?q?ban=E6=8E=89utools=20enter=E5=92=8Cout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/preload.js | 47 +++++++++++++++++++++++++---------------------- src/App.vue | 4 ++-- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/plugin/preload.js b/plugin/preload.js index 955237a..e1d60f1 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -214,22 +214,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 @@ -394,12 +394,12 @@ window.getSelectFile = hwnd => { } window.showHelpPage = path => { - utools.ubrowser - .goto("https://www.yuque.com/fofolee-awga0/cpbg1m/bg31vl" + path) - .run({ - width: 1380, - height: 750 - }); + utools.ubrowser + .goto("https://www.yuque.com/fofolee-awga0/cpbg1m/bg31vl" + path) + .run({ + width: 1380, + height: 750 + }); } window.clipboardReadText = () => electron.clipboard.readText() @@ -465,6 +465,9 @@ window.getuToolsLite = () => { delete utoolsLite.getUserServerTemporaryToken delete utoolsLite.openPayment delete utoolsLite.fetchUserPayments + // 其他 + delete utoolsLite.onPluginEnter + delete utoolsLite.onPluginOut Object.freeze(utoolsLite) return utoolsLite } @@ -668,4 +671,4 @@ window.quickcommandHttpServer = () => { run, stop } -} \ No newline at end of file +} diff --git a/src/App.vue b/src/App.vue index ec77a78..bfd8542 100644 --- a/src/App.vue +++ b/src/App.vue @@ -33,10 +33,10 @@ export default defineComponent({ window.utools = window.getuToolsLite(); if (!this.checkVer()) return; this.startUp(); - utools.onPluginEnter((enter) => { + this.utools.whole.onPluginEnter((enter) => { this.enterPlugin(enter); }); - utools.onPluginOut(() => { + this.utools.whole.onPluginOut(() => { this.outPlugin(); }); },