diff --git a/plugin/plugin.json b/plugin/plugin.json index e56d260..870341e 100644 --- a/plugin/plugin.json +++ b/plugin/plugin.json @@ -47,7 +47,7 @@ { "type": "regex", "label": "导入命令", - "match": "/(^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$)|(^qc=e)/i", + "match": "/(^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$)|(^qc\\/(id|base64)\\/.+)/i", "maxNum": 1 } ] diff --git a/plugin/preload.js b/plugin/preload.js index 3a27943..c470cc8 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -10,18 +10,38 @@ const axios = require('axios'); const http = require('http'); const url = require('url') const kill = require('tree-kill') +const crypto = require("crypto"); require('ses') +const md5 = (input) => { + return crypto.createHash("md5").update(input, "utf8").digest("hex"); +}; + window._ = require("lodash") window.getuToolsLite = require("./lib/utoolsLite") -window.yuQueClient = axios.create({ - baseURL: 'https://www.yuque.com/api/v2/', +// window.yuQueClient = axios.create({ +// baseURL: 'https://www.yuque.com/api/v2/', +// headers: { +// 'Content-Type': 'application/json', +// // 只读权限 +// 'X-Auth-Token': 'WNrd0Z4kfCZLFrGLVAaas93DZ7sbG6PirKq7VxBL' +// } +// }); + +window.getSharedQcById = async (id) => { + const url = "https://qc.qaz.ink/home/quick/script/getScript"; + const timeStamp = parseInt(new Date().getTime() / 1000); + const { data } = await axios.get(url, { + params: { + id, + }, headers: { - 'Content-Type': 'application/json', - // 只读权限 - 'X-Auth-Token': 'WNrd0Z4kfCZLFrGLVAaas93DZ7sbG6PirKq7VxBL' - } -}); + "verify-encrypt": md5("quickcommand666" + timeStamp), + "verify-time": timeStamp, + }, + }); + return JSON.stringify(data.data) +}; // 检测进程是否存在 let isProcessExits = pid => { @@ -633,10 +653,7 @@ window.runCodeFile = (cmd, option, terminal, callback, realTime=true) => { // } let child, cmdline; if (bin.slice(-7) == 'csc.exe') { - cmdline = ` - $ { bin } - $ { argv } - /out:"${script.slice(0, -2) + 'exe'}" "${script}" && "${script.slice(0, -2) + 'exe'}" ${scptarg}` + cmdline = `${bin} ${argv} /out:"${script.slice(0, -2) + 'exe'}" "${script}" && "${script.slice(0, -2) + 'exe'}" ${scptarg}` } else if (bin == 'gcc') { var suffix = utools.isWindows() ? '.exe' : '' cmdline = `${bin} ${argv} "${script.slice(0, -2)}" "${script}" && "${script.slice(0, -2) + suffix}" ${scptarg}` diff --git a/src/components/CommandCard.vue b/src/components/CommandCard.vue index 9899331..43c0183 100644 --- a/src/components/CommandCard.vue +++ b/src/components/CommandCard.vue @@ -444,6 +444,7 @@ export default { cursor: pointer; user-select: none; background: #00000008; + transition: 0.5s; } .q-card--dark.command { background: #ffffff08; diff --git a/src/js/common/quickcommandParser.js b/src/js/common/quickcommandParser.js index 48df2cd..c537ff9 100644 --- a/src/js/common/quickcommandParser.js +++ b/src/js/common/quickcommandParser.js @@ -11,11 +11,18 @@ let isJsonQc = (obj, strict = true) => { return true; }; +let payloadParser = async (payload) => { + let [, format, value] = payload.split("/"); + if (format === "base64") return window.base64Decode(value); + else if (format === "id") return await window.getSharedQcById(value); + else throw new Error("不支持的格式"); +}; + // 判断是否为可导入的快捷命令 -let qcparser = (json, strict = true) => { +let quickcommandParser = async (payload, strict = true) => { try { - if (json.slice(0, 3) === "qc=") json = window.base64Decode(json.slice(3)); - var qc = JSON.parse(json); + if (payload.slice(0, 3) === "qc/") payload = await payloadParser(payload); + var qc = JSON.parse(payload); } catch (error) { return false; } @@ -25,4 +32,4 @@ let qcparser = (json, strict = true) => { else return false; }; -export default qcparser; +export default quickcommandParser;