refactor: 优化智能分页检测和密钥复制交互

- 智能分页统一使用防抖检测避免与 ResizeObserver 双重触发
- 密钥名称仅在非空时启用复制功能
- 移除 API Key 不必要的危险字符校验
This commit is contained in:
fawney19
2026-02-09 19:05:29 +08:00
parent c6cd7d5ae6
commit 853c489471
3 changed files with 12 additions and 26 deletions

View File

@@ -438,17 +438,9 @@ class EndpointAPIKeyCreate(BaseModel):
@field_validator("api_key")
@classmethod
def validate_api_key(cls, v: str) -> str:
"""验证 API Key 安全性"""
# 移除首尾空白(长度校验由 Field min_length 处理)
v = v.strip()
# 检查危险字符SQL 注入防护)
dangerous_chars = ["'", '"', ";", "--", "/*", "*/", "<", ">"]
for char in dangerous_chars:
if char in v:
raise ValueError(f"API Key 包含非法字符: {char}")
return v
"""验证 API Key 基本格式"""
# 移除首尾空白(长度校验由 Field max_length 处理)
return v.strip()
@field_validator("name")
@classmethod
@@ -570,18 +562,11 @@ class EndpointAPIKeyUpdate(BaseModel):
@field_validator("api_key")
@classmethod
def validate_api_key(cls, v: str | None) -> str | None:
"""验证 API Key 安全性"""
"""验证 API Key 基本格式"""
if v is None:
return v
v = v.strip()
dangerous_chars = ["'", '"', ";", "--", "/*", "*/", "<", ">"]
for char in dangerous_chars:
if char in v:
raise ValueError(f"API Key 包含非法字符: {char}")
return v
return v.strip()
@field_validator("name")
@classmethod