From 5aef4ed70f6eb5bfc8e3374e502608531b4b6374 Mon Sep 17 00:00:00 2001 From: sijinhui Date: Thu, 22 Feb 2024 13:14:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=8B=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/charts/route.ts | 4 ++-- app/api/common.ts | 2 +- app/api/logs/[...path]/route.ts | 4 ---- lib/auth.ts | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/api/charts/route.ts b/app/api/charts/route.ts index 41d2768a4..3289d679f 100644 --- a/app/api/charts/route.ts +++ b/app/api/charts/route.ts @@ -66,8 +66,8 @@ async function handle(req: NextRequest) { const todayLog = await prisma.logEntry.findMany({ where: { createdAt: { - gte: startOfTheDayInTimeZone, // gte 表示 '大于等于' - lte: endOfTheDayInTimeZone, // lte 表示 '小于等于' + gte: startOfTheDayInTimeZone.toISOString(), // gte 表示 '大于等于' + lte: endOfTheDayInTimeZone.toISOString(), // lte 表示 '小于等于' }, }, include: { diff --git a/app/api/common.ts b/app/api/common.ts index 7b19b9783..5eaa41d92 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -156,7 +156,7 @@ export async function requestLog( const logData = { ip: ip, path: url_path, - // logEntry: JSON.stringify(jsonBody), + logEntry: JSON.stringify(jsonBody), model: url_path.startsWith("mj/") ? "midjourney" : jsonBody?.model, // 后面尝试请求是添加到参数 userName: h_userName, }; diff --git a/app/api/logs/[...path]/route.ts b/app/api/logs/[...path]/route.ts index 44070b1d1..ad6bc33f3 100644 --- a/app/api/logs/[...path]/route.ts +++ b/app/api/logs/[...path]/route.ts @@ -26,8 +26,6 @@ async function handle( // console.log("===========4", request_data); try { if (request_data?.logEntry) { - // const regex = /\[(.*)]/g; - // const matchResponse = request_data.logEntry.match(regex); const regex_message = /(?<="content":")(.*?)(?="}[,\]])/g; const matchAllMessage = request_data.logEntry.match(regex_message); // console.log(matchAllMessage, "====="); @@ -35,8 +33,6 @@ async function handle( request_data.logToken = getTokenLength(matchAllMessage.join(" ")) + matchAllMessage.length * 3; - } else { - request_data.logToken = 0; } delete request_data["logEntry"]; } diff --git a/lib/auth.ts b/lib/auth.ts index 642d0ca08..676631337 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -10,7 +10,7 @@ const SECURE_COOKIES:boolean = !!process.env.SECURE_COOKIES; export const authOptions: NextAuthOptions = { // debug: !VERCEL_DEPLOYMENT, - debug: SECURE_COOKIES, + debug: !SECURE_COOKIES, useSecureCookies: SECURE_COOKIES, secret: process.env.NEXTAUTH_SECRET, providers: [