修复登录任务页面加载慢的问题

- 后端: list_tasks 用 IN 批量查 Account 替代逐条查询,消除 N+1
- 后端: list_accounts 用 joinedload 预加载 assigned_user,消除懒加载
- 前端: 首次加载 accounts 和 tasks 并行请求

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
yml2213
2026-06-22 19:34:13 +08:00
co-authored by Claude Fable 5
parent a996028f5b
commit accb76b9da
3 changed files with 15 additions and 10 deletions
+2 -1
View File
@@ -11,6 +11,7 @@ from ..schemas import AccountImport, AccountAssign, AccountTag, AccountOut, Batc
from ..deps import get_current_user, require_permission
from ..permissions import has_permission
from sqlalchemy import func
from sqlalchemy.orm import joinedload
router = APIRouter(prefix="/api/accounts", tags=["账号管理"])
@@ -64,7 +65,7 @@ def list_accounts(
if tag:
query = query.filter(Account.tag == tag)
accounts = query.order_by(Account.id).all()
accounts = query.order_by(Account.id).options(joinedload(Account.assigned_user)).all()
result = []
for acc in accounts:
item = AccountOut(