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