mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
为各类命名添加默认输出
This commit is contained in:
parent
d3709db4b3
commit
b6bdb88fe9
@ -8,6 +8,8 @@ export const dataCommands = {
|
|||||||
label: "编解码",
|
label: "编解码",
|
||||||
desc: "文本编解码",
|
desc: "文本编解码",
|
||||||
icon: "code",
|
icon: "code",
|
||||||
|
outputVariable: "processedText",
|
||||||
|
saveOutput: true,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
label: "要编解码的文本",
|
label: "要编解码的文本",
|
||||||
@ -65,17 +67,23 @@ export const dataCommands = {
|
|||||||
value: "quickcomposer.data.symmetricCrypto",
|
value: "quickcomposer.data.symmetricCrypto",
|
||||||
label: "对称加解密",
|
label: "对称加解密",
|
||||||
component: "SymmetricCryptoEditor",
|
component: "SymmetricCryptoEditor",
|
||||||
|
outputVariable: "processedText",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.asymmetricCrypto",
|
value: "quickcomposer.data.asymmetricCrypto",
|
||||||
label: "非对称加解密",
|
label: "非对称加解密",
|
||||||
component: "AsymmetricCryptoEditor",
|
component: "AsymmetricCryptoEditor",
|
||||||
|
outputVariable: "processedText",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.md5Hash",
|
value: "quickcomposer.data.md5Hash",
|
||||||
label: "哈希计算",
|
label: "哈希计算",
|
||||||
desc: "计算文本的哈希值",
|
desc: "计算文本的哈希值",
|
||||||
icon: "enhanced_encryption",
|
icon: "enhanced_encryption",
|
||||||
|
outputVariable: "hashValue",
|
||||||
|
saveOutput: true,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
label: "要计算哈希的文本",
|
label: "要计算哈希的文本",
|
||||||
@ -115,10 +123,12 @@ export const dataCommands = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "Math",
|
value: "Math.sin",
|
||||||
label: "数学计算",
|
label: "数学计算",
|
||||||
desc: "数学函数计算",
|
desc: "数学函数计算",
|
||||||
icon: "calculate",
|
icon: "calculate",
|
||||||
|
outputVariable: "calculatedText",
|
||||||
|
saveOutput: true,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
label: "要计算的数值",
|
label: "要计算的数值",
|
||||||
@ -225,6 +235,8 @@ export const dataCommands = {
|
|||||||
width: 10,
|
width: 10,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
outputVariable: "randomNumber",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.reverseString",
|
value: "quickcomposer.data.reverseString",
|
||||||
@ -237,6 +249,8 @@ export const dataCommands = {
|
|||||||
icon: "swap_horiz",
|
icon: "swap_horiz",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
outputVariable: "reversedText",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.replaceString",
|
value: "quickcomposer.data.replaceString",
|
||||||
@ -264,6 +278,8 @@ export const dataCommands = {
|
|||||||
width: 4,
|
width: 4,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
outputVariable: "replacedText",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.substring",
|
value: "quickcomposer.data.substring",
|
||||||
@ -291,6 +307,8 @@ export const dataCommands = {
|
|||||||
width: 3,
|
width: 3,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
outputVariable: "substringText",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.regexTransform",
|
value: "quickcomposer.data.regexTransform",
|
||||||
@ -299,6 +317,8 @@ export const dataCommands = {
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
inputLabel: "要处理的文本",
|
inputLabel: "要处理的文本",
|
||||||
},
|
},
|
||||||
|
outputVariable: "processedText",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.data.buffer",
|
value: "quickcomposer.data.buffer",
|
||||||
|
@ -43,6 +43,8 @@ export const networkCommands = {
|
|||||||
component: "AxiosConfigEditor",
|
component: "AxiosConfigEditor",
|
||||||
isAsync: true,
|
isAsync: true,
|
||||||
icon: "http",
|
icon: "http",
|
||||||
|
outputVariable: "{data}",
|
||||||
|
saveOutput: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.network.url",
|
value: "quickcomposer.network.url",
|
||||||
|
@ -19,6 +19,8 @@ export const systemCommands = {
|
|||||||
value: "electron.clipboard.readText",
|
value: "electron.clipboard.readText",
|
||||||
label: "获取剪贴板内容",
|
label: "获取剪贴板内容",
|
||||||
config: [],
|
config: [],
|
||||||
|
outputVariable: "clipboardText",
|
||||||
|
saveOutput: true,
|
||||||
allowEmptyArgv: true,
|
allowEmptyArgv: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ export function processVariable({ value, existingVars }) {
|
|||||||
// 处理解构变量
|
// 处理解构变量
|
||||||
const processedVars = destructured.vars.map((name) => {
|
const processedVars = destructured.vars.map((name) => {
|
||||||
const parts = name.split(":").map((p) => p.trim());
|
const parts = name.split(":").map((p) => p.trim());
|
||||||
const key = parts.length > 1 ? parts[0] : parts[0];
|
const key = parts[0];
|
||||||
const varName = parts[parts.length - 1];
|
const varName = parts[parts.length - 1];
|
||||||
const processedName = generateValidVarName(varName, existingVars, varName);
|
const processedName = generateValidVarName(varName, existingVars, varName);
|
||||||
|
|
||||||
@ -114,13 +114,14 @@ export function processVariable({ value, existingVars }) {
|
|||||||
key,
|
key,
|
||||||
processedName,
|
processedName,
|
||||||
needsRename: processedName !== varName,
|
needsRename: processedName !== varName,
|
||||||
|
hasRename: parts.length > 1
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 如果有变量需要重命名,使用对象解构格式
|
// 如果有变量需要重命名,使用对象解构格式
|
||||||
if (processedVars.some((v) => v.needsRename)) {
|
if (processedVars.some((v) => v.needsRename)) {
|
||||||
const pairs = processedVars.map((v) =>
|
const pairs = processedVars.map((v) =>
|
||||||
v.needsRename ? `${v.key}:${v.processedName}` : v.key
|
v.needsRename || v.hasRename ? `${v.key}:${v.processedName}` : v.key
|
||||||
);
|
);
|
||||||
const format = `{${pairs.join(", ")}}`;
|
const format = `{${pairs.join(", ")}}`;
|
||||||
return {
|
return {
|
||||||
@ -134,7 +135,9 @@ export function processVariable({ value, existingVars }) {
|
|||||||
const format =
|
const format =
|
||||||
destructured.format === "array"
|
destructured.format === "array"
|
||||||
? `[${processedVars.map((v) => v.key).join(", ")}]`
|
? `[${processedVars.map((v) => v.key).join(", ")}]`
|
||||||
: `{${processedVars.map((v) => v.key).join(", ")}}`;
|
: `{${processedVars.map((v) =>
|
||||||
|
v.hasRename ? `${v.key}:${v.processedName}` : v.key
|
||||||
|
).join(", ")}}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isValid: true,
|
isValid: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user