diff --git a/plugin/lib/quickcomposer/audio/media.js b/plugin/lib/quickcomposer/audio/media.js index dd4c0d1..bb0952c 100644 --- a/plugin/lib/quickcomposer/audio/media.js +++ b/plugin/lib/quickcomposer/audio/media.js @@ -7,27 +7,27 @@ let currentAudio = null; // 系统音效映射 const SYSTEM_SOUNDS = { beep: { - win: "Beep", + win: "Windows Ding", mac: "Ping.aiff", }, error: { - win: "Asterisk", + win: "Windows Critical Stop", mac: "Basso.aiff", }, warning: { - win: "Exclamation", + win: "Windows Exclamation", mac: "Sosumi.aiff", }, notification: { - win: "Notification", + win: "Windows Notify", mac: "Glass.aiff", }, complete: { - win: "SystemAsterisk", + win: "Windows Print complete", mac: "Hero.aiff", }, click: { - win: "MenuCommand", + win: "Windows Navigation Start", mac: "Tink.aiff", }, }; @@ -40,7 +40,7 @@ const SYSTEM_SOUNDS = { * @param {boolean} autoplay 是否自动播放 */ async function play(file, volume = 1, loop = false, autoplay = true) { - // 停止当前音频 + // 先停止当前音频 stop(); // 检查文件是否存在 @@ -50,6 +50,8 @@ async function play(file, volume = 1, loop = false, autoplay = true) { // 创建新的音频实例 const audio = new Audio(); + + // 设置音频属性 audio.src = `file://${file}`; audio.volume = parseFloat(volume) || 1; audio.loop = !!loop; @@ -59,22 +61,33 @@ async function play(file, volume = 1, loop = false, autoplay = true) { // 如果设置了自动播放 if (autoplay !== false) { - audio.play(); + try { + await audio.play(); + } catch (error) { + console.warn("播放失败:", error); + currentAudio = null; + throw error; + } } - // 返回 Promise,在播放结束时 resolve - return new Promise((resolve, reject) => { - audio.onended = () => { - if (!audio.loop) { - currentAudio = null; - resolve(); - } - }; - audio.onerror = (error) => { + // 立即返回,不等待播放完成 + return Promise.resolve(); +} + +/** + * 停止音频播放 + */ +function stop() { + if (currentAudio) { + try { + currentAudio.pause(); + currentAudio.currentTime = 0; + } catch (error) { + console.warn("停止播放时发生错误:", error); + } finally { currentAudio = null; - reject(error); - }; - }); + } + } } /** @@ -86,8 +99,8 @@ async function beep(type = "beep", volume = 1) { // 在 Windows 上使用 PowerShell 播放系统音效 if (process.platform === "win32") { const soundName = SYSTEM_SOUNDS[type]?.win || SYSTEM_SOUNDS.beep.win; - // 使用系统音效 - const script = `[System.Media.SystemSounds]::${soundName}.Play()`; + // 使用 PowerShell 播放 Windows 系统音效 + const script = `(New-Object System.Media.SoundPlayer "C:\\Windows\\Media\\${soundName}.wav").PlaySync()`; return new Promise((resolve, reject) => { const ps = spawn("powershell", ["-Command", script]); @@ -120,17 +133,6 @@ async function beep(type = "beep", volume = 1) { } } -/** - * 停止音频播放 - */ -function stop() { - if (currentAudio) { - currentAudio.pause(); - currentAudio.currentTime = 0; - currentAudio = null; - } -} - /** * 分析音频文件 * @param {string} file 音频文件路径 diff --git a/plugin/lib/quickcomposer/math/basic.js b/plugin/lib/quickcomposer/math/basic.js index 8e642cf..0e933d0 100644 --- a/plugin/lib/quickcomposer/math/basic.js +++ b/plugin/lib/quickcomposer/math/basic.js @@ -5,7 +5,7 @@ */ function evaluate(expression) { // 移除所有空白字符 - expression = expression.replace(/\s+/g, ""); + expression = expression.toString().replace(/\s+/g, ""); // 检查表达式是否为空 if (!expression) { @@ -31,20 +31,87 @@ function evaluate(expression) { } try { + // 将表达式中的数字转换为整数计算,使用固定精度 + const scale = Math.pow(10, 15); // 使用固定的15位精度 + const processedExpression = expression.replace(/\d*\.?\d+/g, (match) => { + const num = parseFloat(match); + return Math.round(num * scale); + }); + // 使用 Function 构造函数创建一个安全的计算环境 - const result = new Function(`return ${expression}`)(); + const result = new Function(`return ${processedExpression}`)(); // 检查结果是否为有限数 if (!Number.isFinite(result)) { throw new Error("计算结果无效"); } - return result; + // 还原小数位数 + return result / scale; } catch (error) { throw new Error("表达式计算错误: " + error.message); } } +/** + * 处理两个数的加法,避免浮点数精度问题 + * @param {number} a 第一个数 + * @param {number} b 第二个数 + * @returns {number} 计算结果 + */ +function add(a, b) { + const precision = Math.max( + (a.toString().split(".")[1] || "").length, + (b.toString().split(".")[1] || "").length + ); + const scale = Math.pow(10, precision); + return (Math.round(a * scale) + Math.round(b * scale)) / scale; +} + +/** + * 处理两个数的减法,避免浮点数精度问题 + * @param {number} a 第一个数 + * @param {number} b 第二个数 + * @returns {number} 计算结果 + */ +function subtract(a, b) { + const precision = Math.max( + (a.toString().split(".")[1] || "").length, + (b.toString().split(".")[1] || "").length + ); + const scale = Math.pow(10, precision); + return (Math.round(a * scale) - Math.round(b * scale)) / scale; +} + +/** + * 处理两个数的乘法,避免浮点数精度问题 + * @param {number} a 第一个数 + * @param {number} b 第二个数 + * @returns {number} 计算结果 + */ +function multiply(a, b) { + const precision = + (a.toString().split(".")[1] || "").length + + (b.toString().split(".")[1] || "").length; + const scale = Math.pow(10, precision); + return (Math.round(a * scale) * Math.round(b * scale)) / (scale * scale); +} + +/** + * 处理两个数的除法,避免浮点数精度问题 + * @param {number} a 第一个数 + * @param {number} b 第二个数 + * @param {number} [precision=10] 精度 + * @returns {number} 计算结果 + */ +function divide(a, b, precision = 10) { + if (b === 0) { + throw new Error("除数不能为零"); + } + const scale = Math.pow(10, precision); + return Math.round(a * scale) / Math.round(b * scale); +} + /** * 计算阶乘 * @param {number} n 非负整数 @@ -74,7 +141,11 @@ function factorial(n) { * @returns {number} 绝对值 */ function abs(x) { - return Math.abs(x); + // 将数字转换为整数计算,使用固定精度 + const scale = Math.pow(10, 15); // 使用固定的15位精度 + const num = parseFloat(x.toString()); + const result = Math.abs(Math.round(num * scale)); + return result / scale; } /** diff --git a/src/components/composer/MultiParams.vue b/src/components/composer/MultiParams.vue index 2eed4d2..20281f0 100644 --- a/src/components/composer/MultiParams.vue +++ b/src/components/composer/MultiParams.vue @@ -52,7 +52,7 @@ export default defineComponent({ localConfig() { return [...this.commonConfig, ...this.subCommandConfig].map((item) => { const value = - item.type === "varInput" + item.component === "VariableInput" ? item.defaultValue || newVarInputVal("str") : // 其他类型情况复杂,不做判断,没有默认值返回undefined item.defaultValue; @@ -147,15 +147,27 @@ export default defineComponent({ if (!code) return argvs; const variableFormatPaths = []; + + const addVariableFormatPath = (prefix, config) => { + if (config.component === "VariableInput") { + variableFormatPaths.push(prefix); + } else if (config.component === "ArrayEditor") { + variableFormatPaths.push(`${prefix}[*]`); + } else if (config.component === "DictEditor") { + variableFormatPaths.push(`${prefix}.**`); + } + }; + this.localConfig.forEach((item, index) => { - if (item.type === "varInput") { - variableFormatPaths.push(`arg${index}`); - } else if (item.type === "arrayEditor") { - variableFormatPaths.push(`arg${index}[*]`); - } else if (item.type === "dictEditor") { - variableFormatPaths.push(`arg${index}.**`); + if (item.component === "OptionEditor") { + Object.entries(item.options).forEach(([key, config]) => { + addVariableFormatPath(`arg${index}.${key}`, config); + }); + } else { + addVariableFormatPath(`arg${index}`, item); } }); + try { argvs = parseFunction(code, { variableFormatPaths }).argvs; } catch (e) { diff --git a/src/components/composer/common/ArrayEditor.vue b/src/components/composer/common/ArrayEditor.vue index d5e27c8..a5f65c1 100644 --- a/src/components/composer/common/ArrayEditor.vue +++ b/src/components/composer/common/ArrayEditor.vue @@ -22,6 +22,7 @@ :no-icon="true" :placeholder="key.placeholder" :options="key.options" + :disable-toggle-type="key.disableToggleType" @update:model-value=" (val) => updateItemKeyValue(index, key.value, val) " @@ -38,6 +39,7 @@ :options="{ items: options.items, }" + :disable-toggle-type="disableToggleType" @update:model-value="(val) => updateItemValue(index, val)" /> @@ -186,6 +188,10 @@ export default defineComponent({ type: String, default: "", }, + disableToggleType: { + type: Boolean, + default: false, + }, }, emits: ["update:modelValue"], computed: { diff --git a/src/components/composer/common/NumberInput.vue b/src/components/composer/common/NumberInput.vue index c917771..8583c76 100644 --- a/src/components/composer/common/NumberInput.vue +++ b/src/components/composer/common/NumberInput.vue @@ -103,7 +103,7 @@ export default defineComponent({ }, methods: { updateNumber(delta) { - const newValue = (this.localValue || 0) + delta; + const newValue = +((this.localValue || 0) + delta).toFixed(10); if (newValue > this.max) { this.$emit("update:modelValue", this.max); } else if (newValue < this.min) { diff --git a/src/components/composer/common/OptionEditor.vue b/src/components/composer/common/OptionEditor.vue new file mode 100644 index 0000000..77357a4 --- /dev/null +++ b/src/components/composer/common/OptionEditor.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/src/components/composer/common/ParamInput.vue b/src/components/composer/common/ParamInput.vue index dbcbe05..b733f7d 100644 --- a/src/components/composer/common/ParamInput.vue +++ b/src/components/composer/common/ParamInput.vue @@ -6,86 +6,20 @@ class="grid-item" :style="getColumnStyle(config.width)" > - - - - - - - - @@ -99,6 +33,7 @@ import DictEditor from "./DictEditor.vue"; import ButtonGroup from "./ButtonGroup.vue"; import ControlInput from "./ControlInput.vue"; import CheckGroup from "./CheckGroup.vue"; +import OptionEditor from "./OptionEditor.vue"; /** * 参数输入组件 @@ -121,6 +56,7 @@ export default defineComponent({ ButtonGroup, ControlInput, CheckGroup, + OptionEditor, }, props: { configs: { @@ -147,6 +83,9 @@ export default defineComponent({ flex: "0 0 auto", }; }, + shouldShowQIcon(config) { + return ["q-input", "q-select"].includes(config.component) && config.icon; + }, }, }); diff --git a/src/components/composer/common/VariableInput.vue b/src/components/composer/common/VariableInput.vue index 76513ca..6b64104 100644 --- a/src/components/composer/common/VariableInput.vue +++ b/src/components/composer/common/VariableInput.vue @@ -30,8 +30,9 @@ > {{ isString - ? "当前类型是:字符串,点击切换" - : "当前类型是:变量、数字、表达式等,点击切换" + ? "当前类型是:字符串" + : "当前类型是:变量、数字、表达式等" + + (disableToggleType ? "" : ",点击切换") }} @@ -222,6 +223,10 @@ export default defineComponent({ type: Object, default: () => ({}), }, + disableToggleType: { + type: Boolean, + default: false, + }, }, emits: ["update:modelValue"], @@ -308,6 +313,7 @@ export default defineComponent({ // 切换类型 toggleType() { + if (this.disableToggleType) return; this.$emit("update:modelValue", { ...this.modelValue, isString: !this.modelValue.isString, diff --git a/src/js/composer/commands/audioCommands.js b/src/js/composer/commands/audioCommands.js index 7f9a9cd..3a5ba17 100644 --- a/src/js/composer/commands/audioCommands.js +++ b/src/js/composer/commands/audioCommands.js @@ -10,26 +10,91 @@ const SYSTEM_SOUNDS = [ { label: "点击音", value: "click" }, ]; +const LANGUAGES = [ + { label: "中文", value: "zh-CN" }, + { label: "英文", value: "en-US" }, + { label: "日语", value: "ja-JP" }, + { label: "韩语", value: "ko-KR" }, + { label: "法语", value: "fr-FR" }, + { label: "德语", value: "de-DE" }, + { label: "西班牙语", value: "es-ES" }, +]; + // 语音朗读配置 const SPEECH_CONFIG = { label: "朗读配置", - type: "dictEditor", + component: "OptionEditor", icon: "settings", width: 12, defaultValue: { - rate: newVarInputVal("var", "1"), - pitch: newVarInputVal("var", "1"), - volume: newVarInputVal("var", "1"), - lang: newVarInputVal("str", "zh-CN"), + rate: 0.5, + pitch: 1, + volume: 1, + lang: "zh-CN", }, options: { - fixedKeys: [ - { value: "rate", label: "语速(0.1-10)" }, - { value: "pitch", label: "音调(0-2)" }, - { value: "volume", label: "音量(0-1)" }, - { value: "lang", label: "语言" }, - ], - disableAdd: true, + rate: { + label: "语速(0.1-10)", + component: "NumberInput", + min: 0, + max: 10, + step: 0.1, + width: 3, + }, + pitch: { + label: "音调(0-2)", + component: "NumberInput", + min: 0, + max: 2, + step: 0.1, + width: 3, + }, + volume: { + label: "音量(0-1)", + component: "NumberInput", + min: 0, + max: 1, + step: 0.1, + width: 3, + }, + lang: { + label: "语言", + component: "q-select", + options: LANGUAGES, + width: 3, + }, + }, +}; + +const MEDIA_PLAY_CONFIG = { + label: "播放配置", + component: "OptionEditor", + icon: "settings", + width: 12, + defaultValue: { + volume: 1, + loop: false, + autoPlay: true, + }, + options: { + volume: { + label: "音量", + component: "NumberInput", + min: 0, + max: 1, + step: 0.1, + width: 4, + }, + loop: { + label: "循环播放", + component: "q-toggle", + width: 4, + }, + autoPlay: { + label: "自动播放", + component: "q-toggle", + width: 4, + }, }, }; @@ -51,7 +116,7 @@ export const audioCommands = { config: [ { label: "朗读文本", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: 12, }, @@ -70,6 +135,7 @@ export const audioCommands = { label: "音频播放", desc: "播放音频文件", icon: "music_note", + isAsync: true, subCommands: [ { value: "quickcomposer.audio.media.play", @@ -78,7 +144,7 @@ export const audioCommands = { config: [ { label: "音频文件路径", - type: "varInput", + component: "VariableInput", icon: "audio_file", width: 12, options: { @@ -97,30 +163,7 @@ export const audioCommands = { }, }, }, - { - label: "音量", - type: "numInput", - icon: "volume_up", - width: 4, - defaultValue: 1, - min: 0, - max: 1, - step: 0.1, - }, - { - label: "循环播放", - type: "switch", - icon: "repeat", - width: 4, - defaultValue: false, - }, - { - label: "自动播放", - type: "switch", - icon: "play_circle", - width: 4, - defaultValue: true, - }, + MEDIA_PLAY_CONFIG, ], }, { @@ -135,10 +178,11 @@ export const audioCommands = { label: "音频录制", desc: "录制系统音频", icon: "mic", + isAsync: true, config: [ { label: "录制时长(ms)", - type: "numInput", + component: "NumberInput", icon: "timer", width: 6, defaultValue: 5000, @@ -147,7 +191,7 @@ export const audioCommands = { }, { label: "保存路径", - type: "varInput", + component: "VariableInput", icon: "save", width: 6, options: { @@ -171,11 +215,12 @@ export const audioCommands = { value: "quickcomposer.audio.media.beep", label: "系统音效", desc: "播放系统内置音效", + isAsync: true, icon: "notifications_active", config: [ { label: "音效类型", - type: "select", + component: "q-select", icon: "music_note", width: 6, options: SYSTEM_SOUNDS, @@ -183,7 +228,7 @@ export const audioCommands = { }, { label: "音量", - type: "numInput", + component: "NumberInput", icon: "volume_up", width: 6, defaultValue: 1, @@ -202,7 +247,7 @@ export const audioCommands = { config: [ { label: "音频文件", - type: "varInput", + component: "VariableInput", icon: "audio_file", width: 12, options: { diff --git a/src/js/composer/commands/codingCommand.js b/src/js/composer/commands/codingCommand.js index f75a782..b020706 100644 --- a/src/js/composer/commands/codingCommand.js +++ b/src/js/composer/commands/codingCommand.js @@ -14,7 +14,7 @@ export const codingCommands = { { label: "要编解码的文本", icon: "text_fields", - type: "varInput", + component: "VariableInput", }, ], subCommands: [ @@ -85,7 +85,7 @@ export const codingCommands = { { label: "要计算哈希的文本", icon: "text_fields", - type: "varInput", + component: "VariableInput", }, ], subCommands: [ diff --git a/src/js/composer/commands/controlCommands.js b/src/js/composer/commands/controlCommands.js index 191f532..e54730f 100644 --- a/src/js/composer/commands/controlCommands.js +++ b/src/js/composer/commands/controlCommands.js @@ -17,7 +17,7 @@ export const controlCommands = { { key: "condition", label: "条件", - type: "controlInput", + component: "ControlInput", placeholder: "表达式", defaultValue: "true", }, @@ -38,7 +38,7 @@ export const controlCommands = { { key: "condition", label: "条件", - type: "controlInput", + component: "ControlInput", placeholder: "表达式", }, ], @@ -67,14 +67,14 @@ export const controlCommands = { { key: "indexVar", label: "变量", - type: "controlInput", + component: "ControlInput", defaultValue: "i", width: 3, }, { key: "startValue", label: "从", - type: "controlInput", + component: "ControlInput", icon: "first_page", defaultValue: "0", width: 3, @@ -82,7 +82,7 @@ export const controlCommands = { { key: "endValue", label: "到", - type: "controlInput", + component: "ControlInput", icon: "last_page", defaultValue: "10", width: 3, @@ -90,7 +90,7 @@ export const controlCommands = { { key: "stepValue", label: "步进", - type: "controlInput", + component: "ControlInput", icon: "trending_up", defaultValue: "1", width: 3, @@ -133,21 +133,21 @@ export const controlCommands = { { key: "itemVar", label: "元素", - type: "controlInput", + component: "ControlInput", defaultValue: "item", width: 4, }, { key: "indexVar", label: "索引", - type: "controlInput", + component: "ControlInput", defaultValue: "i", width: 4, }, { key: "arrayVar", label: "数组", - type: "controlInput", + component: "ControlInput", icon: "list", defaultValue: "array", width: 4, @@ -190,21 +190,21 @@ export const controlCommands = { { key: "keyVar", label: "键名", - type: "controlInput", + component: "ControlInput", defaultValue: "key", width: 4, }, { key: "valueVar", label: "值", - type: "controlInput", + component: "ControlInput", defaultValue: "value", width: 4, }, { key: "objectVar", label: "对象", - type: "controlInput", + component: "ControlInput", defaultValue: "object", width: 4, }, @@ -245,7 +245,7 @@ export const controlCommands = { { key: "condition", label: "条件", - type: "controlInput", + component: "ControlInput", placeholder: "表达式", defaultValue: "true", }, @@ -286,7 +286,7 @@ export const controlCommands = { { key: "expression", label: "变量", - type: "controlInput", + component: "ControlInput", placeholder: "变量或表达式", defaultValue: "expression", }, @@ -301,7 +301,7 @@ export const controlCommands = { { key: "value", label: "值", - type: "controlInput", + component: "ControlInput", }, ], }, @@ -340,7 +340,7 @@ export const controlCommands = { { key: "errorVar", label: "错误", - type: "controlInput", + component: "ControlInput", defaultValue: "error", }, ], diff --git a/src/js/composer/commands/dataCommands.js b/src/js/composer/commands/dataCommands.js index 22597d3..98922fd 100644 --- a/src/js/composer/commands/dataCommands.js +++ b/src/js/composer/commands/dataCommands.js @@ -12,7 +12,7 @@ export const dataCommands = { { key: "text", label: "要反转的文本", - type: "varInput", + component: "VariableInput", icon: "swap_horiz", }, ], @@ -26,21 +26,21 @@ export const dataCommands = { { key: "text", label: "原始文本", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: 4, }, { key: "oldStr", label: "要替换的文本", - type: "varInput", + component: "VariableInput", icon: "find_replace", width: 4, }, { key: "newStr", label: "替换为", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: 4, }, @@ -55,14 +55,14 @@ export const dataCommands = { { key: "text", label: "原始文本", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: 6, }, { key: "start", label: "起始位置", - type: "numInput", + component: "NumberInput", min: 0, step: 1, icon: "first_page", @@ -71,7 +71,7 @@ export const dataCommands = { { key: "end", label: "结束位置", - type: "numInput", + component: "NumberInput", icon: "last_page", min: 0, step: 1, @@ -105,13 +105,13 @@ export const dataCommands = { config: [ { label: "数据", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: 9, }, { label: "编码", - type: "select", + component: "q-select", icon: "code", options: [ { label: "UTF-8", value: "utf8" }, @@ -135,13 +135,13 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "varInput", + component: "VariableInput", icon: "memory", width: 12, }, { label: "编码", - type: "select", + component: "q-select", icon: "code", options: [ { label: "UTF-8", value: "utf8" }, @@ -158,14 +158,14 @@ export const dataCommands = { }, { label: "起始位置", - type: "numInput", + component: "NumberInput", step: 1, icon: "first_page", width: 4, }, { label: "结束位置", - type: "numInput", + component: "NumberInput", icon: "last_page", step: 1, width: 4, @@ -179,31 +179,31 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "varInput", + component: "VariableInput", icon: "memory", width: 6, }, { label: "要写入的字符串", - type: "varInput", + component: "VariableInput", icon: "edit", width: 6, }, { label: "偏移量", - type: "numInput", + component: "NumberInput", icon: "first_page", width: 4, }, { label: "长度", - type: "numInput", + component: "NumberInput", icon: "straighten", width: 4, }, { label: "编码", - type: "select", + component: "q-select", icon: "code", options: [ { label: "UTF-8", value: "utf8" }, @@ -227,31 +227,31 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "varInput", + component: "VariableInput", icon: "memory", width: 6, }, { label: "填充值", - type: "varInput", + component: "VariableInput", icon: "format_color_fill", width: 6, }, { label: "起始位置", - type: "numInput", + component: "NumberInput", icon: "first_page", width: 4, }, { label: "结束位置", - type: "numInput", + component: "NumberInput", icon: "last_page", width: 4, }, { label: "编码", - type: "select", + component: "q-select", icon: "code", options: [ { label: "UTF-8", value: "utf8" }, @@ -275,31 +275,31 @@ export const dataCommands = { config: [ { label: "源Buffer", - type: "varInput", + component: "VariableInput", icon: "content_copy", width: 6, }, { label: "目标Buffer", - type: "varInput", + component: "VariableInput", icon: "save", width: 6, }, { label: "目标起始位置", - type: "numInput", + component: "NumberInput", icon: "first_page", width: 4, }, { label: "源起始位置", - type: "numInput", + component: "NumberInput", icon: "first_page", width: 4, }, { label: "源结束位置", - type: "numInput", + component: "NumberInput", icon: "last_page", width: 4, }, @@ -312,13 +312,13 @@ export const dataCommands = { config: [ { label: "Buffer 1", - type: "varInput", + component: "VariableInput", icon: "memory", width: 6, }, { label: "Buffer 2", - type: "varInput", + component: "VariableInput", icon: "memory", width: 6, }, @@ -331,14 +331,15 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "arrayEditor", + component: "ArrayEditor", icon: "memory", width: 12, defaultValue: [newVarInputVal("var")], + disableToggleType: true, }, { label: "总长度(可选)", - type: "numInput", + component: "NumberInput", icon: "straighten", width: 12, }, @@ -351,19 +352,19 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "varInput", + component: "VariableInput", icon: "memory", width: 12, }, { label: "起始位置", - type: "numInput", + component: "NumberInput", icon: "first_page", width: 6, }, { label: "结束位置", - type: "numInput", + component: "NumberInput", icon: "last_page", width: 6, }, @@ -376,25 +377,25 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "varInput", + component: "VariableInput", icon: "memory", width: 12, }, { label: "要查找的值", - type: "varInput", + component: "VariableInput", icon: "search", width: 4, }, { label: "起始位置", - type: "numInput", + component: "NumberInput", icon: "first_page", width: 4, }, { label: "编码", - type: "select", + component: "q-select", icon: "code", options: [ { label: "UTF-8", value: "utf8" }, @@ -418,13 +419,13 @@ export const dataCommands = { config: [ { label: "Buffer", - type: "varInput", + component: "VariableInput", icon: "memory", width: 9, }, { label: "字节大小", - type: "select", + component: "q-select", icon: "memory", options: [ { label: "16位", value: 16 }, @@ -454,21 +455,21 @@ export const dataCommands = { config: [ { label: "要解析的 HTML", - type: "varInput", + component: "VariableInput", icon: "html", placeholder: "例如:
Hello, World!
", width: 12, }, { label: "CSS选择器", - type: "varInput", + component: "VariableInput", icon: "css", placeholder: "例如:.class", width: 7, }, { label: "属性", - type: "varInput", + component: "VariableInput", icon: "colorize", options: { items: [ diff --git a/src/js/composer/commands/fileCommands.js b/src/js/composer/commands/fileCommands.js index b4a35d4..d4659f8 100644 --- a/src/js/composer/commands/fileCommands.js +++ b/src/js/composer/commands/fileCommands.js @@ -17,7 +17,7 @@ export const fileCommands = { { key: "path", label: "文件、文件夹或软件的绝对路径", - type: "varInput", + component: "VariableInput", icon: "folder_open", options: { dialog: { @@ -35,7 +35,7 @@ export const fileCommands = { { key: "path", label: "文件、文件夹或软件的绝对路径", - type: "varInput", + component: "VariableInput", icon: "location_on", options: { dialog: { @@ -53,7 +53,7 @@ export const fileCommands = { { key: "path", label: "文件或软件的绝对路径", - type: "varInput", + component: "VariableInput", icon: "folder_open", options: { dialog: { @@ -77,7 +77,7 @@ export const fileCommands = { { key: "operation", label: "操作类型", - type: "select", + component: "q-select", icon: "settings", width: 6, defaultValue: "compress", @@ -89,7 +89,7 @@ export const fileCommands = { { key: "format", label: "归档格式", - type: "select", + component: "q-select", icon: "format_shapes", width: 6, defaultValue: "zip", @@ -102,7 +102,7 @@ export const fileCommands = { { key: "source", label: "源文件/文件夹", - type: "varInput", + component: "VariableInput", icon: "folder_open", width: 12, options: { @@ -117,7 +117,7 @@ export const fileCommands = { { key: "destination", label: "目标路径", - type: "varInput", + component: "VariableInput", icon: "save", width: 12, options: { @@ -137,7 +137,7 @@ export const fileCommands = { { key: "path", label: "文件或文件夹的绝对路径", - type: "varInput", + component: "VariableInput", icon: "folder_open", options: { dialog: { diff --git a/src/js/composer/commands/imageCommands.js b/src/js/composer/commands/imageCommands.js index 18a7ace..54de9ae 100644 --- a/src/js/composer/commands/imageCommands.js +++ b/src/js/composer/commands/imageCommands.js @@ -31,7 +31,7 @@ export const imageCommands = { { key: "file", label: "图片文件", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -62,7 +62,7 @@ export const imageCommands = { { key: "inputFile", label: "输入文件", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -84,7 +84,7 @@ export const imageCommands = { { key: "outputFile", label: "输出文件", - type: "varInput", + component: "VariableInput", icon: "save", width: 12, options: { @@ -105,7 +105,7 @@ export const imageCommands = { { key: "width", label: "宽度(像素)", - type: "numInput", + component: "NumberInput", icon: "compare_arrows", width: 6, min: 1, @@ -115,7 +115,7 @@ export const imageCommands = { { key: "height", label: "高度(像素)", - type: "numInput", + component: "NumberInput", icon: "height", width: 6, min: 1, @@ -125,7 +125,7 @@ export const imageCommands = { { key: "keepAspectRatio", label: "保持宽高比", - type: "select", + component: "q-select", icon: "aspect_ratio", width: 6, defaultValue: "true", @@ -137,7 +137,7 @@ export const imageCommands = { { key: "quality", label: "图片质量(0-1)", - type: "numInput", + component: "NumberInput", icon: "high_quality", width: 6, max: 1, @@ -157,7 +157,7 @@ export const imageCommands = { { key: "inputFile", label: "输入文件", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -179,7 +179,7 @@ export const imageCommands = { { key: "outputFile", label: "输出文件", - type: "varInput", + component: "VariableInput", icon: "save", width: 12, options: { @@ -200,7 +200,7 @@ export const imageCommands = { { key: "angle", label: "旋转角度", - type: "numInput", + component: "NumberInput", icon: "rotate_right", width: 6, step: 90, @@ -209,7 +209,7 @@ export const imageCommands = { { key: "quality", label: "图片质量(0-1)", - type: "numInput", + component: "NumberInput", icon: "high_quality", width: 6, max: 1, @@ -229,7 +229,7 @@ export const imageCommands = { { key: "inputFile", label: "输入文件", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -251,7 +251,7 @@ export const imageCommands = { { key: "outputFile", label: "输出文件", - type: "varInput", + component: "VariableInput", icon: "save", width: 12, options: { @@ -272,7 +272,7 @@ export const imageCommands = { { key: "x", label: "起始X坐标", - type: "numInput", + component: "NumberInput", icon: "arrow_right", width: 6, min: 0, @@ -282,7 +282,7 @@ export const imageCommands = { { key: "y", label: "起始Y坐标", - type: "numInput", + component: "NumberInput", icon: "arrow_downward", width: 6, min: 0, @@ -292,7 +292,7 @@ export const imageCommands = { { key: "width", label: "裁剪宽度", - type: "numInput", + component: "NumberInput", icon: "compare_arrows", width: 6, min: 1, @@ -302,7 +302,7 @@ export const imageCommands = { { key: "height", label: "裁剪高度", - type: "numInput", + component: "NumberInput", icon: "height", width: 6, min: 1, @@ -312,9 +312,9 @@ export const imageCommands = { { key: "quality", label: "图片质量(0-1)", - type: "numInput", + component: "NumberInput", icon: "high_quality", - width: 6, + width: 12, max: 1, min: 0, step: 0.05, @@ -332,7 +332,7 @@ export const imageCommands = { { key: "inputFile", label: "输入文件", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -354,7 +354,7 @@ export const imageCommands = { { key: "outputFile", label: "输出文件", - type: "varInput", + component: "VariableInput", icon: "save", width: 12, options: { @@ -375,31 +375,31 @@ export const imageCommands = { { key: "text", label: "水印文字", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: 12, - defaultValue: newVarInputVal("var", "水印文字"), + defaultValue: newVarInputVal("str", "水印文字"), }, { key: "font", label: "字体设置", - type: "varInput", + component: "VariableInput", icon: "font_download", width: 6, - defaultValue: newVarInputVal("var", "24px Arial"), + defaultValue: newVarInputVal("str", "24px Arial"), }, { key: "color", label: "文字颜色", - type: "varInput", + component: "VariableInput", icon: "format_color_text", width: 6, - defaultValue: newVarInputVal("var", "rgba(255, 255, 255, 0.5)"), + defaultValue: newVarInputVal("str", "rgba(255, 255, 255, 0.5)"), }, { key: "position", label: "位置", - type: "select", + component: "q-select", icon: "place", width: 6, defaultValue: "bottomRight", @@ -408,7 +408,7 @@ export const imageCommands = { { key: "margin", label: "边距", - type: "numInput", + component: "NumberInput", icon: "space_bar", min: 0, step: 10, @@ -418,7 +418,7 @@ export const imageCommands = { { key: "opacity", label: "不透明度(0-1)", - type: "numInput", + component: "NumberInput", icon: "opacity", max: 1, min: 0, @@ -429,7 +429,7 @@ export const imageCommands = { { key: "quality", label: "图片质量(0-1)", - type: "numInput", + component: "NumberInput", icon: "high_quality", max: 1, min: 0, @@ -449,7 +449,7 @@ export const imageCommands = { { key: "inputFile", label: "输入文件", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -471,7 +471,7 @@ export const imageCommands = { { key: "outputFile", label: "输出文件", - type: "varInput", + component: "VariableInput", icon: "save", width: 12, options: { @@ -492,7 +492,7 @@ export const imageCommands = { { key: "format", label: "输出格式", - type: "select", + component: "q-select", icon: "transform", width: 6, defaultValue: "jpeg", @@ -501,7 +501,7 @@ export const imageCommands = { { key: "quality", label: "图片质量(0-1)", - type: "numInput", + component: "NumberInput", icon: "high_quality", width: 6, max: 1, @@ -520,7 +520,7 @@ export const imageCommands = { { key: "inputFile", label: "PNG路径/Base64", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -542,7 +542,7 @@ export const imageCommands = { { key: "outputDir", label: "输出目录", - type: "varInput", + component: "VariableInput", icon: "save", width: 9, defaultValue: newVarInputVal("str", window.utools.getPath("desktop")), @@ -560,7 +560,7 @@ export const imageCommands = { { key: "type", label: "输出格式", - type: "select", + component: "q-select", icon: "transform", width: 3, defaultValue: "ico", diff --git a/src/js/composer/commands/mathCommands.js b/src/js/composer/commands/mathCommands.js index d5d2556..5a90d53 100644 --- a/src/js/composer/commands/mathCommands.js +++ b/src/js/composer/commands/mathCommands.js @@ -1,3 +1,5 @@ +import { newVarInputVal } from "js/composer/varInputValManager"; + export const mathCommands = { label: "数学计算", icon: "calculate", @@ -12,9 +14,11 @@ export const mathCommands = { { key: "expression", label: "表达式", - type: "varInput", + component: "VariableInput", icon: "functions", - width: 12, + width: "auto", + defaultValue: newVarInputVal("var", ""), + disableToggleType: true, }, ], subCommands: [ @@ -31,9 +35,9 @@ export const mathCommands = { { key: "decimals", label: "小数位数", - type: "numInput", + component: "NumberInput", icon: "pin", - width: 6, + width: 4, min: 0, defaultValue: 2, }, @@ -70,7 +74,7 @@ export const mathCommands = { { key: "min", label: "最小值", - type: "numInput", + component: "NumberInput", icon: "arrow_downward", width: 6, defaultValue: 0, @@ -78,7 +82,7 @@ export const mathCommands = { { key: "max", label: "最大值", - type: "numInput", + component: "NumberInput", icon: "arrow_upward", width: 6, defaultValue: 100, @@ -86,7 +90,7 @@ export const mathCommands = { { key: "count", label: "生成数量", - type: "numInput", + component: "NumberInput", icon: "format_list_numbered", width: 6, min: 1, @@ -95,7 +99,7 @@ export const mathCommands = { { key: "decimals", label: "小数位数", - type: "numInput", + component: "NumberInput", icon: "pin", width: 6, min: 0, @@ -116,7 +120,7 @@ export const mathCommands = { ], }, { - value: "quickcomposer.math.statistics", + value: "quickcomposer.math.statistics.mean", label: "统计计算", desc: "统计学相关计算", icon: "bar_chart", @@ -124,10 +128,12 @@ export const mathCommands = { { key: "numbers", label: "数据集合", - type: "varInput", + component: "VariableInput", icon: "dataset", width: 12, - placeholder: "用逗号分隔的数字,如: 1,2,3,4,5", + placeholder: "数字数组,如:[1,2,3,4,5]", + defaultValue: newVarInputVal("var", ""), + disableToggleType: true, }, ], subCommands: [ @@ -197,7 +203,7 @@ export const mathCommands = { { key: "radius", label: "半径", - type: "numInput", + component: "NumberInput", icon: "radio_button_checked", width: 12, min: 0, @@ -212,15 +218,15 @@ export const mathCommands = { { key: "width", label: "宽度", - type: "numInput", - icon: "width", + component: "NumberInput", + icon: "swap_horiz", width: 6, min: 0, }, { key: "height", label: "高度", - type: "numInput", + component: "NumberInput", icon: "height", width: 6, min: 0, @@ -235,7 +241,7 @@ export const mathCommands = { { key: "a", label: "边长a", - type: "numInput", + component: "NumberInput", icon: "straighten", width: 4, min: 0, @@ -243,7 +249,7 @@ export const mathCommands = { { key: "b", label: "边长b", - type: "numInput", + component: "NumberInput", icon: "straighten", width: 4, min: 0, @@ -251,7 +257,7 @@ export const mathCommands = { { key: "c", label: "边长c", - type: "numInput", + component: "NumberInput", icon: "straighten", width: 4, min: 0, @@ -269,7 +275,7 @@ export const mathCommands = { { key: "angle", label: "角度值", - type: "numInput", + component: "NumberInput", icon: "rotate_right", width: 12, }, @@ -316,14 +322,14 @@ export const mathCommands = { { key: "value", label: "数值", - type: "numInput", + component: "NumberInput", icon: "pin", width: 12, }, { key: "from", label: "从", - type: "select", + component: "q-select", icon: "input", width: 6, options: [ @@ -338,7 +344,7 @@ export const mathCommands = { { key: "to", label: "到", - type: "select", + component: "q-select", icon: "output", width: 6, options: [ diff --git a/src/js/composer/commands/networkCommands.js b/src/js/composer/commands/networkCommands.js index 7933b39..db605a0 100644 --- a/src/js/composer/commands/networkCommands.js +++ b/src/js/composer/commands/networkCommands.js @@ -12,7 +12,7 @@ export const networkCommands = { { key: "visit", label: "要访问的网址链接", - type: "varInput", + component: "VariableInput", icon: "language", }, ], @@ -24,7 +24,7 @@ export const networkCommands = { { key: "url", label: "要访问的网址链接", - type: "varInput", + component: "VariableInput", icon: "public", }, ], @@ -56,7 +56,7 @@ export const networkCommands = { config: [ { label: "URL", - type: "varInput", + component: "VariableInput", icon: "link", width: "auto", }, @@ -75,42 +75,42 @@ export const networkCommands = { config: [ { label: "协议", - type: "varInput", + component: "VariableInput", icon: "security", width: 6, }, { label: "认证信息", - type: "varInput", + component: "VariableInput", icon: "person", width: 6, }, { label: "主机名", - type: "varInput", + component: "VariableInput", icon: "dns", width: 6, }, { label: "端口", - type: "varInput", + component: "VariableInput", icon: "settings_ethernet", width: 6, }, { label: "路径", - type: "varInput", + component: "VariableInput", icon: "folder", }, { label: "查询字符串", - type: "varInput", + component: "VariableInput", icon: "search", width: 6, }, { label: "锚点", - type: "varInput", + component: "VariableInput", icon: "tag", width: 6, }, @@ -124,7 +124,7 @@ export const networkCommands = { config: [ { label: "查询字符串", - type: "varInput", + component: "VariableInput", icon: "search", }, ], @@ -137,7 +137,7 @@ export const networkCommands = { config: [ { label: "参数", - type: "dictEditor", + component: "DictEditor", icon: "edit", }, ], @@ -150,7 +150,7 @@ export const networkCommands = { config: [ { label: "路径", - type: "varInput", + component: "VariableInput", icon: "folder", }, ], @@ -163,7 +163,7 @@ export const networkCommands = { config: [ { label: "主机名", - type: "varInput", + component: "VariableInput", icon: "dns", }, ], @@ -175,7 +175,7 @@ export const networkCommands = { config: [ { label: "参数名", - type: "varInput", + component: "VariableInput", icon: "key", width: "auto", }, @@ -188,13 +188,13 @@ export const networkCommands = { config: [ { label: "参数名", - type: "varInput", + component: "VariableInput", icon: "key", width: "auto", }, { label: "参数值", - type: "varInput", + component: "VariableInput", icon: "text_fields", width: "auto", }, @@ -207,7 +207,7 @@ export const networkCommands = { config: [ { label: "参数名", - type: "varInput", + component: "VariableInput", icon: "key", width: "auto", }, @@ -235,7 +235,7 @@ export const networkCommands = { { label: "要查询的域名", icon: "dns", - type: "varInput", + component: "VariableInput", width: "auto", }, ], @@ -248,7 +248,7 @@ export const networkCommands = { { label: "IP版本", icon: "settings_ethernet", - type: "select", + component: "q-select", options: [ { label: "自动", value: 0 }, { label: "IPv4", value: 4 }, @@ -259,7 +259,7 @@ export const networkCommands = { }, { label: "返回所有地址", - type: "checkbox", + component: "q-checkbox", defaultValue: false, width: 2.5, }, @@ -309,7 +309,7 @@ export const networkCommands = { { label: "IP地址", icon: "router", - type: "varInput", + component: "VariableInput", }, ], }, @@ -324,14 +324,14 @@ export const networkCommands = { config: [ { label: "文件URL", - type: "varInput", + component: "VariableInput", icon: "link", defaultValue: newVarInputVal("str", "https://"), width: 12, }, { label: "保存路径", - type: "varInput", + component: "VariableInput", icon: "folder", width: 12, placeholder: "留空则弹出对话框选择保存路径", @@ -347,28 +347,28 @@ export const networkCommands = { config: [ { label: "上传接口地址", - type: "varInput", + component: "VariableInput", icon: "link", defaultValue: newVarInputVal("str", "https://"), width: 12, }, { label: "文件路径", - type: "varInput", + component: "VariableInput", icon: "file_present", width: 12, placeholder: "留空则弹出对话框选择文件", }, { label: "文件名", - type: "varInput", + component: "VariableInput", icon: "text_fields", defaultValue: newVarInputVal("str", "file"), width: 12, }, { label: "额外表单数据(可选)", - type: "dictEditor", + component: "DictEditor", width: 12, }, ], diff --git a/src/js/composer/commands/notifyCommands.js b/src/js/composer/commands/notifyCommands.js index b7e4245..817afb7 100644 --- a/src/js/composer/commands/notifyCommands.js +++ b/src/js/composer/commands/notifyCommands.js @@ -10,7 +10,7 @@ export const notifyCommands = { { key: "log", label: "要打印的消息文本", - type: "varInput", + component: "VariableInput", icon: "info", }, ], @@ -22,7 +22,7 @@ export const notifyCommands = { { key: "notification", label: "要发送的系统消息文本", - type: "varInput", + component: "VariableInput", icon: "message", }, ], diff --git a/src/js/composer/commands/otherCommands.js b/src/js/composer/commands/otherCommands.js index 937b7b1..92c9e96 100644 --- a/src/js/composer/commands/otherCommands.js +++ b/src/js/composer/commands/otherCommands.js @@ -10,7 +10,7 @@ export const otherCommands = { { key: "ms", label: "延迟的毫秒数", - type: "numInput", + component: "NumberInput", min: 0, step: 100, icon: "schedule", diff --git a/src/js/composer/commands/screenCommands.js b/src/js/composer/commands/screenCommands.js index 8e0c9d5..cc1fbdc 100644 --- a/src/js/composer/commands/screenCommands.js +++ b/src/js/composer/commands/screenCommands.js @@ -1,44 +1,67 @@ -import { newVarInputVal } from "js/composer/varInputValManager"; +const xy = { + x: { + label: "X坐标", + component: "NumberInput", + icon: "arrow_right", + width: 6, + min: 0, + step: 10, + }, + y: { + label: "Y坐标", + component: "NumberInput", + icon: "arrow_down", + width: 6, + min: 0, + step: 10, + }, +}; const XY_DICT_EDITOR = { label: "坐标", - type: "dictEditor", + component: "OptionEditor", icon: "transform", isCollapse: false, width: 12, defaultValue: { - x: newVarInputVal("var", "0"), - y: newVarInputVal("var", "0"), + x: 0, + y: 0, }, options: { - fixedKeys: [ - { value: "x", label: "X坐标" }, - { value: "y", label: "Y坐标" }, - ], - disableAdd: true, + ...xy, }, }; const RECT_DICT_EDITOR = { label: "区域", - type: "dictEditor", + component: "DictEditor", icon: "transform", isCollapse: false, width: 12, defaultValue: { - x: newVarInputVal("var", "0"), - y: newVarInputVal("var", "0"), - width: newVarInputVal("var", "100"), - height: newVarInputVal("var", "100"), + x: 0, + y: 0, + width: 100, + height: 100, }, options: { - fixedKeys: [ - { value: "x", label: "X坐标" }, - { value: "y", label: "Y坐标" }, - { value: "width", label: "宽度" }, - { value: "height", label: "高度" }, - ], - disableAdd: true, + ...xy, + width: { + label: "宽度", + component: "NumberInput", + icon: "swap_horiz", + min: 0, + step: 10, + width: 6, + }, + height: { + label: "高度", + component: "NumberInput", + icon: "height", + min: 0, + step: 10, + width: 6, + }, }, }; diff --git a/src/js/composer/commands/simulateCommands.js b/src/js/composer/commands/simulateCommands.js index f5a6831..54d7207 100644 --- a/src/js/composer/commands/simulateCommands.js +++ b/src/js/composer/commands/simulateCommands.js @@ -41,7 +41,7 @@ export const simulateCommands = { { key: "text", label: "要发送的文本内容", - type: "varInput", + component: "VariableInput", icon: "send", width: 12, }, @@ -72,7 +72,7 @@ export const simulateCommands = { { key: "file", label: "文件路径", - type: "varInput", + component: "VariableInput", icon: "description", width: 12, options: { @@ -99,7 +99,7 @@ export const simulateCommands = { { key: "image", label: "图片路径/base64", - type: "varInput", + component: "VariableInput", icon: "image", width: 12, options: { @@ -120,7 +120,7 @@ export const simulateCommands = { { label: "X坐标(留空则原地点击)", icon: "drag_handle", - type: "numInput", + component: "NumberInput", min: 0, step: 10, width: 6, @@ -128,7 +128,7 @@ export const simulateCommands = { { label: "Y坐标(留空则原地点击)", icon: "drag_handle", - type: "numInput", + component: "NumberInput", min: 0, step: 10, width: 6, @@ -165,7 +165,7 @@ export const simulateCommands = { label: "X坐标", icon: "drag_handle", defaultValue: 0, - type: "numInput", + component: "NumberInput", min: 0, step: 10, width: 6, @@ -174,7 +174,7 @@ export const simulateCommands = { label: "Y坐标", icon: "drag_handle", defaultValue: 0, - type: "numInput", + component: "NumberInput", min: 0, step: 10, width: 6, @@ -216,7 +216,7 @@ export const simulateCommands = { { key: "range", label: "截图范围", - type: "buttonGroup", + component: "ButtonGroup", options: [ { label: "全屏截图", @@ -245,7 +245,7 @@ export const simulateCommands = { { key: "path", label: "截图保存路径", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal( "str", `${window.utools.getPath("desktop")}${ diff --git a/src/js/composer/commands/systemCommands.js b/src/js/composer/commands/systemCommands.js index a214201..5f5b609 100644 --- a/src/js/composer/commands/systemCommands.js +++ b/src/js/composer/commands/systemCommands.js @@ -17,7 +17,7 @@ export const systemCommands = { { key: "content", label: "要写入剪切板的内容", - type: "varInput", + component: "VariableInput", icon: "content_copy", }, ], @@ -30,7 +30,7 @@ export const systemCommands = { { key: "image", label: "图片路径/base64", - type: "varInput", + component: "VariableInput", icon: "image", options: { dialog: { @@ -52,7 +52,7 @@ export const systemCommands = { { key: "file", label: "文件路径", - type: "varInput", + component: "VariableInput", icon: "file_copy", options: { dialog: { @@ -132,7 +132,7 @@ export const systemCommands = { config: [ { label: "信息格式", - type: "buttonGroup", + component: "ButtonGroup", options: [ { label: "完整信息", value: "full" }, { label: "仅型号和速度", value: "simple" }, @@ -149,7 +149,7 @@ export const systemCommands = { config: [ { label: "内存类型", - type: "buttonGroup", + component: "ButtonGroup", options: [ { label: "总内存", value: "totalmem" }, { label: "空闲内存", value: "freemem" }, @@ -166,7 +166,7 @@ export const systemCommands = { config: [ { label: "网络信息类型", - type: "buttonGroup", + component: "ButtonGroup", options: [ { label: "主机名", value: "hostname" }, { label: "网络接口", value: "networkInterfaces" }, @@ -176,7 +176,7 @@ export const systemCommands = { }, { label: "包含内部接口", - type: "checkbox", + component: "q-checkbox", defaultValue: false, width: 12, condition: "values[0] === 'networkInterfaces'", @@ -190,7 +190,7 @@ export const systemCommands = { config: [ { label: "平台信息类型", - type: "buttonGroup", + component: "ButtonGroup", options: [ { label: "操作系统名称", value: "platform" }, { label: "操作系统类型", value: "type" }, @@ -217,7 +217,7 @@ export const systemCommands = { config: [ { label: "路径", - type: "varInput", + component: "VariableInput", icon: "folder", width: "auto", }, @@ -245,7 +245,7 @@ export const systemCommands = { config: [ { label: "要移除的扩展名", - type: "varInput", + component: "VariableInput", icon: "extension", width: "auto", }, @@ -269,13 +269,13 @@ export const systemCommands = { config: [ { label: "路径片段", - type: "varInput", + component: "VariableInput", icon: "folder", width: "auto", }, { label: "路径片段", - type: "varInput", + component: "VariableInput", icon: "folder", width: "auto", }, @@ -289,13 +289,13 @@ export const systemCommands = { config: [ { label: "路径片段", - type: "varInput", + component: "VariableInput", icon: "folder", width: "auto", }, { label: "路径片段", - type: "varInput", + component: "VariableInput", icon: "folder", width: "auto", }, @@ -309,13 +309,13 @@ export const systemCommands = { config: [ { label: "起始路径", - type: "varInput", + component: "VariableInput", icon: "folder", width: 6, }, { label: "目标路径", - type: "varInput", + component: "VariableInput", icon: "folder", width: 6, }, @@ -329,31 +329,31 @@ export const systemCommands = { config: [ { label: "根路径", - type: "varInput", + component: "VariableInput", icon: "folder", width: 6, }, { label: "目录", - type: "varInput", + component: "VariableInput", icon: "folder", width: 6, }, { label: "基本名称", - type: "varInput", + component: "VariableInput", icon: "description", width: 6, }, { label: "文件名", - type: "varInput", + component: "VariableInput", icon: "insert_drive_file", width: 6, }, { label: "扩展名", - type: "varInput", + component: "VariableInput", icon: "extension", width: 6, }, @@ -369,7 +369,7 @@ export const systemCommands = { config: [ { label: "进程ID", - type: "numInput", + component: "NumberInput", min: 0, step: 100, icon: "developer_board", @@ -377,7 +377,7 @@ export const systemCommands = { }, { label: "信号", - type: "select", + component: "q-select", icon: "signal_cellular_alt", options: [ { label: "正常终止 (15)", value: "SIGTERM" }, diff --git a/src/js/composer/commands/uiCommands.js b/src/js/composer/commands/uiCommands.js index 0d44043..2514c97 100644 --- a/src/js/composer/commands/uiCommands.js +++ b/src/js/composer/commands/uiCommands.js @@ -14,7 +14,7 @@ export const uiCommands = { config: [ { label: "按钮", - type: "arrayEditor", + component: "ArrayEditor", defaultValue: [ newVarInputVal("str", "是"), newVarInputVal("str", "否"), @@ -31,7 +31,7 @@ export const uiCommands = { config: [ { label: "输入框", - type: "arrayEditor", + component: "ArrayEditor", width: 12, options: { keys: [ @@ -54,7 +54,7 @@ export const uiCommands = { }, { label: "标题", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str"), width: 12, }, @@ -77,13 +77,13 @@ export const uiCommands = { config: [ { label: "文本框占位符", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str", "请输入"), width: 6, }, { label: "文本框默认值", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str"), width: 6, }, @@ -97,14 +97,14 @@ export const uiCommands = { config: [ { label: "提示内容", - type: "varInput", + component: "VariableInput", icon: "info", defaultValue: newVarInputVal("str", "这是一条提示消息"), width: 12, }, { label: "图标类型", - type: "select", + component: "q-select", defaultValue: "success", icon: "lightbulb", width: 6, @@ -117,7 +117,7 @@ export const uiCommands = { }, { label: "显示时间(ms)", - type: "numInput", + component: "NumberInput", min: 0, step: 100, width: 6, @@ -135,25 +135,25 @@ export const uiCommands = { config: [ { label: "提示内容", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str", "确认要执行此操作吗?"), width: 12, }, { label: "标题", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str", "提示"), width: 7, }, { label: "支持HTML", - type: "switch", + component: "q-toggle", defaultValue: false, width: 2, }, { label: "宽度", - type: "numInput", + component: "NumberInput", min: 0, step: 100, defaultValue: 450, @@ -171,26 +171,26 @@ export const uiCommands = { config: [ { label: "标题", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str", "请选择文件"), width: 6, }, { label: "默认路径", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str"), width: 6, placeholder: "默认打开的路径", }, { label: "按钮文本", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str", "选择"), width: 3, }, { label: "提示信息", - type: "varInput", + component: "VariableInput", defaultValue: newVarInputVal("str"), width: 3, placeholder: "对话框底部的提示信息", @@ -198,13 +198,14 @@ export const uiCommands = { }, { label: "扩展名", - type: "varInput", + component: "VariableInput", width: 6, options: { items: ["*", "jpg", "png", "gif", "txt", "json", "exe"], multiSelect: true, }, defaultValue: newVarInputVal("var", '["*"]'), + disableToggleType: true, }, ], subCommands: [ @@ -216,7 +217,7 @@ export const uiCommands = { config: [ { label: "选择选项", - type: "checkGroup", + component: "CheckGroup", icon: "settings", width: 12, options: [ @@ -245,7 +246,7 @@ export const uiCommands = { config: [ { label: "选择选项", - type: "checkGroup", + component: "CheckGroup", icon: "settings", width: 12, options: [ diff --git a/src/js/composer/commands/userdataCommands.js b/src/js/composer/commands/userdataCommands.js index d3dbcfd..7d6e06e 100644 --- a/src/js/composer/commands/userdataCommands.js +++ b/src/js/composer/commands/userdataCommands.js @@ -10,7 +10,7 @@ export const userdataCommands = { config: [ { label: "数据标识", - type: "input", + component: "q-input", }, ], outputVariable: "userData", @@ -30,17 +30,17 @@ export const userdataCommands = { config: [ { label: "数据", - type: "varInput", + component: "VariableInput", width: 7, }, { label: "数据标识", - type: "input", + component: "q-input", width: 3, }, { label: "不同步", - type: "checkbox", + component: "q-checkbox", defaultValue: true, width: 2, }, @@ -53,7 +53,7 @@ export const userdataCommands = { config: [ { label: "数据标识", - type: "input", + component: "q-input", }, ], }, diff --git a/src/js/composer/commands/utoolsCommand.js b/src/js/composer/commands/utoolsCommand.js index 42d8915..4e0c6c0 100644 --- a/src/js/composer/commands/utoolsCommand.js +++ b/src/js/composer/commands/utoolsCommand.js @@ -1,5 +1,3 @@ -import { newVarInputVal } from "js/composer/varInputValManager"; - export const utoolsCommands = { label: "uTools功能", icon: "insights", @@ -25,7 +23,7 @@ export const utoolsCommands = { { key: "height", label: "高度", - type: "numInput", + component: "NumberInput", min: 0, step: 100, icon: "straighten", @@ -41,7 +39,7 @@ export const utoolsCommands = { config: [ { key: "isKill", - type: "select", + component: "q-select", options: [ { label: "杀死插件进程", value: true }, { label: "插件隐藏到后台", value: false }, @@ -74,14 +72,14 @@ export const utoolsCommands = { { key: "pluginName", label: "要跳转至的插件名称", - type: "varInput", + component: "VariableInput", icon: "alt_route", width: 6, }, { key: "payload", label: "传递给插件的文本", - type: "varInput", + component: "VariableInput", icon: "alt_route", width: 6, }, @@ -102,46 +100,53 @@ export const utoolsCommands = { { key: "text", label: "文本", - type: "varInput", + component: "VariableInput", icon: "search", width: 12, }, { key: "options", label: "选项", - type: "dictEditor", + component: "OptionEditor", icon: "settings", options: { - disableAdd: true, - fixedKeys: [ - { - value: "forward", - label: "向前查找", - }, - { - value: "findNext", - label: "查找下一个", - }, - { - value: "matchCase", - label: "区分大小写", - }, - { - value: "wordStart", - label: "单词开头", - }, - { - value: "medialCapitalAsWordStart", - label: "中缀大写作为单词开头", - }, - ], + forward: { + label: "向前查找", + icon: "arrow_right", + width: 2, + component: "q-checkbox", + }, + findNext: { + label: "查找下一个", + icon: "arrow_down", + width: 2, + component: "q-checkbox", + }, + matchCase: { + label: "区分大小写", + icon: "arrow_up", + width: 2, + component: "q-checkbox", + }, + wordStart: { + label: "单词开头", + icon: "arrow_right", + width: 2, + component: "q-checkbox", + }, + medialCapitalAsWordStart: { + label: "中缀大写作为单词开头", + icon: "arrow_right", + width: 4, + component: "q-checkbox", + }, }, defaultValue: { - forward: newVarInputVal("var", "true"), - findNext: newVarInputVal("var", "false"), - matchCase: newVarInputVal("var", "false"), - wordStart: newVarInputVal("var", "false"), - medialCapitalAsWordStart: newVarInputVal("var", "false"), + forward: true, + findNext: false, + matchCase: false, + wordStart: false, + medialCapitalAsWordStart: false, }, width: 12, }, @@ -156,7 +161,7 @@ export const utoolsCommands = { { key: "action", label: "动作", - type: "buttonGroup", + component: "ButtonGroup", icon: "settings", width: 12, options: [ diff --git a/src/js/composer/commonComponentGuide.js b/src/js/composer/commonComponentGuide.js index ad7dca7..12fbc41 100644 --- a/src/js/composer/commonComponentGuide.js +++ b/src/js/composer/commonComponentGuide.js @@ -49,7 +49,7 @@ const commonComponentGuide = { config: [ { label: "域名", - type: "varInput", + component: "VariableInput", icon: "dns", width: "auto" } @@ -75,7 +75,7 @@ const commonComponentGuide = { config: [ { label: "IP版本", - type: "select", + component: "q-select", options: [ { label: "自动", value: 0 }, { label: "IPv4", value: 4 } @@ -92,7 +92,7 @@ const commonComponentGuide = { config: [ { label: "IP地址", - type: "varInput", + component: "VariableInput", icon: "router" } ] diff --git a/src/js/composer/ubrowserConfig.js b/src/js/composer/ubrowserConfig.js index f12cc74..2840dc3 100644 --- a/src/js/composer/ubrowserConfig.js +++ b/src/js/composer/ubrowserConfig.js @@ -21,7 +21,7 @@ export const ubrowserOperationConfigs = [ key: "time", label: "等待时间(ms)", icon: "timer", - type: "numInput", + component: "NumberInput", width: 12, showWhen: "type", showValue: "time", @@ -30,7 +30,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "等待元素的CSS选择器", icon: "find_in_page", - type: "varInput", + component: "VariableInput", width: 12, showWhen: "type", showValue: "selector", @@ -48,7 +48,7 @@ export const ubrowserOperationConfigs = [ key: "timeout", label: "超时时间(ms)", icon: "timer_off", - type: "numInput", + component: "NumberInput", width: 12, defaultValue: 60000, showWhen: "type", @@ -65,7 +65,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "点击元素的CSS选择器", icon: "mouse", - type: "varInput", + component: "VariableInput", }, ], icon: "mouse", @@ -78,7 +78,7 @@ export const ubrowserOperationConfigs = [ key: "value", label: "注入的CSS样式", icon: "style", - type: "varInput", + component: "VariableInput", }, ], icon: "style", @@ -91,7 +91,7 @@ export const ubrowserOperationConfigs = [ key: "key", label: "按键", icon: "keyboard", - type: "varInput", + component: "VariableInput", width: 5, }, { @@ -118,7 +118,7 @@ export const ubrowserOperationConfigs = [ key: "text", label: "粘贴内容", icon: "content_paste", - type: "varInput", + component: "VariableInput", }, ], icon: "content_paste", @@ -131,14 +131,14 @@ export const ubrowserOperationConfigs = [ key: "width", label: "视窗宽度", icon: "width", - type: "numInput", + component: "NumberInput", width: 6, }, { key: "height", label: "视窗高度", icon: "height", - type: "numInput", + component: "NumberInput", width: 6, }, ], @@ -148,36 +148,46 @@ export const ubrowserOperationConfigs = [ value: "screenshot", label: "截图", config: [ - { key: "selector", label: "元素选择器", icon: "crop", type: "varInput" }, + { + key: "selector", + label: "元素选择器", + icon: "crop", + component: "VariableInput", + }, { key: "rect.x", label: "X坐标", icon: "drag_handle", - type: "numInput", + component: "NumberInput", width: 3, }, { key: "rect.y", label: "Y坐标", icon: "drag_handle", - type: "numInput", + component: "NumberInput", width: 3, }, { key: "rect.width", label: "宽度", icon: "width", - type: "numInput", + component: "NumberInput", width: 3, }, { key: "rect.height", label: "高度", icon: "height", - type: "numInput", + component: "NumberInput", width: 3, }, - { key: "savePath", label: "保存路径", icon: "save", type: "varInput" }, + { + key: "savePath", + label: "保存路径", + icon: "save", + component: "VariableInput", + }, ], icon: "picture_as_pdf", }, @@ -188,7 +198,7 @@ export const ubrowserOperationConfigs = [ { key: "options.marginsType", label: "边距类型", - type: "select", + component: "q-select", options: [ { label: "默认边距", value: 0 }, { label: "无边距", value: 1 }, @@ -199,11 +209,16 @@ export const ubrowserOperationConfigs = [ { key: "options.pageSize", label: "页面大小", - type: "select", + component: "q-select", options: ["A3", "A4", "A5", "Legal", "Letter", "Tabloid"], width: 6, }, - { key: "savePath", label: "保存路径", icon: "save", type: "varInput" }, + { + key: "savePath", + label: "保存路径", + icon: "save", + component: "VariableInput", + }, ], icon: "devices", }, @@ -225,7 +240,7 @@ export const ubrowserOperationConfigs = [ key: "deviceName", label: "设备名称", icon: "smartphone", - type: "varInput", + component: "VariableInput", width: 12, showWhen: "type", showValue: "preset", @@ -242,7 +257,7 @@ export const ubrowserOperationConfigs = [ key: "useragent", label: "User-Agent", icon: "devices", - type: "varInput", + component: "VariableInput", width: 12, showWhen: "type", showValue: "custom", @@ -258,7 +273,7 @@ export const ubrowserOperationConfigs = [ key: "name", label: "Cookie名称", icon: "cookie", - type: "varInput", + component: "VariableInput", width: 12, }, ], @@ -274,7 +289,12 @@ export const ubrowserOperationConfigs = [ value: "removeCookies", label: "删除Cookie", config: [ - { key: "name", label: "Cookie名称", icon: "cookie", type: "varInput" }, + { + key: "name", + label: "Cookie名称", + icon: "cookie", + component: "VariableInput", + }, ], icon: "cookie", }, @@ -282,7 +302,12 @@ export const ubrowserOperationConfigs = [ value: "clearCookies", label: "清空Cookie", config: [ - { key: "url", label: "URL(可选)", icon: "link", type: "varInput" }, + { + key: "url", + label: "URL(可选)", + icon: "link", + component: "VariableInput", + }, ], icon: "cookie", }, @@ -318,7 +343,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "等待元素的CSS选择器", icon: "find_in_page", - type: "varInput", + component: "VariableInput", width: 12, showWhen: "type", showValue: "selector", @@ -336,7 +361,7 @@ export const ubrowserOperationConfigs = [ key: "timeout", label: "超时时间(ms)", icon: "timer_off", - type: "numInput", + component: "NumberInput", width: 12, defaultValue: 60000, showWhen: "type", @@ -359,7 +384,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "按下元素选择器", icon: "mouse", - type: "varInput", + component: "VariableInput", }, ], icon: "mouse", @@ -372,7 +397,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "释放元素选择器", icon: "mouse", - type: "varInput", + component: "VariableInput", }, ], icon: "mouse", @@ -385,7 +410,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "文件输入框选择器", icon: "upload_file", - type: "varInput", + component: "VariableInput", }, { key: "files", label: "文件列表", type: "file-list", width: 12 }, ], @@ -399,14 +424,14 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "元素选择器", icon: "varInput", - type: "varInput", + component: "VariableInput", width: 6, }, { key: "value", label: "设置的值", icon: "edit", - type: "varInput", + component: "VariableInput", width: 6, }, ], @@ -420,7 +445,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "复选框/选框选择器", icon: "check_box", - type: "varInput", + component: "VariableInput", width: 8, }, { @@ -441,7 +466,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "元素选择器", icon: "center_focus_strong", - type: "varInput", + component: "VariableInput", }, ], icon: "swap_vert", @@ -464,7 +489,7 @@ export const ubrowserOperationConfigs = [ key: "selector", label: "目标元素选择器", icon: "swap_vert", - type: "varInput", + component: "VariableInput", width: 12, showWhen: "type", showValue: "element", @@ -473,7 +498,7 @@ export const ubrowserOperationConfigs = [ key: "x", label: "X坐标", icon: "drag_handle", - type: "numInput", + component: "NumberInput", width: 6, showWhen: "type", showValue: "position", @@ -482,7 +507,7 @@ export const ubrowserOperationConfigs = [ key: "y", label: "Y坐标", icon: "drag_handle", - type: "numInput", + component: "NumberInput", width: 6, showWhen: "type", showValue: "position", @@ -498,14 +523,14 @@ export const ubrowserOperationConfigs = [ key: "url", label: "下载URL", icon: "link", - type: "varInput", + component: "VariableInput", width: 6, }, { key: "savePath", label: "保存路径", icon: "save", - type: "varInput", + component: "VariableInput", width: 6, }, ],