From ef7e678239d06cde8ebf69a7c54cfcbd7a534d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=A4=9A=E7=9B=8A?= Date: Wed, 8 Jun 2022 20:51:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20app=20=E7=9A=84=20a?= =?UTF-8?q?pi=20=E4=B8=8D=E6=94=AF=E6=8C=81=E6=96=87=E6=9C=AC=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E9=97=AE=E9=A2=98=20Closed=20#4537=20(#4563)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/utils/replaceText.ts | 4 ++-- packages/amis/src/renderers/App.tsx | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/amis-core/src/utils/replaceText.ts b/packages/amis-core/src/utils/replaceText.ts index 2df066994..b1c74d20b 100644 --- a/packages/amis-core/src/utils/replaceText.ts +++ b/packages/amis-core/src/utils/replaceText.ts @@ -6,8 +6,8 @@ import {isObject, JSONTraverse} from './helper'; export function replaceText( schema: any, - replaceText: {[propName: string]: string}, - replaceTextIgnoreKeys: String[] + replaceText?: {[propName: string]: string}, + replaceTextIgnoreKeys?: String[] ) { // 进行文本替换 if (replaceText && isObject(replaceText)) { diff --git a/packages/amis/src/renderers/App.tsx b/packages/amis/src/renderers/App.tsx index 1cbfa2191..a6c06bbce 100644 --- a/packages/amis/src/renderers/App.tsx +++ b/packages/amis/src/renderers/App.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {AsideNav, Html, NotFound, Spinner} from 'amis-ui'; import {Layout} from 'amis-ui'; -import {Renderer, RendererProps} from 'amis-core'; +import {Renderer, RendererProps, replaceText} from 'amis-core'; import { BaseSchema, SchemaApi, @@ -197,6 +197,10 @@ export default class App extends React.Component { if (isEffectiveApi(api, store.data)) { const json = await store.fetchInitData(api, store.data, {}); + if (env.replaceText) { + replaceText(json.data, env.replaceText, env.replaceTextIgnoreKeys); + } + if (json?.data.pages) { store.setPages(json.data.pages); store.updateActivePage(env);