From 9775087310f03804bc5e70fa7e9976644962dad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=9B=E7=9A=93?= Date: Tue, 20 Oct 2020 17:55:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=85=BC=E5=AE=B9=20type:=20group?= =?UTF-8?q?=20=E4=B8=BA=20i18n=20=E6=97=B6=E7=9A=84=E5=9C=BA=E6=99=AF,=20?= =?UTF-8?q?=E6=AF=94=E5=A6=82=20CascadeDateField=20fix:=20=E4=B9=90?= =?UTF-8?q?=E9=AB=98=E5=9B=9E=E6=BB=9A=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/designer/src/document/document-model.ts | 2 +- packages/designer/src/project/project.ts | 5 ++++- packages/editor-preset-vision/src/editor.ts | 5 +++-- packages/react-renderer/package.json | 3 +-- packages/utils/src/misc.ts | 4 ++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/designer/src/document/document-model.ts b/packages/designer/src/document/document-model.ts index de98d964a..ada01657f 100644 --- a/packages/designer/src/document/document-model.ts +++ b/packages/designer/src/document/document-model.ts @@ -274,7 +274,7 @@ export class DocumentModel { if (!node) { return; } - this.internalRemoveAndPurgeNode(node); + this.internalRemoveAndPurgeNode(node, true); } /** diff --git a/packages/designer/src/project/project.ts b/packages/designer/src/project/project.ts index 278d0390b..efa5fef89 100644 --- a/packages/designer/src/project/project.ts +++ b/packages/designer/src/project/project.ts @@ -110,6 +110,7 @@ export class Project { return; } this.documents.splice(index, 1); + this.documentsMap.delete(doc.id); } /** @@ -159,8 +160,10 @@ export class Project { private documentsMap = new Map(); + getDocument(id: string): DocumentModel | null { - return this.documentsMap.get(id) || null; + // 此处不能使用 this.documentsMap.get(id),因为在乐高 rollback 场景,document.id 会被改成其他值 + return this.documents.find(doc => doc.id === id) || null; } createDocument(data?: RootSchema): DocumentModel { diff --git a/packages/editor-preset-vision/src/editor.ts b/packages/editor-preset-vision/src/editor.ts index 076abb036..6a1933c54 100644 --- a/packages/editor-preset-vision/src/editor.ts +++ b/packages/editor-preset-vision/src/editor.ts @@ -1,5 +1,5 @@ import { isJSBlock, isJSExpression, isJSSlot } from '@ali/lowcode-types'; -import { isPlainObject, hasOwnProperty, cloneDeep, isI18NObject, isUseI18NSetter, convertToI18NObject } from '@ali/lowcode-utils'; +import { isPlainObject, hasOwnProperty, cloneDeep, isI18NObject, isUseI18NSetter, convertToI18NObject, isString } from '@ali/lowcode-utils'; import { globalContext, Editor } from '@ali/lowcode-editor-core'; import { Designer, LiveEditing, TransformStage, Node, getConvertedExtraKey } from '@ali/lowcode-designer'; import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane'; @@ -126,7 +126,8 @@ designer.addPropsReducer((props, node) => { !isJSExpression(ov) && !isJSBlock(ov) && !isJSSlot(ov) && - !isVariable(ov)) { + !isVariable(ov) && + isString(v)) { newProps[item.name] = convertToI18NObject(v); } } catch (e) { diff --git a/packages/react-renderer/package.json b/packages/react-renderer/package.json index 608409dda..37aa717cc 100644 --- a/packages/react-renderer/package.json +++ b/packages/react-renderer/package.json @@ -53,6 +53,5 @@ }, "publishConfig": { "registry": "http://registry.npm.alibaba-inc.com" - }, - "homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-2/build/index.html" + } } diff --git a/packages/utils/src/misc.ts b/packages/utils/src/misc.ts index e059a062d..bf2883ece 100644 --- a/packages/utils/src/misc.ts +++ b/packages/utils/src/misc.ts @@ -15,3 +15,7 @@ export function convertToI18NObject(v: string | object, locale: string = 'zh_CN' if (isI18NObject(v)) return v; return { type: 'i18n', use: locale, [locale]: v }; } + +export function isString(v: any): v is string { + return typeof v === 'string'; +} \ No newline at end of file