From 19b8b92f4995b52aac9288fafff4e9b9f5e67835 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sun, 7 Dec 2025 00:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A,=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8D=A2=E8=A1=8C,=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/performAuth.ts | 14 ++++++++------ client/ui/AvatarMySelf.tsx | 2 +- client/ui/main-page/LoginDialog.tsx | 3 +-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client/performAuth.ts b/client/performAuth.ts index 258bbf8..f40307b 100644 --- a/client/performAuth.ts +++ b/client/performAuth.ts @@ -1,14 +1,16 @@ -import data from "./Data.ts"; +import data from "./data.ts" import getClient from "./getClient.ts" /** - * 尝试进行验证 + * 进行身份验证以接受客户端事件 * - * 成功后自动保存到本地 + * 使用验证方式优先级: 访问 > 刷新 > 账号密码 * - * 优先级: 账号密码 > 提供刷新令牌 > 储存的刷新令牌 + * 若传递了账号密码, 则同时缓存新的访问令牌和刷新令牌 * - * 不会逐一尝试 + * 如只传递两个令牌的其一, 按照优先级并在成功验证后赋值 + * + * 多个验证方式不会逐一尝试 */ export default async function performAuth(args: { refresh_token?: string @@ -21,7 +23,7 @@ export default async function performAuth(args: { password: args.password, }) else { - await getClient().authOrThrow({ refresh_token: args.refresh_token ? args.refresh_token : data.refresh_token }) + await getClient().authOrThrow({ refresh_token: args.refresh_token ? args.refresh_token : data.refresh_token, ignore_all_empty: true }) } data.refresh_token = getClient().getCachedRefreshToken() data.access_token = getClient().getCachedAccessToken() diff --git a/client/ui/AvatarMySelf.tsx b/client/ui/AvatarMySelf.tsx index a463fd1..057130d 100644 --- a/client/ui/AvatarMySelf.tsx +++ b/client/ui/AvatarMySelf.tsx @@ -29,4 +29,4 @@ export default function AvatarMySelf({ }) return -} \ No newline at end of file +} diff --git a/client/ui/main-page/LoginDialog.tsx b/client/ui/main-page/LoginDialog.tsx index aff495c..57090c3 100644 --- a/client/ui/main-page/LoginDialog.tsx +++ b/client/ui/main-page/LoginDialog.tsx @@ -8,12 +8,11 @@ import MainSharedContext from '../MainSharedContext.ts' export default function LoginDialog({ ...props }: { open: boolean } & React.HTMLAttributes) { const shared = React.useContext(MainSharedContext) - const loginDialogRef = React.useRef(null) const loginInputAccountRef = React.useRef(null) const loginInputPasswordRef = React.useRef(null) return ( - +