diff --git a/frontend/src/pages/Settings/StartupSettingsCard.tsx b/frontend/src/pages/Settings/StartupSettingsCard.tsx index ac5ee24..bd505a0 100644 --- a/frontend/src/pages/Settings/StartupSettingsCard.tsx +++ b/frontend/src/pages/Settings/StartupSettingsCard.tsx @@ -4,11 +4,34 @@ import { useStartupSettings, useSaveStartupSettings } from '@/hooks/useSettings' import type { StartupConfig } from '@/types' import type { SubmitContext } from 'tdesign-react/es/form/type' -const DURATION_PLACEHOLDERS = { - readTimeout: '例如 30s', - writeTimeout: '例如 30s', - connMaxLifetime: '例如 1h', -} +const TIMEOUT_OPTIONS = [ + { label: '5 秒', value: '5s' }, + { label: '10 秒', value: '10s' }, + { label: '15 秒', value: '15s' }, + { label: '30 秒', value: '30s' }, + { label: '1 分钟', value: '60s' }, + { label: '2 分钟', value: '120s' }, + { label: '5 分钟', value: '300s' }, +] + +const CONN_LIFETIME_OPTIONS = [ + { label: '5 分钟', value: '5m' }, + { label: '15 分钟', value: '15m' }, + { label: '30 分钟', value: '30m' }, + { label: '1 小时', value: '1h' }, + { label: '2 小时', value: '2h' }, + { label: '4 小时', value: '4h' }, +] + +const MAX_AGE_OPTIONS = [ + { label: '1 天', value: 1 }, + { label: '3 天', value: 3 }, + { label: '7 天', value: 7 }, + { label: '14 天', value: 14 }, + { label: '30 天', value: 30 }, + { label: '60 天', value: 60 }, + { label: '90 天', value: 90 }, +] function flattenConfig(c: StartupConfig): Record { return { @@ -140,11 +163,11 @@ export function StartupSettingsCard() { - - + + + + + diff --git a/openspec/specs/frontend/spec.md b/openspec/specs/frontend/spec.md index 0bd3453..d8ce9de 100644 --- a/openspec/specs/frontend/spec.md +++ b/openspec/specs/frontend/spec.md @@ -408,6 +408,23 @@ TBD - 提供供应商、模型配置和总览的前端管理界面 - **THEN** 前端 SHALL NOT 展示配置来源标签 - **THEN** 前端 SHALL 直接展示 `database.password` 字段值 +#### Scenario: 超时时间字段使用下拉预设选择 + +- **WHEN** 前端渲染启动参数设置表单 +- **THEN** `server.readTimeout` 字段 SHALL 使用 Select 下拉组件,提供以下预设选项:5 秒、10 秒、15 秒、30 秒、1 分钟、2 分钟、5 分钟 +- **THEN** `server.writeTimeout` 字段 SHALL 使用 Select 下拉组件,提供与 readTimeout 相同的预设选项 +- **THEN** `database.connMaxLifetime` 字段 SHALL 使用 Select 下拉组件,提供以下预设选项:5 分钟、15 分钟、30 分钟、1 小时、2 小时、4 小时 +- **THEN** duration 字段的 Select value SHALL 使用 Go duration 字符串格式(如 `"30s"`、`"1h"`) +- **THEN** duration 字段的 Select label SHALL 使用中文单位显示(如 `"30 秒"`、`"1 小时"`) + +#### Scenario: 日志最大保留天数使用下拉预设选择 + +- **WHEN** 前端渲染启动参数设置表单中的 `log.maxAge` 字段 +- **THEN** `log.maxAge` 字段 SHALL 使用 Select 下拉组件 +- **THEN** Select SHALL 提供以下预设选项:1 天、3 天、7 天、14 天、30 天、60 天、90 天 +- **THEN** Select value SHALL 使用数字类型 +- **THEN** Select label SHALL 使用中文单位显示(如 `"30 天"`) + #### Scenario: 数据库驱动表单切换 - **WHEN** 启动参数设置中的 `database.driver` 为 `sqlite`