mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
Merge pull request #8359 from igrowp/fix-formula-control
fix: nextjs13环境下formulaControl组件popOverContainer 写死,导致编辑器出现死循环bug Close:#8355
This commit is contained in:
commit
9647a54d78
@ -1587,7 +1587,7 @@ export function mapObject(
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(item => mapObject(item, fn));
|
||||
return value.map(item => mapObject(item, fn, skipFn));
|
||||
}
|
||||
|
||||
if (isObject(value)) {
|
||||
@ -1595,7 +1595,8 @@ export function mapObject(
|
||||
Object.keys(tmpValue).forEach(key => {
|
||||
(tmpValue as PlainObject)[key] = mapObject(
|
||||
(tmpValue as PlainObject)[key],
|
||||
fn
|
||||
fn,
|
||||
skipFn
|
||||
);
|
||||
});
|
||||
return tmpValue;
|
||||
|
@ -1063,14 +1063,12 @@ export function getI18nEnabled() {
|
||||
}
|
||||
|
||||
/** schema 翻译方法 */
|
||||
export function translateSchema(schema: any, replaceData?: any) {
|
||||
export function translateSchema(schema: any, replaceData?: any, skipFn?: any) {
|
||||
replaceData = replaceData || (window as any)?.editorStore?.appCorpusData;
|
||||
if (!isPlainObject(replaceData)) {
|
||||
return schema;
|
||||
}
|
||||
return mapObject(schema, (item: any) => {
|
||||
return replaceData[item] || item;
|
||||
});
|
||||
return mapObject(schema, (item: any) => replaceData[item] || item, skipFn);
|
||||
}
|
||||
|
||||
/** 应用级别的翻译方法 */
|
||||
|
@ -516,15 +516,23 @@ export default class FormulaControl extends React.Component<
|
||||
curRendererSchema.placeholder = '请输入静态值';
|
||||
}
|
||||
// 设置popOverContainer
|
||||
curRendererSchema.popOverContainer = window.document.body;
|
||||
if (!curRendererSchema.popOverContainer) {
|
||||
curRendererSchema.popOverContainer = window.document.body;
|
||||
}
|
||||
}
|
||||
|
||||
JSONPipeOut(curRendererSchema);
|
||||
|
||||
// 对 schema 进行国际化翻译
|
||||
if (this.appLocale && this.appCorpusData) {
|
||||
return translateSchema(curRendererSchema, this.appCorpusData);
|
||||
translateSchema(
|
||||
curRendererSchema,
|
||||
this.appCorpusData,
|
||||
(item: any) => item.__reactFiber || item.__reactProp // 在nextjs 13中,window.document.body对象,有__reactFiber,__reactProp 两个子对象,递归遍历会导致死循环,因此过滤掉
|
||||
);
|
||||
}
|
||||
|
||||
return JSONPipeOut(curRendererSchema);
|
||||
return curRendererSchema;
|
||||
}
|
||||
|
||||
@autobind
|
||||
|
Loading…
Reference in New Issue
Block a user