fix(client): prevent empty display text from crashing field rendering (#8950)

This commit is contained in:
PiEgg
2026-03-25 14:52:25 +08:00
committed by GitHub
parent c5e9c0a78a
commit b199e135c4
@@ -12,9 +12,9 @@ import React from 'react';
import { ClickableFieldModel } from './ClickableFieldModel';
export class DisplayTextFieldModel extends ClickableFieldModel {
t(value: string) {
t(value: string | undefined | null) {
// 如果 value 是 {{ 开头 }} 结尾,则认为是 i18n 表达式,需要翻译
if (value.startsWith('{{') && value.endsWith('}}')) {
if (value?.startsWith('{{') && value?.endsWith('}}')) {
return this.translate(value);
}
return value;