diff --git a/plugin/lib/quickcomposer/textProcessing.js b/plugin/lib/quickcomposer/textProcessing.js index 03562a0..01032c5 100644 --- a/plugin/lib/quickcomposer/textProcessing.js +++ b/plugin/lib/quickcomposer/textProcessing.js @@ -103,10 +103,14 @@ const textProcessing = { substring: function (text, start, end) { return text.substring(start, end); }, - // 正则提取 - regexExtract: function (text, regex) { - const match = text.match(regex); - return match ? match[0] : ""; + // 正则处理 + regexTransform: function (text, regex, replace) { + try { + if (replace === undefined) return text.match(regex); + return text.replace(regex, replace); + } catch (e) { + throw "正则表达式格式错误"; + } }, // 非对称加解密 asymmetricCrypto: function (config) { diff --git a/src/components/composer/CommandComposer.vue b/src/components/composer/CommandComposer.vue index 20d4832..0d09c22 100644 --- a/src/components/composer/CommandComposer.vue +++ b/src/components/composer/CommandComposer.vue @@ -188,13 +188,12 @@ export default defineComponent({ /* 输入框标签字体大小,占位时的位置 */ .command-composer :deep(.q-field--filled .q-field__label) { font-size: 11px; - top: 50%; - transform: translateY(-50%); + top: 11px; } /* 输入框标签悬浮的位置 */ -.command-composer :deep(.q-field--filled.q-field--float .q-field__label) { - transform: translateY(-90%) scale(0.7); +.command-composer :deep(.q-field--filled .q-field--float .q_field__label) { + transform: translateY(-35%) scale(0.7); } /* 去除filled输入框边框 */ diff --git a/src/components/composer/ComposerCard.vue b/src/components/composer/ComposerCard.vue index 9c08e88..ad857d0 100644 --- a/src/components/composer/ComposerCard.vue +++ b/src/components/composer/ComposerCard.vue @@ -122,6 +122,7 @@ import AxiosConfigEditor from "components/composer/http/AxiosConfigEditor.vue"; import SymmetricCryptoEditor from "components/composer/crypto/SymmetricCryptoEditor.vue"; import AsymmetricCryptoEditor from "components/composer/crypto/AsymmetricCryptoEditor.vue"; import FunctionSelector from "components/composer/ui/FunctionSelector.vue"; +import RegexEditor from "components/composer/regex/RegexEditor.vue"; import { validateVariableName } from "js/common/variableValidator"; export default defineComponent({ @@ -135,6 +136,7 @@ export default defineComponent({ SymmetricCryptoEditor, AsymmetricCryptoEditor, FunctionSelector, + RegexEditor, }, props: { command: { @@ -321,6 +323,7 @@ export default defineComponent({ .command-item:hover { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + transition: all 0.3s ease; } /* 拖拽和放置样式 */ @@ -424,34 +427,31 @@ export default defineComponent({ } /* 暗色模式适配 */ -.body--dark { - .command-item { - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); - border: 1px solid rgba(255, 255, 255, 0.1); - } +.body--dark .command-item { + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); +} - .command-item:hover { - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); - } +.body--dark .command-item:hover { + box-shadow: 0 4px 8px rgba(58, 58, 58, 0.3); +} - .can-drop { - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); - } +.body--dark .can-drop { + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); +} - .output-section :deep(.q-field) { - background: rgba(255, 255, 255, 0.03); - } +.body--dark .output-section :deep(.q-field) { + background: rgba(255, 255, 255, 0.03); +} - .output-section :deep(.q-field--focused) { - background: #1d1d1d; - } +.body--dark .output-section :deep(.q-field--focused) { + background: #1d1d1d; +} - .output-btn { - border-color: rgba(255, 255, 255, 0.1); - } +.body--dark .output-btn { + border-color: rgba(255, 255, 255, 0.1); +} - .output-btn:hover { - background: rgba(255, 255, 255, 0.05); - } +.body--dark .output-btn:hover { + background: rgba(255, 255, 255, 0.05); } diff --git a/src/components/composer/crypto/AsymmetricCryptoEditor.vue b/src/components/composer/crypto/AsymmetricCryptoEditor.vue index 7141da5..845024b 100644 --- a/src/components/composer/crypto/AsymmetricCryptoEditor.vue +++ b/src/components/composer/crypto/AsymmetricCryptoEditor.vue @@ -198,9 +198,14 @@ export default defineComponent({ ], }; }, + props: { + command: { + type: Object, + }, + }, methods: { updateConfig() { - const code = `quickcomposer.textProcessing.asymmetricCrypto(${formatJsonVariables( + const code = `${this.command.value}(${formatJsonVariables( { text: this.text, algorithm: this.algorithm, diff --git a/src/components/composer/crypto/SymmetricCryptoEditor.vue b/src/components/composer/crypto/SymmetricCryptoEditor.vue index 9caeb1d..4ce84a2 100644 --- a/src/components/composer/crypto/SymmetricCryptoEditor.vue +++ b/src/components/composer/crypto/SymmetricCryptoEditor.vue @@ -164,6 +164,9 @@ export default defineComponent({ type: [String, Object], default: "", }, + command: { + type: Object, + }, }, data() { return { @@ -243,7 +246,7 @@ export default defineComponent({ }, methods: { updateConfig() { - const code = `quickcomposer.textProcessing.symmetricCrypto(${formatJsonVariables( + const code = `${this.command.value}(${formatJsonVariables( { text: this.text, algorithm: this.algorithm, diff --git a/src/components/composer/http/AxiosConfigEditor.vue b/src/components/composer/http/AxiosConfigEditor.vue index 519c38a..5bcad79 100644 --- a/src/components/composer/http/AxiosConfigEditor.vue +++ b/src/components/composer/http/AxiosConfigEditor.vue @@ -240,6 +240,9 @@ export default defineComponent({ type: [Object, String], default: () => ({}), }, + command: { + type: Object, + }, }, emits: ["update:modelValue"], data() { @@ -316,9 +319,9 @@ export default defineComponent({ ? `, ${formatJsonVariables(restConfig, null, excludeFields)}` : ""; - const code = `axios.${method.toLowerCase()}(${url}${ + const code = `${this.command.value}(${url}${ this.hasRequestData ? `, ${formatJsonVariables(data)}` : "" - }${configStr})?.data`; + }${configStr})`; this.$emit("update:modelValue", code); }, @@ -344,7 +347,7 @@ export default defineComponent({ deep: true, handler(newValue) { if (typeof newValue === "string") { - // 如果是字符串,明是编辑现有的配置 + // 如果是字符串,说明是编辑现有的配置 try { const config = JSON.parse(newValue); this.localConfig = { diff --git a/src/components/composer/regex/RegexBuilder.vue b/src/components/composer/regex/RegexBuilder.vue new file mode 100644 index 0000000..09fa436 --- /dev/null +++ b/src/components/composer/regex/RegexBuilder.vue @@ -0,0 +1,520 @@ + + + + + diff --git a/src/components/composer/regex/RegexEditor.vue b/src/components/composer/regex/RegexEditor.vue new file mode 100644 index 0000000..094990b --- /dev/null +++ b/src/components/composer/regex/RegexEditor.vue @@ -0,0 +1,273 @@ + + + + + diff --git a/src/components/composer/regex/RegexInput.vue b/src/components/composer/regex/RegexInput.vue new file mode 100644 index 0000000..1e5cdff --- /dev/null +++ b/src/components/composer/regex/RegexInput.vue @@ -0,0 +1,786 @@ + + + + + diff --git a/src/components/composer/regex/RegexTester.vue b/src/components/composer/regex/RegexTester.vue new file mode 100644 index 0000000..f317135 --- /dev/null +++ b/src/components/composer/regex/RegexTester.vue @@ -0,0 +1,218 @@ + + + + + diff --git a/src/components/composer/ubrowser/operations/UBrowserFunctionInput.vue b/src/components/composer/ubrowser/operations/UBrowserFunctionInput.vue index 4afe418..7e8d5af 100644 --- a/src/components/composer/ubrowser/operations/UBrowserFunctionInput.vue +++ b/src/components/composer/ubrowser/operations/UBrowserFunctionInput.vue @@ -35,7 +35,7 @@ type="textarea" dense borderless - style="font-family: monospace, monoca, consola" + style="font-family: Consolas, Monaco, 'Courier New'" autogrow @update:model-value="updateFunction" > diff --git a/src/components/composer/ui/KeyEditor.vue b/src/components/composer/ui/KeyEditor.vue index 78080d8..0be721a 100644 --- a/src/components/composer/ui/KeyEditor.vue +++ b/src/components/composer/ui/KeyEditor.vue @@ -121,6 +121,11 @@ export default defineComponent({ ], }; }, + props: { + command: { + type: Object, + }, + }, computed: { mainKeyDisplay() { if (!this.mainKey) return ""; @@ -272,7 +277,7 @@ export default defineComponent({ const args = [this.mainKey, ...activeModifiers]; // 为每个参数添加引号 - this.$emit("update:modelValue", `keyTap("${args.join('","')}")`); + this.$emit("update:modelValue", `${this.command.value}("${args.join('","')}")`); }, parseKeyString(val) { try { diff --git a/src/components/composer/ui/MultiParamInput.vue b/src/components/composer/ui/MultiParamInput.vue index c625d54..5436eb3 100644 --- a/src/components/composer/ui/MultiParamInput.vue +++ b/src/components/composer/ui/MultiParamInput.vue @@ -54,7 +54,7 @@ export default defineComponent({ .filter((val) => val !== undefined && val !== "") .join(","); - this.$emit("update:modelValue", argv); + this.$emit("update:modelValue", `${this.command.value}(${argv})`); }, }, }); diff --git a/src/js/composer/commands/textProcessingCommands.js b/src/js/composer/commands/textProcessingCommands.js index ce496da..aaa62ac 100644 --- a/src/js/composer/commands/textProcessingCommands.js +++ b/src/js/composer/commands/textProcessingCommands.js @@ -144,24 +144,12 @@ export const textProcessingCommands = { ], }, { - value: "quickcomposer.textProcessing.regexExtract", - label: "正则提取", - config: [ - { - key: "text", - label: "原始文本", - type: "input", - defaultValue: "", - icon: "text_fields", - }, - { - key: "regex", - label: "正则表达式", - type: "input", - defaultValue: "", - icon: "regex", - }, - ], + value: "quickcomposer.textProcessing.regexTransform", + label: "正则提取/替换", + component: "RegexEditor", + componentProps: { + inputLabel: "要处理的文本", + }, }, ], }; diff --git a/src/js/composer/generateCode.js b/src/js/composer/generateCode.js index a9631bd..c266636 100644 --- a/src/js/composer/generateCode.js +++ b/src/js/composer/generateCode.js @@ -13,7 +13,7 @@ export function generateCode(commandFlow) { } let awaitCmd = cmd.isAsync ? "await " : ""; - line += `${awaitCmd}${cmd.value}(${cmd.argv})`; + line += `${awaitCmd} ${cmd.argv}`; code.push(line); });