From 386d120ab77b8526539d7de1fb55c97c51ec54e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=9B=E7=9A=93?= Date: Mon, 1 Feb 2021 10:57:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20vc-live-editing=20?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E9=80=BB=E8=BE=91(=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E8=A6=81=E5=BC=80=E4=B8=AA=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=E8=AE=A9=E7=94=A8=E6=88=B7=E9=80=89=E6=8B=A9=E7=89=88?= =?UTF-8?q?=E6=9C=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builtin-simulator/live-editing/live-editing.ts | 12 ++++++++++-- packages/vision-polyfill/src/reducers.ts | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/designer/src/builtin-simulator/live-editing/live-editing.ts b/packages/designer/src/builtin-simulator/live-editing/live-editing.ts index 5cf78090d..58cc17739 100644 --- a/packages/designer/src/builtin-simulator/live-editing/live-editing.ts +++ b/packages/designer/src/builtin-simulator/live-editing/live-editing.ts @@ -22,20 +22,28 @@ export interface EditingTarget { event: MouseEvent; } -const saveHandlers: SaveHandler[] = []; +let saveHandlers: SaveHandler[] = []; function addLiveEditingSaveHandler(handler: SaveHandler) { saveHandlers.push(handler); } +function clearLiveEditingSaveHandler() { + saveHandlers = []; +} -const specificRules: SpecificRule[] = []; +let specificRules: SpecificRule[] = []; function addLiveEditingSpecificRule(rule: SpecificRule) { specificRules.push(rule); } +function clearLiveEditingSpecificRule() { + specificRules = []; +} export class LiveEditing { static addLiveEditingSpecificRule = addLiveEditingSpecificRule; + static clearLiveEditingSpecificRule = clearLiveEditingSpecificRule; static addLiveEditingSaveHandler = addLiveEditingSaveHandler; + static clearLiveEditingSaveHandler = clearLiveEditingSaveHandler; @obx.ref private _editing: Prop | null = null; diff --git a/packages/vision-polyfill/src/reducers.ts b/packages/vision-polyfill/src/reducers.ts index 4c3c5c12a..8c5f488b3 100644 --- a/packages/vision-polyfill/src/reducers.ts +++ b/packages/vision-polyfill/src/reducers.ts @@ -1,5 +1,3 @@ -import { isJSBlock, isJSExpression, isJSSlot } from '@ali/lowcode-types'; -import { isPlainObject, hasOwnProperty, cloneDeep, isI18NObject, isUseI18NSetter, convertToI18NObject, isString } from '@ali/lowcode-utils'; import { editor, designer, designerCabin } from '@ali/lowcode-engine'; import bus from './bus'; import { VE_EVENTS } from './base/const'; @@ -20,6 +18,9 @@ import { const { LiveEditing, TransformStage } = designerCabin; +// 清理引擎自带的规则和保存函数,会影响 vc i18n 的保存 +LiveEditing.clearLiveEditingSpecificRule(); +LiveEditing.clearLiveEditingSaveHandler(); LiveEditing.addLiveEditingSpecificRule(liveEditingRule); LiveEditing.addLiveEditingSaveHandler(liveEditingSaveHander);