From 7973dc6a2c5696535fa2eb139329c49bd4807dbd Mon Sep 17 00:00:00 2001 From: fofolee Date: Fri, 15 Apr 2022 00:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BA=AB=E4=B8=AD=E5=BF=83=2030%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/plugin.json | 41 +++++++++++----- plugin/preload.js | 36 ++++++++------ src/pages/ShareCenterPage.vue | 90 +++++++++++++++++++++++++++++++++++ src/router/routes.js | 8 +++- 4 files changed, 146 insertions(+), 29 deletions(-) create mode 100644 src/pages/ShareCenterPage.vue diff --git a/plugin/plugin.json b/plugin/plugin.json index 5131fc0..9b0e225 100644 --- a/plugin/plugin.json +++ b/plugin/plugin.json @@ -9,32 +9,49 @@ "main": "http://127.0.0.1:8080/" }, "author": "云之轩", - "unpack":"autopep8.py", + "unpack": "autopep8.py", "logo": "logo.png", "preload": "preload.js", "pluginSetting": { "single": false }, - "features": [ - { + "features": [{ "code": "configuration", - "explain": "新建、编辑或获取快捷命令", - "cmds": [ "快捷命令", "QuickCommand"] + "explain": "创建或编辑快捷命令", + "cmds": [ + "快捷命令", + "QuickCommand" + ] }, { "code": "code", "explain": "运行代码", - "cmds": [ "运行代码", "RunCode"] + "cmds": [ + "运行代码", + "RunCode" + ] }, { "code": "newcommand", "explain": "快速新建快捷命令", - "cmds": [ "新建快捷命令", "NewCommand", { - "type": "regex", - "label": "新建快捷命令", - "match": "/^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$/i", - "maxNum": 1 - }] + "cmds": [ + "新建快捷命令", + "NewCommand", + { + "type": "regex", + "label": "新建快捷命令", + "match": "/^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$/i", + "maxNum": 1 + } + ] + }, + { + "code": "share", + "explain": "查看分享中心的快捷命令", + "cmds": [ + "分享中心", + "ShareCenter" + ] } ] } diff --git a/plugin/preload.js b/plugin/preload.js index 03b0298..0badace 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -12,6 +12,10 @@ const axios = require('axios'); const pictureCompress = require("./lib/picture-compressor") window._ = require("lodash") +window.fetchGitee = async path => { + let res = await axios('https://gitee.com/api/v5/repos/fofolee/qcshares' + path) + return res.data +} // axios.defaults.adapter = require('axios/lib/adapters/http') @@ -212,22 +216,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 @@ -413,6 +417,8 @@ window.htmlEncode = (value) => { window.hexEncode = text => Buffer.from(text, 'utf8').toString('hex') window.hexDecode = text => Buffer.from(text, 'hex').toString('utf8') +window.base64Decode = text => Buffer.from(text, 'base64').toString('utf8') + window.processPlatform = process.platform diff --git a/src/pages/ShareCenterPage.vue b/src/pages/ShareCenterPage.vue new file mode 100644 index 0000000..811acef --- /dev/null +++ b/src/pages/ShareCenterPage.vue @@ -0,0 +1,90 @@ + + + diff --git a/src/router/routes.js b/src/router/routes.js index 5b82e61..49e7a93 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -40,8 +40,12 @@ const routes = [{ name: 'loading', component: () => import ('pages/LoadingPage.vue') + }, { + path: '/share', + name: 'share', + component: () => + import ('pages/ShareCenterPage.vue') } - ] -export default routes \ No newline at end of file +export default routes