diff --git a/api/server.go b/api/server.go index a2ab1250..21893242 100644 --- a/api/server.go +++ b/api/server.go @@ -345,8 +345,8 @@ func (s *Server) handleCreateTrader(c *gin.Context) { // 设置扫描间隔默认值 scanIntervalMinutes := req.ScanIntervalMinutes - if scanIntervalMinutes <= 0 { - scanIntervalMinutes = 3 // 默认3分钟 + if scanIntervalMinutes < 3 { + scanIntervalMinutes = 3 // 默认3分钟,且不允许小于3 } // ✨ 查询交易所实际余额,覆盖用户输入 @@ -527,6 +527,8 @@ func (s *Server) handleUpdateTrader(c *gin.Context) { scanIntervalMinutes := req.ScanIntervalMinutes if scanIntervalMinutes <= 0 { scanIntervalMinutes = existingTrader.ScanIntervalMinutes // 保持原值 + } else if scanIntervalMinutes < 3 { + scanIntervalMinutes = 3 } // 更新交易员配置 diff --git a/web/package-lock.json b/web/package-lock.json index 5e41f91e..a117b2cb 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -7177,7 +7177,6 @@ "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", "dev": true, "license": "ISC", - "peer": true, "bin": { "yaml": "bin.mjs" }, diff --git a/web/src/components/TraderConfigModal.tsx b/web/src/components/TraderConfigModal.tsx index e0c7c0bf..95a49473 100644 --- a/web/src/components/TraderConfigModal.tsx +++ b/web/src/components/TraderConfigModal.tsx @@ -442,14 +442,15 @@ export function TraderConfigModal({ - handleInputChange( - 'scan_interval_minutes', - Number(e.target.value) - ) - } + onChange={(e) => { + const parsedValue = Number(e.target.value) + const safeValue = Number.isFinite(parsedValue) + ? Math.max(3, parsedValue) + : 3 + handleInputChange('scan_interval_minutes', safeValue) + }} className="w-full px-3 py-2 bg-[#0B0E11] border border-[#2B3139] rounded text-[#EAECEF] focus:border-[#F0B90B] focus:outline-none" - min="1" + min="3" max="60" step="1" />