fix: 修复 app 的 api 不支持文本替换问题 Closed #4537 (#4563)

This commit is contained in:
吴多益 2022-06-08 20:51:15 +08:00 committed by GitHub
parent fbeb0bfbb2
commit ef7e678239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -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)) {

View File

@ -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<AppProps, object> {
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);