diff --git a/src/components/CommandEditor.vue b/src/components/CommandEditor.vue index b88367f..6f86271 100644 --- a/src/components/CommandEditor.vue +++ b/src/components/CommandEditor.vue @@ -1,73 +1,50 @@ diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index 14dd63e..23ed9a5 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -78,6 +78,7 @@ import ResultMenu from "components/popup/ResultMenu.vue"; import { generateFlowsCode } from "js/composer/generateCode"; import { getValidCommand } from "js/commandManager"; import { dbManager } from "js/utools.js"; +import programs from "js/options/programs.js"; export default { components: { ResultArea, ResultMenu }, diff --git a/src/components/ComposerEditor.vue b/src/components/ComposerEditor.vue index fa04d19..b197ac9 100644 --- a/src/components/ComposerEditor.vue +++ b/src/components/ComposerEditor.vue @@ -3,7 +3,7 @@ ref="composer" @action="handleComposerAction" v-model="quickcommandInfo" - :show-close-button="!isRunComposePage" + :disabled-control-buttons="disabledControlButtons" class="fixed-full" /> @@ -15,7 +15,7 @@ import CommandComposer from "components/composer/CommandComposer.vue"; import CommandRunResult from "components/CommandRunResult"; import { findCommandByValue } from "js/composer/composerConfig"; import programs from "js/options/programs.js"; -import { ref } from "vue"; +import { ref, computed } from "vue"; export default { components: { CommandComposer, CommandRunResult }, @@ -82,15 +82,7 @@ export default { mainPush: false, cmds: [], }, - flows: [ - { - id: "main", - name: "main", - label: "主流程", - commands: [], - customVariables: [], - }, - ], + flows: [], output: "text", tags: [], }; @@ -99,12 +91,18 @@ export default { ...retoreToFullCommand(savedCommand), }); - const isRunComposePage = ref(props.action.type === "composer"); + const isRunComposePage = computed(() => { + return props.action.type === "composer"; + }); + + const disabledControlButtons = computed(() => { + return isRunComposePage.value ? ["close", "save", "apply"] : ["apply"]; + }); return { quickcommandInfo, getLitedComposerCommand, - isRunComposePage, + disabledControlButtons, }; }, emits: ["editorEvent"], @@ -120,14 +118,13 @@ export default { case "run": return this.runCurrentCommand(command); case "close": - return this.$emit("editorEvent", { - type: "back", - }); + return this.$emit("editorEvent", "back"); case "save": - return this.$emit("editorEvent", { - type: "save", - data: this.getLitedComposerCommand(command), - }); + return this.$emit( + "editorEvent", + "save", + this.getLitedComposerCommand(command) + ); } }, runCurrentCommand(command) { diff --git a/src/components/composer/CommandComposer.vue b/src/components/composer/CommandComposer.vue index e8ce444..779776a 100644 --- a/src/components/composer/CommandComposer.vue +++ b/src/components/composer/CommandComposer.vue @@ -11,7 +11,7 @@
@@ -42,9 +42,9 @@ export default defineComponent({ }; }, props: { - showCloseButton: { - type: Boolean, - default: true, + disabledControlButtons: { + type: Array, + default: () => [], }, modelValue: { type: Object, diff --git a/src/components/composer/ComposerCard.vue b/src/components/composer/ComposerCard.vue index c4bb269..e25209f 100644 --- a/src/components/composer/ComposerCard.vue +++ b/src/components/composer/ComposerCard.vue @@ -197,16 +197,17 @@ export default defineComponent({ }; const consoleLogVars = this.getAvailableOutputVariableName(outputVariable); - const tempFlows = [{ - name: "main", - commands: [ - tempCommand, - { - //没有输出,则不打印 - code: `if(${consoleLogVars}!==undefined){ + const tempFlows = [ + { + name: "main", + commands: [ + tempCommand, + { + //没有输出,则不打印 + code: `if(${consoleLogVars}!==undefined){ console.log(${consoleLogVars}) }`, - }, + }, ], }, ]; @@ -314,6 +315,14 @@ export default defineComponent({ position: relative; } +.composer-card .q-card { + background-color: rgba(0, 0, 0, 0.02); +} + +.body--dark .composer-card .q-card { + background-color: rgba(255, 255, 255, 0.05); +} + /* 控制流程组件样式 */ .control-component { flex: 1; diff --git a/src/components/composer/FlowTabs.vue b/src/components/composer/FlowTabs.vue index 0cb3d61..cf0363a 100644 --- a/src/components/composer/FlowTabs.vue +++ b/src/components/composer/FlowTabs.vue @@ -60,7 +60,7 @@ @@ -86,7 +86,7 @@ ref="flowRefs" /> [], }, modelValue: { type: Object, @@ -136,7 +136,26 @@ export default defineComponent({ }); }; - const flows = computed(() => props.modelValue.flows); + const defaultFlow = [ + { + id: "main", + name: "main", + label: "主流程", + commands: [], + customVariables: [], + }, + ]; + + if (!props.modelValue.flows || props.modelValue.flows.length === 0) { + updateFlows(defaultFlow); + } + + const flows = computed(() => props.modelValue.flows || []); + + const commandConfig = computed(() => { + const { tags, output, features, program } = props.modelValue; + return { tags, output, features, program }; + }); const mainFlow = computed({ get: () => flows.value[0], @@ -235,6 +254,7 @@ export default defineComponent({ flows, mainFlow, subFlows, + commandConfig, activeTab, getOutputVariables, updateFlows, @@ -243,16 +263,10 @@ export default defineComponent({ data() { return { isAllCollapsed: false, - showVariableManager: false, + showFlowManager: false, outputVariables: [], }; }, - computed: { - commandConfig() { - const { tags, output, features } = this.modelValue; - return { tags, output, features }; - }, - }, methods: { generateFlowName(baseName = "func_") { return ( @@ -293,7 +307,7 @@ export default defineComponent({ this.activeTab = id; this.$nextTick(() => { - this.toggleVariableManager(); + this.toggleFlowManager(); }); }, removeFlow(flow) { @@ -332,12 +346,15 @@ export default defineComponent({ case "expandAll": this.expandAll(); break; - case "toggleVariableManager": - this.toggleVariableManager(); + case "toggleFlowManager": + this.toggleFlowManager(); break; case "close": this.$emit("action", "close"); break; + case "apply": + this.$emit("action", "apply", payload); + break; case "addFlow": // 处理新函数创建 const index = this.subFlows.findIndex((f) => f.name === payload.name); @@ -352,8 +369,8 @@ export default defineComponent({ this.$emit("action", type, payload); } }, - toggleVariableManager() { - this.showVariableManager = !this.showVariableManager; + toggleFlowManager() { + this.showFlowManager = !this.showFlowManager; this.outputVariables = this.getOutputVariables(); }, saveFlows() { @@ -383,7 +400,7 @@ export default defineComponent({ }, editFunction(flow) { this.activeTab = flow.id; - this.toggleVariableManager(); + this.toggleFlowManager(); }, updateCommandConfig(newVal) { const newModelValue = { diff --git a/src/components/composer/flow/ComposerButtons.vue b/src/components/composer/flow/ComposerButtons.vue index 0e1ced6..064a223 100644 --- a/src/components/composer/flow/ComposerButtons.vue +++ b/src/components/composer/flow/ComposerButtons.vue @@ -5,8 +5,8 @@ icon="close" dense flat - v-if="showCloseButton" @click="$emit('action', 'close')" + v-if="!disabledButtons.includes('close')" > 退出可视化编排 @@ -15,6 +15,7 @@ dense flat @click="$emit('action', isAllCollapsed ? 'expandAll' : 'collapseAll')" + v-if="!disabledButtons.includes('expand')" > {{ isAllCollapsed ? "展开所有" : "折叠所有" }} @@ -22,7 +23,8 @@ icon="settings" dense flat - @click="$emit('action', 'toggleVariableManager')" + @click="$emit('action', 'toggleFlowManager')" + v-if="!disabledButtons.includes('manager')" > 流程管理 @@ -34,33 +36,40 @@ v-if="isDev" > - - - + + 保存 - + 预览代码 - + 运行
@@ -99,9 +108,9 @@ export default defineComponent({ type: Boolean, default: false, }, - showCloseButton: { - type: Boolean, - default: true, + disabledButtons: { + type: Array, + default: () => [], }, flows: { type: Array, @@ -119,11 +128,15 @@ export default defineComponent({ }; }, - watch: { - isVisible(val) { - if (val) { - this.code = generateFlowsCode(this.flows); - } + methods: { + handlePreviewCode() { + this.code = generateFlowsCode(this.flows); + this.isVisible = true; + }, + // 清空编辑器内容并插入 + handleApply() { + const code = generateFlowsCode(this.flows); + this.$emit("action", "apply", code); }, }, }); diff --git a/src/components/composer/param/ParamImporter.vue b/src/components/composer/param/ParamImporter.vue index 7fb6ea8..60a4a1d 100644 --- a/src/components/composer/param/ParamImporter.vue +++ b/src/components/composer/param/ParamImporter.vue @@ -26,7 +26,7 @@ import TimeInput from "components/composer/common/TimeInput.vue"; import FunctionInput from "components/composer/common/FunctionInput.vue"; import { QInput, QSelect, QToggle, QCheckbox } from "quasar"; const CodeEditor = defineAsyncComponent(() => - import("components/composer/common/CodeEditor.vue") + import("components/editor/CodeEditor.vue") ); export default defineComponent({ diff --git a/src/components/composer/script/ScriptEditor.vue b/src/components/composer/script/ScriptEditor.vue index 0b5640c..392ee42 100644 --- a/src/components/composer/script/ScriptEditor.vue +++ b/src/components/composer/script/ScriptEditor.vue @@ -127,7 +127,7 @@ @@ -280,6 +315,11 @@ export default defineComponent({ width: 100%; } +.basic-config :deep(.q-field__native), +.basic-config :deep(.q-field__control) { + height: 36px; +} + .command-config :deep(.q-item) { padding: 0; min-height: unset; @@ -314,6 +354,7 @@ export default defineComponent({ .featureIco { cursor: pointer; transition: 0.2s; + margin-right: 10px; } .featureIco:hover { diff --git a/src/components/editor/CommandLanguageBar.vue b/src/components/editor/CommandLanguageBar.vue index daeb744..c1148b2 100644 --- a/src/components/editor/CommandLanguageBar.vue +++ b/src/components/editor/CommandLanguageBar.vue @@ -1,168 +1,231 @@ + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/src/components/editor/CommandSideBar.vue b/src/components/editor/CommandSideBar.vue deleted file mode 100644 index f789559..0000000 --- a/src/components/editor/CommandSideBar.vue +++ /dev/null @@ -1,739 +0,0 @@ - - - - diff --git a/src/components/editor/EditorTools.vue b/src/components/editor/EditorTools.vue index e28058e..d65e97e 100644 --- a/src/components/editor/EditorTools.vue +++ b/src/components/editor/EditorTools.vue @@ -6,20 +6,6 @@ :commandCode="commandCode" @restore="$emit('restore', $event)" /> - - - - {{ - isFullscreen ? "退出全屏 (F11)" : "全屏编辑 (F11)" - }} - @@ -36,12 +22,8 @@ export default { type: String, default: "temp", }, - isFullscreen: { - type: Boolean, - default: false, - }, }, - emits: ["restore", "toggle-fullscreen"], + emits: ["restore"], methods: { showHistory() { this.$refs.history.open(); @@ -58,46 +40,10 @@ export default { position: fixed; right: 24px; bottom: 24px; - z-index: 1000; + z-index: 500; display: flex; flex-direction: column; gap: 12px; transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); } - -.fullscreen-btn { - z-index: 1000; - transform-origin: center; - color: #666; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); - transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); -} - -.fullscreen-btn:hover { - transform: scale(1.1) translateY(-2px); -} - -.fullscreen-btn:active { - transform: scale(0.95); - transition-duration: 0.1s; -} - -.btn-fullscreen { - transform: rotate(180deg); -} - -.btn-fullscreen:hover { - transform: rotate(180deg) scale(1.1); -} - -.body--dark .fullscreen-btn { - background: rgba(255, 255, 255, 0.1); - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); - color: #bbb; -} - -.body--dark .fullscreen-btn:hover { - background: rgba(255, 255, 255, 0.15); - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); -} diff --git a/src/components/editor/MatchRuleEditor.vue b/src/components/editor/MatchRuleEditor.vue index d9f718f..eab92d5 100644 --- a/src/components/editor/MatchRuleEditor.vue +++ b/src/components/editor/MatchRuleEditor.vue @@ -45,34 +45,32 @@ :class="{ 'buttons-visible': isHovering[type.value] }" @mouseleave="setHovering(type.value, false)" > - - - - - + - + + @@ -140,7 +138,7 @@ label="匹配文本正则表达式" placeholder="例:/xxx/,任意匹配的正则会被 uTools 忽略" class="col" - @blur="validateRegex(rule)" + @blur="validateRegex('match', rule)" /> @@ -256,7 +254,7 @@ label="排除的正则表达式字符串" placeholder="可选,例:/xxx/" class="col" - @blur="validateRegex({ match: rule.exclude })" + @blur="validateRegex('exclude', rule)" /> obj[key], rule); + + const matchValue = target[lastKey]; if (!matchValue) return; try { if (!matchValue.startsWith("/")) { - rule.match = `/${matchValue}/`; + target[lastKey] = `/${matchValue}/`; } new RegExp(matchValue.replace(/^\/|\/[gimuy]*$/g, "")); } catch (e) { - rule.match = "/./"; + target[lastKey] = "/./"; } }, @@ -450,7 +452,6 @@ export default defineComponent({ .rule-type-buttons { display: flex; gap: 8px; - justify-content: space-between; } /* 合并按钮基础样式 */ @@ -490,7 +491,7 @@ export default defineComponent({ .key-input-wrapper :deep(.q-icon) { font-size: 16px; opacity: 0.7; - transition: opacity 0.3s; + transition: opacity 0.2s; } .key-input-wrapper :deep(.q-icon:hover) { @@ -518,8 +519,8 @@ export default defineComponent({ .rule-type-btn-wrapper, .btn-container { position: relative; - width: 85px; height: 24px; + flex: 1; } .btn-container { @@ -531,7 +532,7 @@ export default defineComponent({ .rule-type-btn { width: 100%; position: absolute; - transition: opacity 0.3s ease; + transition: opacity 0.2s ease; } .btn-hidden { @@ -544,9 +545,9 @@ export default defineComponent({ position: absolute; inset: 0; display: flex; + gap: 4px; justify-content: center; opacity: 0; - transition: all 0.5s ease; pointer-events: none; } diff --git a/src/components/editor/MonacoEditor.vue b/src/components/editor/MonacoEditor.vue index 4dec0b6..75a8819 100644 --- a/src/components/editor/MonacoEditor.vue +++ b/src/components/editor/MonacoEditor.vue @@ -1,12 +1,17 @@