From 2cc849e55c7fa81914779aa6995d922ebc72ac57 Mon Sep 17 00:00:00 2001 From: wangyuzhen01 Date: Tue, 17 Jan 2023 17:56:53 +0800 Subject: [PATCH] =?UTF-8?q?amis-saas-8146=201.=20=E6=9B=B4=E6=94=B9=20i18n?= =?UTF-8?q?Enabled=20=E7=9A=84=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie1c65b3e42054abf3522cd5101513288cc82507d --- packages/amis-editor-core/src/component/Editor.tsx | 3 ++- packages/amis-editor-core/src/store/editor.ts | 2 ++ packages/amis-editor-core/src/util.ts | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor-core/src/component/Editor.tsx b/packages/amis-editor-core/src/component/Editor.tsx index 98a18c52c..7d0da9116 100644 --- a/packages/amis-editor-core/src/component/Editor.tsx +++ b/packages/amis-editor-core/src/component/Editor.tsx @@ -141,7 +141,8 @@ export default class Editor extends Component { ctx: props.ctx, superEditorData, appLocale: props.appLocale, - appCorpusData: props?.amisEnv?.replaceText + appCorpusData: props?.amisEnv?.replaceText, + i18nEnabled: props?.i18nEnabled ?? false }, config ); diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index 8cc96d79c..fc428a286 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -202,6 +202,8 @@ export const MainStore = types targetNames: types.optional(types.array(types.frozen()), []), ctx: types.frozen(), + /** 是否开启应用多语言 */ + i18nEnabled: types.optional(types.boolean, false), /** 应用语言 */ appLocale: types.optional(types.string, 'zh-CN'), /** 应用语料 */ diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index ed4a23be1..3d8dd46c5 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -1030,6 +1030,11 @@ export function needDefaultWidth(elemType: string) { return false; } +/** 是否开启应用国际化 */ +export function getI18nEnabled() { + return (window as any)?.editorStore?.i18nEnabled ?? false; +} + /** schema 翻译方法 */ export function translateSchema(schema: any, replaceData?: any) { replaceData = replaceData || (window as any)?.editorStore?.appCorpusData; @@ -1050,7 +1055,10 @@ export function needFillPlaceholder(curProps: any) { return false; } // 识别page中的aside、body - if (curProps.rendererName === 'page' && (curProps.name === 'aside' || curProps.name === 'body')) { + if ( + curProps.rendererName === 'page' && + (curProps.name === 'aside' || curProps.name === 'body') + ) { return true; } // 识别自由容器 @@ -1060,7 +1068,7 @@ export function needFillPlaceholder(curProps: any) { // 支持在plugin中配置 if (curProps.$$editor?.needFillPlaceholder) { needFillPlaceholder = true; - } else if (curProps.regionConfig?.needFillPlaceholder ) { + } else if (curProps.regionConfig?.needFillPlaceholder) { needFillPlaceholder = true; } return needFillPlaceholder;