mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
feat: 完善 API Keys 批量删除功能并修复搜索跨选择问题
## 主要改进 ### 🔧 核心修复 - 修复搜索时勾选状态无法保存的问题 - 优化全选/取消全选逻辑,支持跨搜索结果保持选择状态 - 改进批量删除的用户体验 - 添加 Unicode 字符处理中间件,提升请求体解析稳定性 ### 🎯 具体变更 - **路由修复**: 解决批量删除路由匹配问题,调整路由顺序 - **API客户端**: 修复 DELETE 方法支持请求体数据传输 - **前端逻辑**: 分离筛选和搜索的监听器,搜索时保持已选中状态 - **全选优化**: 取消全选时只移除当前页选中项,保留其他页面选择 - **Unicode处理**: 添加无效 UTF-16 代理对清理和错误处理机制 - **配置管理**: 将 .mcp.json 添加到 .gitignore,避免本地配置被提交 ### 🚀 用户体验提升 - 支持跨搜索结果批量选择和删除 - 批量删除按钮显示选中数量 - 智能的全选状态管理 - 更好的 Unicode 字符处理容错性 ### 🧪 测试验证 - 验证搜索切换时选择状态保持 - 确认批量删除功能正常工作 - 检查 Redis 数据清理完整性 - 测试 Unicode 字符处理稳定性 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,11 +12,52 @@ const sessionHelper = require('../utils/sessionHelper')
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// 🧹 Unicode 字符清理函数
|
||||
function cleanUnicodeString(str) {
|
||||
if (typeof str !== 'string') {
|
||||
return str
|
||||
}
|
||||
|
||||
// 移除无效的 UTF-16 代理对字符
|
||||
// 匹配无效的低代理字符 (0xDC00-0xDFFF) 没有对应的高代理字符
|
||||
// 匹配无效的高代理字符 (0xD800-0xDBFF) 没有对应的低代理字符
|
||||
return str.replace(
|
||||
/[\uDC00-\uDFFF](?![\uD800-\uDBFF])|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g,
|
||||
'\uFFFD'
|
||||
)
|
||||
}
|
||||
|
||||
// 🧹 递归清理对象中的 Unicode 字符
|
||||
function cleanUnicodeInObject(obj) {
|
||||
if (typeof obj === 'string') {
|
||||
return cleanUnicodeString(obj)
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((item) => cleanUnicodeInObject(item))
|
||||
}
|
||||
|
||||
if (obj && typeof obj === 'object') {
|
||||
const cleaned = {}
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
cleaned[cleanUnicodeString(key)] = cleanUnicodeInObject(value)
|
||||
}
|
||||
return cleaned
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
// 🔧 共享的消息处理函数
|
||||
async function handleMessagesRequest(req, res) {
|
||||
try {
|
||||
const startTime = Date.now()
|
||||
|
||||
// Unicode 字符清理 - 在输入验证之前清理请求体
|
||||
if (req.body) {
|
||||
req.body = cleanUnicodeInObject(req.body)
|
||||
}
|
||||
|
||||
// 严格的输入验证
|
||||
if (!req.body || typeof req.body !== 'object') {
|
||||
return res.status(400).json({
|
||||
|
||||
Reference in New Issue
Block a user