From be8a0991ed486313f5ea8bad230f7deb049ef58a Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:56:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E4=BB=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=85=8D=E7=BD=AE=E9=A1=B9=E7=9A=84=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=E6=80=A7=E7=AE=A1=E7=90=86=20(#2433)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/shared/AstrBotConfig.vue | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/dashboard/src/components/shared/AstrBotConfig.vue b/dashboard/src/components/shared/AstrBotConfig.vue index e636a61bb..943350ce2 100644 --- a/dashboard/src/components/shared/AstrBotConfig.vue +++ b/dashboard/src/components/shared/AstrBotConfig.vue @@ -48,6 +48,47 @@ function openEditorDialog(key, value, theme, language) { function saveEditedContent() { dialog.value = false } + +function getValueBySelector(obj, selector) { + const keys = selector.split('.') + let current = obj + for (const key of keys) { + if (current && typeof current === 'object' && key in current) { + current = current[key] + } else { + return undefined + } + } + return current +} + +function shouldShowItem(itemMeta, itemKey) { + if (!itemMeta?.condition) { + return true + } + for (const [conditionKey, expectedValue] of Object.entries(itemMeta.condition)) { + const actualValue = getValueBySelector(props.iterable, conditionKey) + if (actualValue !== expectedValue) { + return false + } + } + return true +} + +function hasVisibleItemsAfter(items, currentIndex) { + const itemEntries = Object.entries(items) + + // 检查当前索引之后是否还有可见的配置项 + for (let i = currentIndex + 1; i < itemEntries.length; i++) { + const [itemKey, itemValue] = itemEntries[i] + const itemMeta = props.metadata[props.metadataKey].items[itemKey] + if (!itemMeta?.invisible && shouldShowItem(itemMeta, itemKey)) { + return true + } + } + + return false +}