Step 12:后端轻量优化(API 稳定性 & 前端友好)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
|
||||
|
||||
def paginate(items: Iterable[Any], total: int | None = None) -> dict[str, Any]:
|
||||
items_list = list(items)
|
||||
return {"items": items_list, "total": total if total is not None else len(items_list)}
|
||||
Reference in New Issue
Block a user