mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:15:36 +00:00
chore: optimize error message (#2992)
* Revert "chore: optimize error message (#2985)"
This reverts commit 3802ca38f8
.
* chore: optimize error message
This commit is contained in:
parent
00cabc5e23
commit
76940c5454
@ -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 || {} };
|
||||
|
Loading…
Reference in New Issue
Block a user