命令配置页面加入新建可视化编排的入口

This commit is contained in:
fofolee 2025-02-10 00:04:45 +08:00
parent e3d399af4e
commit 63635fe933
4 changed files with 166 additions and 190 deletions

View File

@ -1,84 +1,74 @@
<template> <template>
<div <!-- 命令设置栏 -->
class="command-editor-container" <CommandSideBar
:class="{ leaving: isLeaving, 'run-code': isRunCodePage }" ref="sidebar"
@animationend="$emit('animationend')" :canCommandSave="canCommandSave"
> :quickcommandInfo="quickcommandInfo"
<!-- 命令设置栏 --> class="absolute-left shadow-1"
<CommandSideBar :style="{
ref="sidebar" width: sideBarWidth + 'px',
:canCommandSave="canCommandSave" zIndex: 1,
:quickcommandInfo="quickcommandInfo" transform: isFullscreen ? 'translateX(-100%)' : 'translateX(0)',
class="absolute-left shadow-1" transition: 'transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
:style="{ }"
width: sideBarWidth + 'px', :sideBarWidth="sideBarWidth"
zIndex: 1, v-if="showSidebar"
transform: isFullscreen ? 'translateX(-100%)' : 'translateX(0)', @back="handleBack"
transition: 'transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)', ></CommandSideBar>
}"
:sideBarWidth="sideBarWidth"
v-if="showSidebar"
@back="handleBack"
></CommandSideBar>
<!-- 编程语言栏 --> <!-- 编程语言栏 -->
<CommandLanguageBar <CommandLanguageBar
class="absolute-top" class="absolute-top"
:style="{ :style="{
left: showSidebar ? sideBarWidth + 'px' : 65, left: showSidebar ? sideBarWidth + 'px' : 65,
zIndex: 1, zIndex: 1,
transform: isFullscreen ? 'translateY(-100%)' : 'translateY(0)', transform: isFullscreen ? 'translateY(-100%)' : 'translateY(0)',
opacity: isFullscreen ? 0 : 1, opacity: isFullscreen ? 0 : 1,
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)', transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
}" }"
v-model="quickcommandInfo" v-model="quickcommandInfo"
:height="languageBarHeight" :height="languageBarHeight"
:canCommandSave="canCommandSave" :canCommandSave="canCommandSave"
:isRunCodePage="isRunCodePage" :isRunCodePage="isRunCodePage"
@program-changed="programChanged" @program-changed="programChanged"
@run="runCurrentCommand" @run="runCurrentCommand"
@save="saveCurrentCommand" @save="saveCurrentCommand"
@show-composer="showComposer = true" @show-composer="showComposer = true"
/> />
<!-- 编辑器 --> <!-- 编辑器 -->
<MonacoEditor <MonacoEditor
class="editor-transition" class="editor-transition"
:placeholder="true" :placeholder="true"
ref="editor" ref="editor"
@loaded="monacoInit" @loaded="monacoInit"
@typing="(val) => monacoTyping(val)" @typing="(val) => monacoTyping(val)"
@keyStroke="monacoKeyStroke" @keyStroke="monacoKeyStroke"
:style="{ :style="{
position: 'absolute', position: 'absolute',
top: isFullscreen ? 0 : languageBarHeight + 'px', top: isFullscreen ? 0 : languageBarHeight + 'px',
left: isFullscreen left: isFullscreen ? 0 : action.type === 'run' ? 0 : sideBarWidth + 'px',
? 0 right: 0,
: action.type === 'run' bottom: 0,
? 0 }"
: sideBarWidth + 'px', />
right: 0,
bottom: 0,
}"
/>
<!-- 编辑器工具按钮组 --> <!-- 编辑器工具按钮组 -->
<EditorTools <EditorTools
ref="editorTools" ref="editorTools"
:commandCode="quickcommandInfo?.features?.code || 'temp'" :commandCode="quickcommandInfo?.features?.code || 'temp'"
:isFullscreen="isFullscreen" :isFullscreen="isFullscreen"
@restore="restoreHistory" @restore="restoreHistory"
@toggle-fullscreen="toggleFullscreen" @toggle-fullscreen="toggleFullscreen"
/> />
<!-- 可视化编排 --> <!-- 可视化编排 -->
<q-dialog v-model="showComposer" maximized> <q-dialog v-model="showComposer" maximized>
<CommandComposer ref="composer" @use-composer="handleComposer" /> <CommandComposer ref="composer" @use-composer="handleComposer" />
</q-dialog> </q-dialog>
<!-- 运行结果 --> <!-- 运行结果 -->
<CommandRunResult :action="action" ref="result"></CommandRunResult> <CommandRunResult :action="action" ref="result"></CommandRunResult>
</div>
</template> </template>
<script> <script>
@ -338,72 +328,4 @@ export default {
transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
will-change: transform, left, top, opacity; will-change: transform, left, top, opacity;
} }
.command-editor-container {
color: black;
background: white;
overflow: hidden;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 5000;
background: var(--q-page-background);
animation: slideUpDefault 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.command-editor-container.run-code {
animation: none;
}
.command-editor-container.leaving {
animation: slideDownOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
background: transparent;
}
.command-editor-container.leaving.run-code {
animation: slideUpOut 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideUpDefault {
from {
transform: translateY(100%);
}
to {
transform: translateY(0);
}
}
@keyframes slideDownIn {
from {
transform: translateY(-100%);
}
to {
transform: translateY(0);
}
}
@keyframes slideDownOut {
from {
transform: translateY(0);
}
to {
transform: translateY(100%);
}
}
@keyframes slideUpOut {
from {
transform: translateY(0);
}
to {
transform: translateY(-100%);
}
}
.body--dark .command-editor-container {
color: white;
background: var(--q-dark-page);
}
</style> </style>

View File

@ -1,7 +1,9 @@
<template> <template>
<div class="composer-buttons"> <div class="composer-buttons">
<div class="right-buttons"> <div class="right-buttons">
<q-separator vertical /> <q-btn icon="close" dense flat v-close-popup v-if="showCloseButton">
<q-tooltip>退出可视化编排</q-tooltip>
</q-btn>
<q-btn <q-btn
:icon="isAllCollapsed ? 'unfold_more' : 'unfold_less'" :icon="isAllCollapsed ? 'unfold_more' : 'unfold_less'"
dense dense
@ -10,7 +12,6 @@
> >
<q-tooltip>{{ isAllCollapsed ? "展开所有" : "折叠所有" }}</q-tooltip> <q-tooltip>{{ isAllCollapsed ? "展开所有" : "折叠所有" }}</q-tooltip>
</q-btn> </q-btn>
<q-separator vertical />
<q-btn <q-btn
icon="settings" icon="settings"
dense dense
@ -19,7 +20,6 @@
> >
<q-tooltip>流程管理</q-tooltip> <q-tooltip>流程管理</q-tooltip>
</q-btn> </q-btn>
<q-separator vertical />
<q-btn <q-btn
@click="$q.dark.toggle()" @click="$q.dark.toggle()"
:icon="$q.dark.isActive ? 'dark_mode' : 'light_mode'" :icon="$q.dark.isActive ? 'dark_mode' : 'light_mode'"
@ -28,11 +28,7 @@
v-if="isDev" v-if="isDev"
> >
</q-btn> </q-btn>
<q-btn icon="close" dense flat v-close-popup v-if="showCloseButton"> <!-- <q-btn
<q-tooltip>退出可视化编排</q-tooltip>
</q-btn>
<q-separator vertical v-if="showCloseButton" />
<q-btn
dense dense
icon="read_more" icon="read_more"
flat flat
@ -41,7 +37,7 @@
v-if="showCloseButton" v-if="showCloseButton"
> >
<q-tooltip>插入到编辑器光标处</q-tooltip> <q-tooltip>插入到编辑器光标处</q-tooltip>
</q-btn> </q-btn> -->
<q-btn <q-btn
dense dense
flat flat
@ -52,14 +48,12 @@
> >
<q-tooltip>清空编辑器内容并插入</q-tooltip> <q-tooltip>清空编辑器内容并插入</q-tooltip>
</q-btn> </q-btn>
<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>
<q-btn dense flat icon="history" @click="$emit('action', 'load')"> <q-btn dense flat icon="history" @click="$emit('action', 'load')">
<q-tooltip>载入</q-tooltip> <q-tooltip>载入</q-tooltip>
</q-btn> </q-btn>
<q-separator vertical />
<q-btn flat dense icon="preview" @click="isVisible = true"> <q-btn flat dense icon="preview" @click="isVisible = true">
<q-tooltip>预览代码</q-tooltip> <q-tooltip>预览代码</q-tooltip>
</q-btn> </q-btn>

View File

@ -68,20 +68,32 @@
flat flat
@click="goShareCenter" @click="goShareCenter"
color="primary" color="primary"
label="分享中心"
icon="groups" icon="groups"
class="share-btn" class="share-btn"
/> >
<q-tooltip>分享中心</q-tooltip>
</q-btn>
<!-- 新建按钮 --> <!-- 新建按钮 -->
<q-btn <q-btn
split split
flat flat
@click="$emit('add-new')" @click="$emit('add-new', 'CommandEditor')"
color="primary" color="primary"
label="新建"
icon="add"
class="new-btn" class="new-btn"
/> >
<q-icon name="code" class="icon-with-badge" />
<q-tooltip>新建命令直接编写脚本</q-tooltip>
</q-btn>
<q-btn
split
flat
@click="$emit('add-new', 'ComposerEditor')"
color="primary"
class="new-btn"
>
<q-icon name="view_timeline" class="icon-with-badge" />
<q-tooltip>新建命令可视化编排</q-tooltip>
</q-btn>
<!-- 菜单按钮 --> <!-- 菜单按钮 -->
<q-btn <q-btn
stretch stretch
@ -226,4 +238,28 @@ export default {
animation: searchIconShake 0.8s ease; animation: searchIconShake 0.8s ease;
color: var(--q-primary); color: var(--q-primary);
} }
/* 图标角标样式 */
.icon-with-badge {
position: relative;
}
.icon-with-badge::after {
content: "+";
position: absolute;
top: 4px;
right: 4px;
transform: translate(50%, -50%);
background-color: var(--q-primary);
color: white;
width: 14px;
height: 14px;
border-radius: 50%;
font-size: 12px;
font-weight: bold;
display: grid;
place-items: center;
font-family: monospace;
line-height: 0;
}
</style> </style>

View File

@ -1,10 +1,7 @@
<template> <template>
<div class="config-page-container"> <div class="config-page-container">
<!-- 主界面内容 --> <!-- 主界面内容 -->
<div <div class="main-content">
class="main-content"
:class="{ hide: isCommandEditorShow && !isEditorLeaving }"
>
<BackgroundLayer /> <BackgroundLayer />
<!-- 标签栏 --> <!-- 标签栏 -->
<TagBar <TagBar
@ -39,15 +36,16 @@
</div> </div>
<!-- 命令编辑界面 --> <!-- 命令编辑界面 -->
<CommandEditor <transition name="slide">
v-if="isCommandEditorShow" <div v-if="isEditorShow" class="editor-container">
ref="commandEditor" <component
:action="commandEditorAction" :is="commandEditorAction.data.component"
@editorEvent="editorEvent" :action="commandEditorAction"
:allQuickCommandTags="allQuickCommandTags" @editorEvent="editorEvent"
:isLeaving="isEditorLeaving" :allQuickCommandTags="allQuickCommandTags"
@animationend="handleAnimationEnd" />
></CommandEditor> </div>
</transition>
<CommandRunResult <CommandRunResult
:action="{ type: 'config' }" :action="{ type: 'config' }"
@ -63,6 +61,7 @@ import importAll from "js/common/importAll.js";
import changeLog from "js/options/changeLog.js"; import changeLog from "js/options/changeLog.js";
import pinyinMatch from "pinyin-match"; import pinyinMatch from "pinyin-match";
import CommandEditor from "components/CommandEditor"; import CommandEditor from "components/CommandEditor";
import ComposerEditor from "components/ComposerEditor";
import FooterBar from "src/components/config/FooterBar.vue"; import FooterBar from "src/components/config/FooterBar.vue";
import TagBar from "src/components/config/TagBar.vue"; import TagBar from "src/components/config/TagBar.vue";
import BackgroundLayer from "src/components/config/BackgroundLayer.vue"; import BackgroundLayer from "src/components/config/BackgroundLayer.vue";
@ -78,6 +77,7 @@ let defaultCommands = importAll(require.context("../json/", false, /\.json$/));
export default { export default {
components: { components: {
CommandEditor, CommandEditor,
ComposerEditor,
CommandRunResult, CommandRunResult,
FooterBar, FooterBar,
TagBar, TagBar,
@ -93,10 +93,9 @@ export default {
allQuickCommands: {}, allQuickCommands: {},
allQuickCommandTags: [], allQuickCommandTags: [],
commandSearchKeyword: "", commandSearchKeyword: "",
isCommandEditorShow: false, isEditorShow: false,
commandEditorAction: {}, commandEditorAction: {},
footerBarHeight: "40px", footerBarHeight: "40px",
isEditorLeaving: false,
}; };
}, },
computed: { computed: {
@ -286,7 +285,7 @@ export default {
type: "edit", type: "edit",
data: window.lodashM.cloneDeep(command), data: window.lodashM.cloneDeep(command),
}; };
this.isCommandEditorShow = true; this.isEditorShow = true;
}, },
// //
isDefaultCommand(code) { isDefaultCommand(code) {
@ -419,12 +418,14 @@ export default {
} }
}, },
// //
addNewCommand() { addNewCommand(component = "CommandEditor") {
this.commandEditorAction = { this.commandEditorAction = {
type: "new", type: "new",
data: {}, data: {
component,
},
}; };
this.isCommandEditorShow = true; this.isEditorShow = true;
}, },
saveCommand(command) { saveCommand(command) {
let code = command.features.code; let code = command.features.code;
@ -444,7 +445,7 @@ export default {
this.saveCommand(event.data); this.saveCommand(event.data);
break; break;
case "back": case "back":
this.isEditorLeaving = true; this.isEditorShow = false;
break; break;
default: default:
return; return;
@ -470,12 +471,6 @@ export default {
); );
} }
}, },
handleAnimationEnd(e) {
if (this.isEditorLeaving) {
this.isEditorLeaving = false;
this.isCommandEditorShow = false;
}
},
handleCommandsReorder({ tag, commands }) { handleCommandsReorder({ tag, commands }) {
// tag // tag
const tagCommands = {}; const tagCommands = {};
@ -522,11 +517,40 @@ export default {
background: transparent; background: transparent;
} }
.main-content { .editor-container {
transition: opacity 0.3s ease; color: black;
background: white;
overflow: hidden;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 5000;
background: var(--q-page-background);
} }
.main-content.hide { .body--dark .editor-container {
opacity: 0; color: white;
background: var(--q-dark-page);
}
/* 编辑器容器动画 */
.slide-enter-active,
.slide-leave-active {
transition: transform 0.3s ease-in-out;
}
.slide-enter-from {
transform: translateY(100%);
}
.slide-leave-to {
transform: translateY(100%);
}
.slide-enter-to,
.slide-leave-from {
transform: translateY(0);
} }
</style> </style>