diff --git a/batch_operation_dist.zip b/batch_operation_dist.zip new file mode 100644 index 000000000..46551204a Binary files /dev/null and b/batch_operation_dist.zip differ diff --git a/dashboard/src/i18n/locales/en-US/features/session-management.json b/dashboard/src/i18n/locales/en-US/features/session-management.json index 0764bbc59..fdd6b4f82 100644 --- a/dashboard/src/i18n/locales/en-US/features/session-management.json +++ b/dashboard/src/i18n/locales/en-US/features/session-management.json @@ -112,6 +112,24 @@ "enabled": "Enabled", "disabled": "Disabled" }, + "batchOperations": { + "title": "Batch Operations", + "hint": "Quick batch modify session settings", + "scope": "Apply to", + "scopeSelected": "Selected sessions", + "scopeAll": "All sessions", + "scopeGroup": "All groups", + "scopePrivate": "All private chats", + "llmStatus": "LLM Status", + "ttsStatus": "TTS Status", + "chatProvider": "Chat Model", + "ttsProvider": "TTS Model", + "apply": "Apply Changes" + }, + "status": { + "enabled": "Enabled", + "disabled": "Disabled" + }, "messages": { "refreshSuccess": "Data refreshed", "loadError": "Failed to load data", diff --git a/dashboard/src/i18n/locales/zh-CN/features/session-management.json b/dashboard/src/i18n/locales/zh-CN/features/session-management.json index 4b9053ebf..33b387cd2 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/session-management.json +++ b/dashboard/src/i18n/locales/zh-CN/features/session-management.json @@ -1,4 +1,4 @@ -{ +{ "title": "自定义规则", "subtitle": "为特定会话设置自定义规则,优先级高于全局配置", "buttons": { @@ -94,6 +94,24 @@ "title": "确认批量删除", "message": "确定要删除选中的 {count} 条规则吗?删除后将恢复使用全局配置。" }, + "batchOperations": { + "title": "批量操作", + "hint": "快速批量修改会话配置", + "scope": "应用范围", + "scopeSelected": "选中的会话", + "scopeAll": "所有会话", + "scopeGroup": "所有群聊", + "scopePrivate": "所有私聊", + "llmStatus": "LLM 状态", + "ttsStatus": "TTS 状态", + "chatProvider": "聊天模型", + "ttsProvider": "TTS 模型", + "apply": "应用更改" + }, + "status": { + "enabled": "启用", + "disabled": "禁用" + }, "messages": { "refreshSuccess": "数据已刷新", "loadError": "加载数据失败", diff --git a/dashboard/src/views/SessionManagementPage.vue b/dashboard/src/views/SessionManagementPage.vue index 8a9be55c2..5cfbf6db3 100644 --- a/dashboard/src/views/SessionManagementPage.vue +++ b/dashboard/src/views/SessionManagementPage.vue @@ -111,6 +111,47 @@ + + + + {{ tm('batchOperations.title') }} + + {{ tm('batchOperations.hint') }} + + + + + + + + + + + + + + + + + + + + + + + + + {{ tm('batchOperations.apply') }} + + + + + @@ -1103,6 +1144,77 @@ export default { } this.saving = false }, + + async applyBatchChanges() { + this.batchUpdating = true + try { + const scope = this.batchScope + let umos = [] + + if (scope === 'selected') { + umos = this.selectedItems.map(item => item.umo) + if (umos.length === 0) { + this.showError('请先选择要操作的会话') + this.batchUpdating = false + return + } + } + + const tasks = [] + + if (this.batchLlmStatus !== null || this.batchTtsStatus !== null) { + const serviceData = { scope, umos } + if (this.batchLlmStatus !== null) { + serviceData.llm_enabled = this.batchLlmStatus + } + if (this.batchTtsStatus !== null) { + serviceData.tts_enabled = this.batchTtsStatus + } + tasks.push(axios.post('/api/session/batch-update-service', serviceData)) + } + + if (this.batchChatProvider !== null) { + tasks.push(axios.post('/api/session/batch-update-provider', { + scope, + umos, + provider_type: 'chat_completion', + provider_id: this.batchChatProvider || null + })) + } + + if (this.batchTtsProvider !== null) { + tasks.push(axios.post('/api/session/batch-update-provider', { + scope, + umos, + provider_type: 'text_to_speech', + provider_id: this.batchTtsProvider || null + })) + } + + if (tasks.length === 0) { + this.showError('请至少选择一项要修改的配置') + this.batchUpdating = false + return + } + + const results = await Promise.all(tasks) + const allOk = results.every(r => r.data.status === 'ok') + + if (allOk) { + this.showSuccess('批量更新成功') + this.batchLlmStatus = null + this.batchTtsStatus = null + this.batchChatProvider = null + this.batchTtsProvider = null + await this.loadData() + } else { + this.showError('部分更新失败') + } + } catch (error) { + this.showError(error.response?.data?.message || '批量更新失败') + } + this.batchUpdating = false + }, }, }