添加可视化编排的独立入口

This commit is contained in:
fofolee 2025-01-12 15:35:45 +08:00
parent 2fcad53ef9
commit 9df34cfe08
9 changed files with 134 additions and 63 deletions

View File

@ -32,6 +32,15 @@
], ],
"icon": "features/code.png" "icon": "features/code.png"
}, },
{
"code": "composer",
"explain": "运行可视化编排",
"cmds": [
"可视化编排",
"RunComposer"
],
"icon": "features/code.png"
},
{ {
"code": "newcommand", "code": "newcommand",
"explain": "快速新建快捷命令", "explain": "快速新建快捷命令",

View File

@ -38,7 +38,7 @@
@program-changed="programChanged" @program-changed="programChanged"
@run="runCurrentCommand" @run="runCurrentCommand"
@save="saveCurrentCommand" @save="saveCurrentCommand"
@use-composer="handleComposer" @show-composer="showComposer = true"
/> />
<!-- 编辑器 --> <!-- 编辑器 -->
@ -71,6 +71,11 @@
@toggle-fullscreen="toggleFullscreen" @toggle-fullscreen="toggleFullscreen"
/> />
<!-- 可视化编排 -->
<q-dialog v-model="showComposer" maximized>
<CommandComposer ref="composer" @use-composer="handleComposer" />
</q-dialog>
<!-- 运行结果 --> <!-- 运行结果 -->
<CommandRunResult :action="action" ref="result"></CommandRunResult> <CommandRunResult :action="action" ref="result"></CommandRunResult>
</div> </div>
@ -82,6 +87,7 @@ import CommandSideBar from "components/editor/CommandSideBar";
import CommandLanguageBar from "components/editor/CommandLanguageBar"; import CommandLanguageBar from "components/editor/CommandLanguageBar";
import EditorTools from "components/editor/EditorTools"; import EditorTools from "components/editor/EditorTools";
import CommandRunResult from "components/CommandRunResult"; import CommandRunResult from "components/CommandRunResult";
import CommandComposer from "components/composer/CommandComposer.vue";
// MonacoEditor // MonacoEditor
const MonacoEditorPromise = import("components/editor/MonacoEditor"); const MonacoEditorPromise = import("components/editor/MonacoEditor");
@ -108,6 +114,7 @@ export default {
CommandSideBar, CommandSideBar,
CommandRunResult, CommandRunResult,
CommandLanguageBar, CommandLanguageBar,
CommandComposer,
EditorTools, EditorTools,
}, },
data() { data() {
@ -115,7 +122,10 @@ export default {
programLanguages: Object.keys(this.$root.programs), programLanguages: Object.keys(this.$root.programs),
sideBarWidth: 200, sideBarWidth: 200,
languageBarHeight: 40, languageBarHeight: 40,
canCommandSave: this.action.type === "code" ? false : true, showComposer: false,
isRunCodePage: this.action.type === "run",
canCommandSave: this.action.type !== "run",
showSidebar: this.action.type !== "run",
quickcommandInfo: { quickcommandInfo: {
program: "quickcommand", program: "quickcommand",
cmd: "", cmd: "",
@ -131,8 +141,6 @@ export default {
}, },
}, },
resultMaxLength: 10000, resultMaxLength: 10000,
showSidebar: this.action.type !== "run",
isRunCodePage: this.action.type === "run",
listener: null, listener: null,
isFullscreen: false, isFullscreen: false,
}; };
@ -162,8 +170,7 @@ export default {
methods: { methods: {
// //
commandInit() { commandInit() {
let quickCommandInfo = let quickCommandInfo = this.isRunCodePage
this.action.type === "run"
? this.$root.utools.getDB("cfg_codeHistory") ? this.$root.utools.getDB("cfg_codeHistory")
: this.action.data; : this.action.data;
quickCommandInfo?.program && quickCommandInfo?.program &&

View File

@ -0,0 +1,42 @@
<template>
<CommandComposer
ref="composer"
@use-composer="handleComposer"
:show-close-button="false"
class="fixed-full"
/>
<!-- 运行结果 -->
<CommandRunResult :action="action" ref="result"></CommandRunResult>
</template>
<script>
import CommandComposer from "components/composer/CommandComposer.vue";
import CommandRunResult from "components/CommandRunResult";
export default {
components: { CommandComposer, CommandRunResult },
props: {
action: {
type: Object,
required: true,
},
},
methods: {
handleComposer({ type, code }) {
switch (type) {
case "run":
return this.runCurrentCommand(code);
}
},
runCurrentCommand(cmd) {
if (!cmd) return;
let command = {
cmd: cmd,
output: "text",
program: "quickcommand",
};
this.$refs.result.runCurrentCommand(command);
},
},
};
</script>

View File

@ -12,6 +12,7 @@
<ComposerFlow <ComposerFlow
v-model="commandFlow" v-model="commandFlow"
:generate-code="generateFlowCode" :generate-code="generateFlowCode"
:show-close-button="showCloseButton"
@add-command="addCommand" @add-command="addCommand"
@action="handleComposer" @action="handleComposer"
/> />
@ -76,7 +77,13 @@ export default defineComponent({
hasCommandNeedLoading: false, hasCommandNeedLoading: false,
}; };
}, },
emits: ["use-composer", "update:modelValue"], props: {
showCloseButton: {
type: Boolean,
default: true,
},
},
emits: ["use-composer"],
methods: { methods: {
addCommand(action) { addCommand(action) {
let newAction = window.lodashM.cloneDeep(action); let newAction = window.lodashM.cloneDeep(action);
@ -99,8 +106,10 @@ export default defineComponent({
case "run": case "run":
return this.runFlow(flow); return this.runFlow(flow);
default: default:
this.$emit("use-composer", { type, code }); return this.$emit("use-composer", {
return this.$emit("update:modelValue", false); type,
code: this.generateFlowCode(),
});
} }
}, },
// flow // flow

View File

@ -9,6 +9,7 @@
<ComposerButtons <ComposerButtons
:generate-code="generateCode" :generate-code="generateCode"
:is-all-collapsed="isAllCollapsed" :is-all-collapsed="isAllCollapsed"
:show-close-button="showCloseButton"
@action="handleAction" @action="handleAction"
class="flex-grow" class="flex-grow"
/> />
@ -97,6 +98,10 @@ export default defineComponent({
type: Function, type: Function,
required: true, required: true,
}, },
showCloseButton: {
type: Boolean,
default: true,
},
}, },
setup() { setup() {
const getCurrentVariables = inject("getCurrentVariables"); const getCurrentVariables = inject("getCurrentVariables");

View File

@ -22,17 +22,31 @@
v-if="isDev" v-if="isDev"
> >
</q-btn> </q-btn>
<q-btn icon="close" dense flat v-close-popup> <q-btn icon="close" dense flat v-close-popup v-if="showCloseButton">
<q-tooltip>退出可视化编排</q-tooltip> <q-tooltip>退出可视化编排</q-tooltip>
</q-btn> </q-btn>
<q-separator vertical /> <q-separator vertical v-if="showCloseButton" />
<q-btn dense icon="read_more" flat @click="$emit('action', 'insert')"> <q-btn
dense
icon="read_more"
flat
v-close-popup
@click="$emit('action', 'insert')"
v-if="showCloseButton"
>
<q-tooltip>插入到编辑器光标处</q-tooltip> <q-tooltip>插入到编辑器光标处</q-tooltip>
</q-btn> </q-btn>
<q-btn dense flat icon="done_all" @click="$emit('action', 'apply')"> <q-btn
dense
flat
v-close-popup
icon="done_all"
@click="$emit('action', 'apply')"
v-if="showCloseButton"
>
<q-tooltip>清空编辑器内容并插入</q-tooltip> <q-tooltip>清空编辑器内容并插入</q-tooltip>
</q-btn> </q-btn>
<q-separator vertical /> <q-separator vertical v-if="showCloseButton" />
<q-btn dense flat icon="save" @click="$emit('action', 'save')"> <q-btn dense flat icon="save" @click="$emit('action', 'save')">
<q-tooltip>保存</q-tooltip> <q-tooltip>保存</q-tooltip>
</q-btn> </q-btn>
@ -80,6 +94,10 @@ export default defineComponent({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
showCloseButton: {
type: Boolean,
default: true,
},
}, },
emits: ["action"], emits: ["action"],

View File

@ -39,8 +39,6 @@
<template v-if="modelValue.program === 'quickcommand'"> <template v-if="modelValue.program === 'quickcommand'">
<q-btn <q-btn
v-for="(item, index) in [ v-for="(item, index) in [
// 'keyboard',
// 'rocket_launch',
'help_center', 'help_center',
'view_timeline', 'view_timeline',
]" ]"
@ -53,7 +51,6 @@
@click="handleQuickCommandAction(index)" @click="handleQuickCommandAction(index)"
> >
<q-tooltip> <q-tooltip>
<!-- {{ ["录制按键", "快捷动作", "查看文档", "可视化编排"][index] }} -->
{{ ["查看文档", "可视化编排"][index] }} {{ ["查看文档", "可视化编排"][index] }}
</q-tooltip> </q-tooltip>
</q-btn> </q-btn>
@ -161,36 +158,13 @@
></q-btn> ></q-btn>
</q-btn-group> </q-btn-group>
</div> </div>
<!-- 移动对话框到这里 -->
<!-- <q-dialog v-model="showActions">
<QuickAction @addAction="addAction" />
</q-dialog> -->
<!-- <q-dialog v-model="showRecorder" position="bottom">
<KeyRecorder @sendKeys="addAction" />
</q-dialog> -->
<q-dialog v-model="showComposer" maximized>
<CommandComposer
ref="composer"
@use-composer="handleComposer"
@update:model-value="showComposer = false"
/>
</q-dialog>
</div> </div>
</template> </template>
<script> <script>
// import QuickAction from "components/popup/QuickAction";
// import KeyRecorder from "components/popup/KeyRecorder";
import CommandComposer from "components/composer/CommandComposer.vue";
export default { export default {
name: "CommandLanguageBar", name: "CommandLanguageBar",
components: {
// QuickAction,
// KeyRecorder,
CommandComposer,
},
props: { props: {
modelValue: { modelValue: {
type: Object, type: Object,
@ -209,22 +183,12 @@ export default {
default: false, default: false,
}, },
}, },
data() {
return {
// showActions: false,
// showRecorder: false,
showComposer: false,
};
},
emits: [ emits: [
"update:modelValue", "update:modelValue",
"program-changed", "program-changed",
"run", "run",
"save", "save",
// "show-recorder", "show-composer",
// "show-actions",
"show-help",
"use-composer",
], ],
computed: { computed: {
programLanguages() { programLanguages() {
@ -280,23 +244,14 @@ export default {
}, },
handleQuickCommandAction(index) { handleQuickCommandAction(index) {
const actions = [ const actions = [
// () => (this.showRecorder = true),
// () => (this.showActions = true),
() => this.showHelp(), () => this.showHelp(),
() => (this.showComposer = true), () => this.$emit("show-composer"),
]; ];
actions[index](); actions[index]();
}, },
// addAction(text) {
// this.$emit("add-action", text);
// },
showHelp() { showHelp() {
window.showUb.docs(); window.showUb.docs();
}, },
handleComposer({ type, code }) {
this.$emit("use-composer", { type, code });
if (type !== "run") this.showComposer = false;
},
}, },
}; };
</script> </script>

View File

@ -0,0 +1,21 @@
<template>
<div>
<ComposerEditor :action="action"></ComposerEditor>
</div>
</template>
<script>
import ComposerEditor from "components/ComposerEditor";
export default {
components: { ComposerEditor },
data() {
return {
action: {
type: "composer",
data: {},
},
};
},
};
</script>

View File

@ -9,6 +9,11 @@ const routes = [
name: "code", name: "code",
component: () => import("pages/RunCodePage.vue"), component: () => import("pages/RunCodePage.vue"),
}, },
{
path: "/composer",
name: "composer",
component: () => import("pages/RunComposerPage.vue"),
},
{ {
path: "/newcommand", path: "/newcommand",
name: "newcommand", name: "newcommand",