From d35108468869ab551b01dacf9add3f16a6bb8424 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Mon, 8 May 2023 11:13:20 +0800 Subject: [PATCH] fix: openapi key unsave --- src/pages/api/user/update.ts | 3 +-- src/pages/number/index.tsx | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/api/user/update.ts b/src/pages/api/user/update.ts index 4fae96356..34cc1f225 100644 --- a/src/pages/api/user/update.ts +++ b/src/pages/api/user/update.ts @@ -14,7 +14,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< const userId = await authToken(req); await connectToDatabase(); - // 更新对应的记录 await User.updateOne( { @@ -22,7 +21,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< }, { ...(avatar && { avatar }), - ...(openaiKey && { openaiKey }) + ...(openaiKey !== undefined && { openaiKey }) } ); diff --git a/src/pages/number/index.tsx b/src/pages/number/index.tsx index a9ae5f6cb..53fcf655b 100644 --- a/src/pages/number/index.tsx +++ b/src/pages/number/index.tsx @@ -61,6 +61,7 @@ const NumberSetting = () => { maxH: 60 }); onclickSave({ + ...userInfo, avatar: base64 }); } catch (err: any) { @@ -70,7 +71,7 @@ const NumberSetting = () => { }); } }, - [onclickSave, toast] + [onclickSave, toast, userInfo] ); const onclickLogOut = useCallback(() => {