feat: 优化批量余额查询和用户模型权限检查

- 添加批量余额查询并发限制,避免数据库连接池耗尽
- 支持余额加载 pending 状态和前端自动重试机制
- 添加用户可用模型 API,统一使用 AccessRestrictions
- 修复用户表单编辑时数组引用共享导致的数据覆盖问题
- 添加数据库连接池配置说明到 .env.example
This commit is contained in:
fawney19
2026-01-28 01:01:05 +08:00
parent 8e0695e9d9
commit 1e0255d0ed
12 changed files with 411 additions and 64 deletions

View File

@@ -357,10 +357,7 @@ import {
Pagination,
RefreshButton,
} from '@/components/ui'
import {
getPublicGlobalModels,
type PublicGlobalModel,
} from '@/api/public-models'
import { type PublicGlobalModel } from '@/api/public-models'
import { meApi } from '@/api/me'
import {
getUserConfigurableCapabilities,
@@ -515,8 +512,9 @@ watch([searchQuery, capabilityFilters], () => {
async function loadModels() {
loading.value = true
try {
const response = await getPublicGlobalModels({ limit: 1000 })
models.value = response.models || []
// 使用用户认证端点,只获取用户有权限使用的模型
const response = await meApi.getAvailableModels({ limit: 1000 })
models.value = (response.models || []) as PublicGlobalModel[]
} catch (err: any) {
log.error('加载模型失败:', err)
showError(err.response?.data?.detail || err.message, '加载模型失败')