fix(Data-templates): avoid errors and add log

This commit is contained in:
Rairn 2023-05-23 16:18:01 +08:00
parent 58fda41513
commit a0dd58e7e3
3 changed files with 19 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import { useFieldSchema } from '@formily/react'; 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 { Select } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import React, { useCallback, useEffect } from 'react'; import React, { useCallback, useEffect } from 'react';
@ -29,6 +29,7 @@ const useDataTemplates = () => {
// 过滤掉已经被删除的字段 // 过滤掉已经被删除的字段
items.forEach((item) => { items.forEach((item) => {
try {
item.fields = item.fields item.fields = item.fields
.map((field) => { .map((field) => {
const joinField = getCollectionJoinField(`${item.collection}.${field}`); const joinField = getCollectionJoinField(`${item.collection}.${field}`);
@ -38,6 +39,10 @@ const useDataTemplates = () => {
return ''; return '';
}) })
.filter(Boolean); .filter(Boolean);
} catch (err) {
error(err);
item.fields = [];
}
}); });
const templates: any = [ const templates: any = [

View File

@ -4,6 +4,7 @@ export * from './date';
export * from './forEach'; export * from './forEach';
export * from './getValuesByPath'; export * from './getValuesByPath';
export * from './json-templates'; export * from './json-templates';
export * from './log';
export * from './merge'; export * from './merge';
export * from './notification'; export * from './notification';
export * from './number'; export * from './number';

View File

@ -0,0 +1,3 @@
export const error = (message: Error | string, ...args: any[]) => {
console.error(message, ...args);
};