chore: optimize error message (#2992)

* Revert "chore: optimize error message (#2985)"

This reverts commit 3802ca38f8.

* chore: optimize error message
This commit is contained in:
被雨水过滤的空气-Rain 2023-11-08 00:23:53 +08:00 committed by GitHub
parent 00cabc5e23
commit 76940c5454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,8 +16,6 @@ import { transformVariableValue } from '../../../../variables/utils/transformVar
import { isSubMode } from '../../association-field/util';
import { isFromDatabase, useSpecialCase } from './useSpecialCase';
const formilyVariable = ['record'];
/**
* FormItem
*/
@ -49,7 +47,6 @@ const useParseDefaultValue = () => {
useEffect(() => {
if (
(isVariable(fieldSchema.default) && formilyVariable.includes(getVariableName(fieldSchema.default))) ||
fieldSchema.default == null ||
isInSetDefaultValueDialog ||
isInFormDataTemplate ||
@ -73,7 +70,7 @@ const useParseDefaultValue = () => {
if (process.env.NODE_ENV !== 'production') {
if (!collectionField) {
throw new Error(`useParseDefaultValue: can not find field ${fieldSchema.name}`);
console.error(`useParseDefaultValue: can not find field ${fieldSchema.name}`);
}
}
@ -107,17 +104,17 @@ const useParseDefaultValue = () => {
// 使用防抖,提高性能和用户体验
const run = _.debounce(_run, DEBOUNCE_WAIT);
_run();
if (isVariable(fieldSchema.default)) {
const variableName = getVariableName(fieldSchema.default);
const variable = findVariable(variableName);
if (process.env.NODE_ENV !== 'production' && !variable) {
throw new Error(`useParseDefaultValue: can not find variable ${variableName}`);
console.error(`useParseDefaultValue: can not find variable ${variableName}`);
}
if (variable) {
_run();
// 实现联动的效果,当依赖的变量变化时(如 `$nForm` 变量),重新解析默认值
const dispose = reaction(() => {
const obj = { [variableName]: variable?.ctx || {} };