From 4fc697f83f7e8e55cc45c210a5f1651e59cd7434 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 31 Dec 2025 10:06:45 +0800 Subject: [PATCH] perf: Optimize API Key Page --- backend/apps/system/api/apikey.py | 2 +- frontend/src/components/layout/Apikey.vue | 30 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/backend/apps/system/api/apikey.py b/backend/apps/system/api/apikey.py index 051843ef..4887e247 100644 --- a/backend/apps/system/api/apikey.py +++ b/backend/apps/system/api/apikey.py @@ -20,7 +20,7 @@ async def grid(session: SessionDep, current_user: CurrentUser) -> list[ApikeyGri @router.post("") @system_log(LogConfig(operation_type=OperationType.CREATE, module=OperationModules.API_KEY,result_id_expr='result.self')) async def create(session: SessionDep, current_user: CurrentUser): - count = session.exec(select(func.count()).select_from(ApiKeyModel)).one() + count = session.exec(select(func.count()).select_from(ApiKeyModel).where(ApiKeyModel.uid == current_user.id)).one() if count >= 5: raise ValueError("Maximum of 5 API keys allowed") access_key = secrets.token_urlsafe(16) diff --git a/frontend/src/components/layout/Apikey.vue b/frontend/src/components/layout/Apikey.vue index 81501170..99e51761 100644 --- a/frontend/src/components/layout/Apikey.vue +++ b/frontend/src/components/layout/Apikey.vue @@ -1,6 +1,8 @@