From e0b644b2d5ccf11511f83192bafe2b195f1f9437 Mon Sep 17 00:00:00 2001 From: yahaozhang Date: Mon, 15 Sep 2025 14:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E7=BB=84=E4=BB=B6=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=80=89=E6=8B=A9=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81JSON=E6=A0=BC=E5=BC=8F=E8=BE=93=E5=85=A5?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/settings/components/ConfigGroup.vue | 81 +++++++++++++++---- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/src/views/settings/components/ConfigGroup.vue b/src/views/settings/components/ConfigGroup.vue index 7cc34ae..4c23013 100644 --- a/src/views/settings/components/ConfigGroup.vue +++ b/src/views/settings/components/ConfigGroup.vue @@ -44,22 +44,39 @@
- - + + +
@@ -124,7 +141,8 @@ function getTypeLabel(type) { STRING: '字符串', INTEGER: '整数', BOOLEAN: '布尔值', - JSON: 'JSON' + JSON: 'JSON', + SELECT: '下拉选择' } return typeMap[type] || type } @@ -135,6 +153,8 @@ function getValuePlaceholder(type) { return '请输入整数' case 'BOOLEAN': return '请输入 true 或 false' + case 'SELECT': + return '请选择' case 'STRING': return '请输入字符串值' default: @@ -142,6 +162,33 @@ function getValuePlaceholder(type) { } } +// 返回对应配置项的下拉选项 +function getSelectOptions(config) { + // 特殊处理 user.progress_display_format + if (config.configKey === 'user.progress_display_format') { + return [ + { label: '50/100', value: '1' }, + { label: '差:50', value: '2' } + ] + } + + // 如果后端提供了 options 字段(JSON 字符串或数组),做兼容 + if (config.options) { + try { + const parsed = typeof config.options === 'string' ? JSON.parse(config.options) : config.options + // 期望形如 [{ label, value }] 或 { value: label } + if (Array.isArray(parsed)) return parsed + if (parsed && typeof parsed === 'object') { + return Object.entries(parsed).map(([value, label]) => ({ label, value })) + } + } catch (e) { + // ignore parse error + } + } + + return [] +} + function hasChanged(config) { return localValues[config.configKey] !== originalValues[config.configKey] }