feat: 补充注释
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
// server/api/images/history.get.ts - 生图历史列表接口:分页返回当前用户未软删除的记录。
|
||||
import type { IImageHistoryListData } from "#shared/types/openai";
|
||||
import {
|
||||
clearNewApiAuthCookies,
|
||||
createApiLogger,
|
||||
createErrorResponse,
|
||||
createSuccessResponse,
|
||||
createUpstreamErrorResponse,
|
||||
getNewApiUserIdFromCookie,
|
||||
isUnauthorizedError,
|
||||
listImageGenerationHistory,
|
||||
toSafeLogError
|
||||
} from "~~/server/utils";
|
||||
|
||||
const DEFAULT_PAGE = 1;
|
||||
const DEFAULT_PAGE_SIZE = 10;
|
||||
const MAX_PAGE_SIZE = 50;
|
||||
|
||||
/**
|
||||
* GET /api/images/history
|
||||
*
|
||||
* 流程:
|
||||
* 1. 从 httpOnly cookie 读取当前用户 ID。
|
||||
* 2. 读取 page/size 查询参数,并限制最大 pageSize,避免一次查太多。
|
||||
* 3. 只查询当前用户且未软删除的记录,按创建时间倒序返回。
|
||||
* 4. 列表不返回完整上游响应或图床响应,详情接口再返回这些调试数据。
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const logger = createApiLogger("images.history.list");
|
||||
logger.info("开始");
|
||||
@@ -68,6 +67,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
});
|
||||
|
||||
/** 将 query 参数归一化为正整数,非法值回退到默认值 */
|
||||
const normalizePositiveInt = (
|
||||
value: unknown,
|
||||
fallbackValue: number
|
||||
|
||||
Reference in New Issue
Block a user