mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix(Data-templates): avoid errors and add log
This commit is contained in:
parent
58fda41513
commit
a0dd58e7e3
@ -1,5 +1,5 @@
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import { forEach, showToast } from '@nocobase/utils/client';
|
||||
import { error, forEach, showToast } from '@nocobase/utils/client';
|
||||
import { Select } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useCallback, useEffect } from 'react';
|
||||
@ -29,15 +29,20 @@ const useDataTemplates = () => {
|
||||
|
||||
// 过滤掉已经被删除的字段
|
||||
items.forEach((item) => {
|
||||
item.fields = item.fields
|
||||
.map((field) => {
|
||||
const joinField = getCollectionJoinField(`${item.collection}.${field}`);
|
||||
if (joinField) {
|
||||
return field;
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean);
|
||||
try {
|
||||
item.fields = item.fields
|
||||
.map((field) => {
|
||||
const joinField = getCollectionJoinField(`${item.collection}.${field}`);
|
||||
if (joinField) {
|
||||
return field;
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean);
|
||||
} catch (err) {
|
||||
error(err);
|
||||
item.fields = [];
|
||||
}
|
||||
});
|
||||
|
||||
const templates: any = [
|
||||
|
@ -4,6 +4,7 @@ export * from './date';
|
||||
export * from './forEach';
|
||||
export * from './getValuesByPath';
|
||||
export * from './json-templates';
|
||||
export * from './log';
|
||||
export * from './merge';
|
||||
export * from './notification';
|
||||
export * from './number';
|
||||
|
3
packages/core/utils/src/log.ts
Normal file
3
packages/core/utils/src/log.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export const error = (message: Error | string, ...args: any[]) => {
|
||||
console.error(message, ...args);
|
||||
};
|
Loading…
Reference in New Issue
Block a user