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] }