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

@@ -127,13 +127,13 @@ export function useSmartPagination<T>(
function requestDetect() {
pendingDetect = true
// 先尝试立即检测
// 先尝试立即检测(快路径),统一走防抖避免与 ResizeObserver 双重触发
nextTick(() => {
const el = listRef.value
if (el && el.scrollHeight > 0) {
// DOM 已就绪,直接检测
// DOM 已就绪,通过防抖检测
pendingDetect = false
detect()
debouncedDetect()
}
// 否则等待 ResizeObserver 回调
})

View File

@@ -235,9 +235,10 @@
<div class="flex flex-col min-w-0">
<div class="flex items-center gap-1.5">
<span
class="text-sm font-medium truncate cursor-pointer hover:text-primary transition-colors"
title="点击复制"
@click.stop="copyToClipboard(key.name || '未命名密钥')"
class="text-sm font-medium truncate"
:class="key.name ? 'cursor-pointer hover:text-primary transition-colors' : ''"
:title="key.name ? '点击复制' : ''"
@click.stop="key.name && copyToClipboard(key.name)"
>{{ key.name || '未命名密钥' }}</span>
<!-- OAuth 订阅类型标签 (Codex) -->
<Badge

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