mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-29 12:22:44 +08:00
添加从id获取qc的接口
This commit is contained in:
parent
545d4b3b31
commit
4de96bac47
@ -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
|
||||
}
|
||||
]
|
||||
|
@ -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}`
|
||||
|
@ -444,6 +444,7 @@ export default {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
background: #00000008;
|
||||
transition: 0.5s;
|
||||
}
|
||||
.q-card--dark.command {
|
||||
background: #ffffff08;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user