koishi-plugin-media-luna 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -247,11 +247,26 @@ const setFieldValue = (key: string, value: any) => {
247
247
  emit('update:modelValue', newValue)
248
248
  }
249
249
 
250
- // 判断字段是否应该显示(基于 showWhen 条件)
251
- const shouldShowField = (field: ConfigField) => {
250
+ // 判断字段是否应该显示(基于 showWhen 条件,递归检查依赖链)
251
+ const shouldShowField = (field: ConfigField, visited = new Set<string>()): boolean => {
252
252
  if (!field.showWhen) return true
253
+
253
254
  const { field: dependField, value } = field.showWhen
254
- return props.modelValue[dependField] === value
255
+
256
+ // 防止循环依赖
257
+ if (visited.has(field.key)) return false
258
+ visited.add(field.key)
259
+
260
+ // 检查当前条件
261
+ if (props.modelValue[dependField] !== value) return false
262
+
263
+ // 递归检查依赖字段的 showWhen 条件
264
+ const dependentField = props.fields.find(f => f.key === dependField)
265
+ if (dependentField) {
266
+ return shouldShowField(dependentField, visited)
267
+ }
268
+
269
+ return true
255
270
  }
256
271
 
257
272
  // ============ Table 类型支持 ============