mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-19 10:15:45 +08:00
Compare commits
13 Commits
5.0.3
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71c5b70fea | ||
|
|
14769bb7e7 | ||
|
|
5d76d4d657 | ||
|
|
ebde8999bf | ||
|
|
31f0d66ebc | ||
|
|
c1f86c20d2 | ||
|
|
bbdc2c6d65 | ||
|
|
0979e5648c | ||
|
|
f9a22595be | ||
|
|
823a95079a | ||
|
|
39ee88b02a | ||
|
|
fcf3d5912e | ||
|
|
f61fe17c6a |
12
package-lock.json
generated
12
package-lock.json
generated
@@ -6251,9 +6251,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy-middleware": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz",
|
||||
"integrity": "sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==",
|
||||
"version": "2.0.9",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.9.tgz",
|
||||
"integrity": "sha512-c1IyJYLYppU574+YI7R4QyX2ystMtVXZwIdzazUIPIJsHuWNd+mho2j+bKoHftndicGj9yh+xjd+l0yj7VeT1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -15697,9 +15697,9 @@
|
||||
}
|
||||
},
|
||||
"http-proxy-middleware": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz",
|
||||
"integrity": "sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==",
|
||||
"version": "2.0.9",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.9.tgz",
|
||||
"integrity": "sha512-c1IyJYLYppU574+YI7R4QyX2ystMtVXZwIdzazUIPIJsHuWNd+mho2j+bKoHftndicGj9yh+xjd+l0yj7VeT1Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/http-proxy": "^1.17.8",
|
||||
|
||||
28
plugin/package-lock.json
generated
28
plugin/package-lock.json
generated
@@ -5,7 +5,7 @@
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"axios": "^1.8.2",
|
||||
"chrome-remote-interface": "^0.33.2",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dompurify": "^3.2.4",
|
||||
@@ -15,7 +15,7 @@
|
||||
"node-forge": "^1.3.1",
|
||||
"pinyin-match": "^1.2.6",
|
||||
"png2icons": "^2.0.1",
|
||||
"ses": "^1.10.0",
|
||||
"ses": "^1.12.0",
|
||||
"sm-crypto": "^0.3.13",
|
||||
"tree-kill": "^1.2.2"
|
||||
}
|
||||
@@ -40,9 +40,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.7.9",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
||||
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.2.tgz",
|
||||
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
@@ -229,9 +229,9 @@
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/ses": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/ses/-/ses-1.10.0.tgz",
|
||||
"integrity": "sha512-HXmJbNEgY/4hsQfaz5dna39vVKNyvlElRmJYk+bjTqSXSElT0Hr6NKwWVg4j0TxP6IuHp/PNMoWJKIRXzmLbAQ==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/ses/-/ses-1.12.0.tgz",
|
||||
"integrity": "sha512-jvmwXE2lFxIIY1j76hFjewIIhYMR9Slo3ynWZGtGl5M7VUCw3EA0wetS+JCIbl2UcSQjAT0yGAHkyxPJreuC9w==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@endo/env-options": "^1.1.8"
|
||||
@@ -293,9 +293,9 @@
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "1.7.9",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
||||
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.2.tgz",
|
||||
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
@@ -419,9 +419,9 @@
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"ses": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/ses/-/ses-1.10.0.tgz",
|
||||
"integrity": "sha512-HXmJbNEgY/4hsQfaz5dna39vVKNyvlElRmJYk+bjTqSXSElT0Hr6NKwWVg4j0TxP6IuHp/PNMoWJKIRXzmLbAQ==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/ses/-/ses-1.12.0.tgz",
|
||||
"integrity": "sha512-jvmwXE2lFxIIY1j76hFjewIIhYMR9Slo3ynWZGtGl5M7VUCw3EA0wetS+JCIbl2UcSQjAT0yGAHkyxPJreuC9w==",
|
||||
"requires": {
|
||||
"@endo/env-options": "^1.1.8"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"axios": "^1.8.2",
|
||||
"chrome-remote-interface": "^0.33.2",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dompurify": "^3.2.4",
|
||||
@@ -10,7 +10,7 @@
|
||||
"node-forge": "^1.3.1",
|
||||
"pinyin-match": "^1.2.6",
|
||||
"png2icons": "^2.0.1",
|
||||
"ses": "^1.10.0",
|
||||
"ses": "^1.12.0",
|
||||
"sm-crypto": "^0.3.13",
|
||||
"tree-kill": "^1.2.2"
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import programmings from "./js/options/programs.js";
|
||||
import defaultProfile from "./js/options/defaultProfile.js";
|
||||
import Cron from "croner";
|
||||
import QuickCommand from "components/quickcommandUI/QuickCommand";
|
||||
import { generateFlowsCode } from "js/composer/generateCode";
|
||||
|
||||
// import autoDetach from "./js/autoDetach.js";
|
||||
|
||||
export default defineComponent({
|
||||
@@ -157,10 +159,13 @@ export default defineComponent({
|
||||
reslove([`超过${timeout}ms未响应`]);
|
||||
}, timeout);
|
||||
let command = dbManager.getDB("qc_" + featureCode);
|
||||
let commandCode = command.cmd;
|
||||
let commandCode =
|
||||
command.program === "quickcomposer"
|
||||
? generateFlowsCode(command.flows)
|
||||
: command.cmd;
|
||||
if (mainInput)
|
||||
commandCode = commandCode.replace(/\{\{input\}\}/g, mainInput);
|
||||
if (command.program === "quickcommand") {
|
||||
if (["quickcommand", "quickcomposer"].includes(command.program)) {
|
||||
window.runCodeInSandbox(commandCode, (stdout, stderr) => {
|
||||
stderr && reslove([stderr.toString()]);
|
||||
reslove(stdout);
|
||||
|
||||
@@ -14,12 +14,15 @@
|
||||
bordered
|
||||
class="action-card cursor-pointer"
|
||||
:class="{
|
||||
'action-selected': selectedActionKeys.includes(actionKey),
|
||||
'action-selected': actionCount[actionKey] > 0,
|
||||
}"
|
||||
@click="toggleAction(actionKey)"
|
||||
@click="addAction(actionKey)"
|
||||
>
|
||||
<div class="q-pa-xs text-caption text-wrap text-center">
|
||||
{{ action.label }}
|
||||
<q-badge v-if="actionCount[actionKey]" color="primary" floating>
|
||||
{{ actionCount[actionKey] }}
|
||||
</q-badge>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
@@ -38,7 +41,7 @@
|
||||
<q-chip
|
||||
square
|
||||
removable
|
||||
@remove="toggleAction(selectedActionKey)"
|
||||
@remove="removeAction(index)"
|
||||
class="text-caption q-mb-sm"
|
||||
:style="{
|
||||
paddingLeft: '7px',
|
||||
@@ -125,6 +128,13 @@ export default {
|
||||
selectedActionArgs() {
|
||||
return this.modelValue.map((x) => x.args);
|
||||
},
|
||||
actionCount() {
|
||||
const count = {};
|
||||
this.selectedActionKeys.forEach((key) => {
|
||||
count[key] = (count[key] || 0) + 1;
|
||||
});
|
||||
return count;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
moveAction(index, direction) {
|
||||
@@ -138,26 +148,25 @@ export default {
|
||||
this.$emit("update:model-value", newOperation);
|
||||
}
|
||||
},
|
||||
toggleAction(actionKey) {
|
||||
const index = this.selectedActionKeys.indexOf(actionKey);
|
||||
addAction(actionKey) {
|
||||
let newOperation = [...this.modelValue];
|
||||
if (index !== -1) {
|
||||
// 移除操作
|
||||
newOperation.splice(index, 1);
|
||||
} else {
|
||||
// 添加操作
|
||||
const { config, value } = this.operationsMap[actionKey];
|
||||
const args = config?.length
|
||||
? config.map((field) => field.defaultValue)
|
||||
: [];
|
||||
// 添加操作
|
||||
const { config, value } = this.operationsMap[actionKey];
|
||||
const args = config?.length
|
||||
? config.map((field) => field.defaultValue)
|
||||
: [];
|
||||
|
||||
const newOperationItem = { value, args };
|
||||
if (actionKey !== value) {
|
||||
newOperationItem.key = actionKey;
|
||||
}
|
||||
|
||||
newOperation.push(newOperationItem);
|
||||
const newOperationItem = { value, args };
|
||||
if (actionKey !== value) {
|
||||
newOperationItem.key = actionKey;
|
||||
}
|
||||
|
||||
newOperation.push(newOperationItem);
|
||||
this.$emit("update:model-value", newOperation);
|
||||
},
|
||||
removeAction(index) {
|
||||
let newOperation = [...this.modelValue];
|
||||
newOperation.splice(index, 1);
|
||||
this.$emit("update:model-value", newOperation);
|
||||
},
|
||||
updateActionArgs(argvIndex, argvVal, actionIndex) {
|
||||
@@ -250,4 +259,11 @@ export default {
|
||||
.row.q-col-gutter-xs > * {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.q-badge {
|
||||
font-size: 10px;
|
||||
padding: 2px 4px;
|
||||
right: -4px;
|
||||
top: -4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -114,9 +114,13 @@ export default {
|
||||
|
||||
return this.items.filter((x) => {
|
||||
if (this.is.json) {
|
||||
const titleMatch = window.pinyinMatch.match(x.title, this.searchWords);
|
||||
const titleMatch = window.pinyinMatch.match(
|
||||
x.title,
|
||||
this.searchWords
|
||||
);
|
||||
const descMatch =
|
||||
x.description && window.pinyinMatch.match(x.description, this.searchWords);
|
||||
x.description &&
|
||||
window.pinyinMatch.match(x.description, this.searchWords);
|
||||
return titleMatch || descMatch;
|
||||
} else {
|
||||
return window.pinyinMatch.match(x, this.searchWords);
|
||||
@@ -212,6 +216,7 @@ export default {
|
||||
this.searchWords = text;
|
||||
if (this.matchedItems.length < this.currentIndex + 1)
|
||||
this.currentIndex = 0;
|
||||
this.setUtoolsHeight(this.itemHeight * this.matchedItemsSize);
|
||||
}, this.options.options.placeholder);
|
||||
},
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ export function generateCode(flow) {
|
||||
// 获取变量赋值代码,如果变量已经存在,则直接赋值,否则声明并赋值
|
||||
const getVarAssignCode = (varName, varValue) => {
|
||||
if (usedVarNames.includes(varName)) {
|
||||
return `${varName} = ${varValue};`;
|
||||
return `${varName} = ${varValue}`;
|
||||
}
|
||||
usedVarNames.push(varName);
|
||||
if (!varValue) {
|
||||
return `let ${varName};`;
|
||||
return `let ${varName}`;
|
||||
}
|
||||
return `let ${varName} = ${varValue};`;
|
||||
return `let ${varName} = ${varValue}`;
|
||||
};
|
||||
|
||||
const getVarByPath = (name, path) => {
|
||||
@@ -36,10 +36,11 @@ export function generateCode(flow) {
|
||||
);
|
||||
|
||||
const indent = " ";
|
||||
const comma = ";";
|
||||
|
||||
// 局部变量赋值
|
||||
manualVars.forEach((v) => {
|
||||
code.push(indent + getVarAssignCode(v.name, v.value));
|
||||
code.push(indent + getVarAssignCode(v.name, v.value) + comma);
|
||||
});
|
||||
|
||||
commands.forEach((cmd) => {
|
||||
@@ -65,7 +66,7 @@ export function generateCode(flow) {
|
||||
const extractVarCode = Object.entries(details)
|
||||
.map(
|
||||
([path, varName]) =>
|
||||
`let ${varName} = ${getVarByPath(promiseName, path)}`
|
||||
`let ${varName} = ${getVarByPath(promiseName, path)};`
|
||||
)
|
||||
.join("\n");
|
||||
|
||||
@@ -80,20 +81,22 @@ export function generateCode(flow) {
|
||||
})`;
|
||||
}
|
||||
}
|
||||
code.push(indent + cmdCode);
|
||||
code.push(indent + cmdCode + comma);
|
||||
} else if (cmd.asyncMode === "await") {
|
||||
// 使用 await 模式
|
||||
const promiseName = name || "__result";
|
||||
cmdCode = getVarAssignCode(promiseName, `await ${cmdCode}`);
|
||||
code.push(indent + cmdCode);
|
||||
code.push(indent + cmdCode + comma);
|
||||
// 处理详细变量
|
||||
if (details) {
|
||||
Object.entries(details).forEach(([path, varName]) => {
|
||||
code.push(
|
||||
`${indent}${getVarAssignCode(
|
||||
varName,
|
||||
getVarByPath(promiseName, path)
|
||||
)}`
|
||||
indent +
|
||||
`${getVarAssignCode(
|
||||
varName,
|
||||
getVarByPath(promiseName, path)
|
||||
)}` +
|
||||
comma
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -101,15 +104,17 @@ export function generateCode(flow) {
|
||||
// 非Async命令
|
||||
const resultVarName = name || "__result";
|
||||
cmdCode = getVarAssignCode(resultVarName, `${cmdCode}`);
|
||||
code.push(indent + cmdCode);
|
||||
code.push(indent + cmdCode + comma);
|
||||
// 处理详细变量
|
||||
if (details) {
|
||||
Object.entries(details).forEach(([path, varName]) => {
|
||||
code.push(
|
||||
`${indent}${getVarAssignCode(
|
||||
varName,
|
||||
getVarByPath(resultVarName, path)
|
||||
)}`
|
||||
indent +
|
||||
`${getVarAssignCode(
|
||||
varName,
|
||||
getVarByPath(resultVarName, path)
|
||||
)}` +
|
||||
comma
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -119,11 +124,11 @@ export function generateCode(flow) {
|
||||
if (cmd.asyncMode === "await") {
|
||||
cmdCode = `await ${cmdCode}`;
|
||||
}
|
||||
code.push(indent + cmdCode);
|
||||
code.push(indent + cmdCode + comma);
|
||||
}
|
||||
});
|
||||
|
||||
code.push("}"); // Close the function
|
||||
code.push("};"); // Close the function
|
||||
|
||||
// 如果是主函数,则自动执行
|
||||
if (funcName === "main") {
|
||||
|
||||
@@ -323,6 +323,19 @@ export const ubrowserOperationConfigs = {
|
||||
},
|
||||
],
|
||||
},
|
||||
markdown: {
|
||||
value: "markdown",
|
||||
label: "转markdown",
|
||||
icon: "get_app",
|
||||
config: [
|
||||
{
|
||||
label: "CSS 或 XPath 选择器,不传递则转换整个网页内容",
|
||||
icon: "find_in_page",
|
||||
component: "VariableInput",
|
||||
width: 12,
|
||||
},
|
||||
],
|
||||
},
|
||||
setCookies: {
|
||||
value: "setCookies",
|
||||
label: "设置Cookie",
|
||||
|
||||
5
src/plugins/monaco/types/utools.api.d.ts
vendored
5
src/plugins/monaco/types/utools.api.d.ts
vendored
@@ -138,6 +138,11 @@ interface UBrowser {
|
||||
* 配合 when 使用
|
||||
*/
|
||||
end(): this;
|
||||
/**
|
||||
* 转为markdown
|
||||
* @param selector CSS 或 XPath 选择器,不传递则转换整个网页内容
|
||||
*/
|
||||
markdown(selector: string): this;
|
||||
/**
|
||||
* 单击元素
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user