diff --git a/app/api/chat-stream/route.ts b/app/api/chat-stream/route.ts index 060cc1fe3..78f70847e 100644 --- a/app/api/chat-stream/route.ts +++ b/app/api/chat-stream/route.ts @@ -58,11 +58,18 @@ export async function POST(req: NextRequest) { const usersCollection = db.collection("users"); // 查询用户数据 const user = await usersCollection.findOne({ key: accessCode }); + console.log(user, accessCode); const tips = - "您的链接授权已过期,为了避免恶意盗刷,\n 关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ![](/wx.png)"; + "您的链接授权已过期,为了避免恶意盗刷,\n 请关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ![](/wx.png)"; if (!user) { return new Response(tips); } + console.log("compare: "); + console.log( + user["expire"] < new Date().getTime(), + user["expire"], + new Date().getTime(), + ); if (user["expire"] < new Date().getTime()) { // 判断用户是否过期 return new Response(tips); @@ -95,7 +102,7 @@ export async function POST(req: NextRequest) { content: req.body, }; collection.insertOne(chatLog).then(() => { - client.close(); + //client.close(); }); const stream = await createStream(req); diff --git a/app/config/server.ts b/app/config/server.ts index f1b4f07b8..190ee620a 100644 --- a/app/config/server.ts +++ b/app/config/server.ts @@ -35,7 +35,7 @@ export const getServerSideConfig = () => { apiKey: process.env.OPENAI_API_KEY, code: process.env.CODE, codes: ACCESS_CODES, - needCode: true, + needCode: false, proxyUrl: process.env.PROXY_URL, isVercel: !!process.env.VERCEL, }; diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 7e44f84b8..5b64c3c96 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -4,7 +4,7 @@ const cn = { WIP: "该功能仍在开发中……", Error: { Unauthorized: - "现在是未授权状态,为了避免恶意盗刷:,\n 关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ![](/wx.png)", + "现在是未授权状态,为了避免恶意盗刷:\n 请关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ![](/wx.png)", }, ChatItem: { ChatItemCount: (count: number) => `${count} 条对话`, @@ -151,7 +151,7 @@ const cn = { }, Store: { DefaultTopic: "新的聊天", - BotHello: "有什么可以帮你的吗", + BotHello: "有什么可以帮你的吗,我是智商超越人类的 AI大师", Error: "出错了,稍后重试吧", Prompt: { History: (content: string) => diff --git a/app/requests.ts b/app/requests.ts index 97d69d4f0..6d6666058 100644 --- a/app/requests.ts +++ b/app/requests.ts @@ -37,11 +37,9 @@ function getHeaders() { const accessStore = useAccessStore.getState(); let headers: Record = {}; - if (accessStore.enabledAccessControl()) { - const hash = window.location.hash.substr(1); // 获取 hash 值,去掉 # - const params = new URLSearchParams(hash); // 创建 URLSearchParams 对象 - headers["access-code"] = params.get("key") + ""; - } + const hash = window.location.hash.substr(1); // 获取 hash 值,去掉 # + const params = new URLSearchParams(hash); // 创建 URLSearchParams 对象 + headers["access-code"] = params.get("key") + ""; if (accessStore.token && accessStore.token.length > 0) { headers["token"] = accessStore.token; diff --git a/middleware.ts b/middleware.ts index 30e0ba83c..703b42bcd 100644 --- a/middleware.ts +++ b/middleware.ts @@ -9,7 +9,7 @@ export const config = { const serverConfig = getServerSideConfig(); export function middleware(req: NextRequest) { - console.log("req:",req) + //console.log("req:",req) const accessCode = req.headers.get("access-code"); const token = req.headers.get("token"); const hashedCode = md5.hash(accessCode ?? "").trim();