From a452cecc444a155efa1a7a25391125b03677ffe7 Mon Sep 17 00:00:00 2001 From: parisma Date: Fri, 16 Sep 2022 17:24:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E4=BF=AE=E6=94=B9=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F,=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E5=9D=97ID?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/fields/CodeSelect.vue | 38 ++--- .../sidebar/code-block/CodeBlockEditor.vue | 100 ++++++------- .../sidebar/code-block/CodeBlockList.vue | 2 +- packages/editor/src/services/codeBlock.ts | 2 +- packages/editor/src/theme/code-block.scss | 135 ++++++++++++------ playground/src/configs/dsl.ts | 4 +- 6 files changed, 167 insertions(+), 114 deletions(-) diff --git a/packages/editor/src/fields/CodeSelect.vue b/packages/editor/src/fields/CodeSelect.vue index ea98a485..9a8b337a 100644 --- a/packages/editor/src/fields/CodeSelect.vue +++ b/packages/editor/src/fields/CodeSelect.vue @@ -1,21 +1,27 @@ diff --git a/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue b/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue index a3ff580c..58739e16 100644 --- a/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue +++ b/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue @@ -1,70 +1,72 @@ diff --git a/packages/editor/src/layouts/sidebar/code-block/CodeBlockList.vue b/packages/editor/src/layouts/sidebar/code-block/CodeBlockList.vue index fdf3af01..44668cd1 100644 --- a/packages/editor/src/layouts/sidebar/code-block/CodeBlockList.vue +++ b/packages/editor/src/layouts/sidebar/code-block/CodeBlockList.vue @@ -8,7 +8,7 @@ placeholder="输入关键字进行过滤" clearable v-model="filterText" - @change="filterTextChangeHandler" + @input="filterTextChangeHandler" > 新增 { - const newId = (Date.now().toString(36) + Math.random().toString(36).substring(2)).padEnd(19, '0'); + const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`; // 判断是否重复 const dsl = await this.getCodeDsl(); const existedIds = keys(dsl); diff --git a/packages/editor/src/theme/code-block.scss b/packages/editor/src/theme/code-block.scss index dcf21910..361049ab 100644 --- a/packages/editor/src/theme/code-block.scss +++ b/packages/editor/src/theme/code-block.scss @@ -50,67 +50,112 @@ } } } -.m-editor-code-block-editor-panel { - position: absolute; - top: 0; - left: 4px; - width: 100%; - height: 100%; - z-index: 10; - background: #fff; - .code-name-wrapper { - padding: 10px 20px; +.m-fields-code-select { + width: 100%; + .el-card__body { + padding: 10px; + } + .tool-bar { display: flex; align-items: center; + justify-content: end; } - - .m-editor-content-bottom { - text-align: right; - padding-right: 20px; - height: 40px; - position: absolute; - width: 100%; - display: flex; - justify-content: center; - bottom: 0; - right: 0; - background: #fff; - > button { - height: 30px; - margin-top: 4px; - } - } -} -.m-fields-code-select { - display: flex; - width: 100%; - align-items: center; } .code-editor-dialog { .el-dialog__body { height: 90%; } - .code-editor-side-menu { - width: 18%; - height: 90%; - overflow: auto; - margin-left: -25px; + .el-card { + height: 100%; + background: #fff; + .el-card__body { + height: 80%; + background: #fff; + } + } - .list-item { - width: 100%; - margin: 10px 0; - .code-name { + .code-editor-side-menu { + width: 20%; + position: absolute; + top: 0; + left: 0; + background: #fff; + + .side-tree { + margin-top: 10px; + .list-container { width: 100%; - font-size: 14px; + overflow: hidden; + margin-left: -20px; + .list-item { + width: 100%; + margin: 10px 0; + line-height: 30px; + .code-name { + width: 100%; + font-size: 14px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + } } } } + + .code-name-wrapper { + margin: 10px 0 10px 10px; + display: flex; + align-items: center; + .code-name-label { + width: 80px; + } + .code-name-input { + width: 300px; + } + } + .m-editor-code-block-editor-panel-list-mode { - width: 80%; position: absolute; - height: 90%; + top: 0; left: 20%; - top: 60px; + width: 80%; + height: 100%; + z-index: 10; + background: #fff; + } + + .m-editor-code-block-editor-panel { + position: absolute; + top: 0; + left: 4px; + width: 100%; + height: 100%; + z-index: 10; + background: #fff; + } + + .m-editor-wrapper { + height: 100%; + .m-editor-container { + height: 100%; + } + .m-editor-content-bottom { + text-align: right; + height: 40px; + padding-right: 20px; + position: absolute; + width: calc(100% - 30px); + display: flex; + justify-content: end; + bottom: 20px; + right: 0; + background: #fff; + > button { + height: 30px; + margin-top: 5px; + } + } } } diff --git a/playground/src/configs/dsl.ts b/playground/src/configs/dsl.ts index 0483697d..36f8b5fb 100644 --- a/playground/src/configs/dsl.ts +++ b/playground/src/configs/dsl.ts @@ -21,7 +21,7 @@ export default { name: 'test', type: 'app', methods: { - l7znj1q24wilb357ay6: { + code_5336: { name: 'getData', // eslint-disable-next-line no-eval content: eval(`(vm) => {\n console.log("this is getData function")\n}`), @@ -51,7 +51,7 @@ export default { fontWeight: '', }, events: [], - created: ['l7znj1q24wilb357ay6'], + created: ['code_5336'], items: [ { type: 'text',