diff --git a/VERSION b/VERSION index 5bd0c3a6..c3c6aefa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.126 +1.1.127 diff --git a/src/routes/admin.js b/src/routes/admin.js index 33199f4d..1974fe9e 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -890,6 +890,7 @@ router.put('/api-keys/:keyId', authenticateAdmin, async (req, res) => { try { const { keyId } = req.params const { + name, // 添加名称字段 tokenLimit, concurrencyLimit, rateLimitWindow, @@ -916,6 +917,18 @@ router.put('/api-keys/:keyId', authenticateAdmin, async (req, res) => { // 只允许更新指定字段 const updates = {} + // 处理名称字段 + if (name !== undefined && name !== null && name !== '') { + const trimmedName = name.toString().trim() + if (trimmedName.length === 0) { + return res.status(400).json({ error: 'API Key name cannot be empty' }) + } + if (trimmedName.length > 100) { + return res.status(400).json({ error: 'API Key name must be less than 100 characters' }) + } + updates.name = trimmedName + } + if (tokenLimit !== undefined && tokenLimit !== null && tokenLimit !== '') { if (!Number.isInteger(Number(tokenLimit)) || Number(tokenLimit) < 0) { return res.status(400).json({ error: 'Token limit must be a non-negative integer' }) diff --git a/web/admin-spa/src/components/apikeys/EditApiKeyModal.vue b/web/admin-spa/src/components/apikeys/EditApiKeyModal.vue index 1484f41a..c84aeb37 100644 --- a/web/admin-spa/src/components/apikeys/EditApiKeyModal.vue +++ b/web/admin-spa/src/components/apikeys/EditApiKeyModal.vue @@ -33,12 +33,16 @@ >名称 -
名称不可修改
++ 用于识别此 API Key 的用途 +
@@ -798,6 +802,7 @@ const updateApiKey = async () => { try { // 准备提交的数据 const data = { + name: form.name, // 添加名称字段 tokenLimit: 0, // 清除历史token限制 rateLimitWindow: form.rateLimitWindow !== '' && form.rateLimitWindow !== null diff --git a/web/admin-spa/src/views/ApiKeysView.vue b/web/admin-spa/src/views/ApiKeysView.vue index d1c36f59..20e48a7a 100644 --- a/web/admin-spa/src/views/ApiKeysView.vue +++ b/web/admin-spa/src/views/ApiKeysView.vue @@ -105,7 +105,7 @@ @@ -405,7 +405,10 @@ -