This commit is contained in:
iqudoo
2026-06-14 03:59:45 +08:00
parent 833eda5621
commit 1e03b7750a
23 changed files with 1499 additions and 153 deletions

View File

@@ -20,37 +20,42 @@ interface VisibilityRuleFormProps {
rule: VisibilityRuleDraft;
onChange: (patch: Partial<VisibilityRule>) => void;
variableOptions: string[];
/** 为 true 时仅支持按变量判断(如批量导出过滤) */
variableOnly?: boolean;
}
export const VisibilityRuleForm: React.FC<VisibilityRuleFormProps> = ({
rule,
onChange,
variableOptions,
variableOnly = false,
}) => {
const target = rule.target ?? 'variable';
const target = variableOnly ? 'variable' : (rule.target ?? 'variable');
return (
<div className="space-y-3">
<div>
<label className="ps-field-label"></label>
<FieldSelect
value={target}
onChange={(e) => {
const nextTarget = e.target.value as VisibilityRuleTarget;
onChange({
target: nextTarget,
variable: nextTarget === 'content' ? '' : rule.variable,
});
}}
className="ps-field text-[11px] w-full mt-0.5"
>
{(Object.keys(VISIBILITY_RULE_TARGET_LABELS) as VisibilityRuleTarget[]).map((t) => (
<option key={t} value={t}>
{VISIBILITY_RULE_TARGET_LABELS[t]}
</option>
))}
</FieldSelect>
</div>
{!variableOnly && (
<div>
<label className="ps-field-label"></label>
<FieldSelect
value={target}
onChange={(e) => {
const nextTarget = e.target.value as VisibilityRuleTarget;
onChange({
target: nextTarget,
variable: nextTarget === 'content' ? '' : rule.variable,
});
}}
className="ps-field text-[11px] w-full mt-0.5"
>
{(Object.keys(VISIBILITY_RULE_TARGET_LABELS) as VisibilityRuleTarget[]).map((t) => (
<option key={t} value={t}>
{VISIBILITY_RULE_TARGET_LABELS[t]}
</option>
))}
</FieldSelect>
</div>
)}
{target === 'variable' ? (
<div>
<label className="ps-field-label"></label>
@@ -68,14 +73,18 @@ export const VisibilityRuleForm: React.FC<VisibilityRuleFormProps> = ({
</FieldSelect>
{variableOptions.length === 0 && (
<p className="text-[9px] text-[#666] mt-1 leading-relaxed">
{variableOnly
? '请先在模板中添加变量后再设置过滤条件'
: '请先在「变量管理」中添加变量,或改用「内容值」作为条件对象'}
</p>
)}
</div>
) : (
!variableOnly && (
<p className="text-[9px] text-[#666] leading-relaxed">
使/
</p>
)
)}
<div>
<label className="ps-field-label"></label>