修改注释, 添加换行, 删除不必要的代码

This commit is contained in:
CrescentLeaf
2025-12-07 00:07:21 +08:00
parent f584b49cd4
commit 19b8b92f49
3 changed files with 10 additions and 9 deletions

View File

@@ -1,14 +1,16 @@
import data from "./Data.ts"; import data from "./data.ts"
import getClient from "./getClient.ts" import getClient from "./getClient.ts"
/** /**
* 尝试进行验证 * 进行身份验证以接受客户端事件
* *
* 成功后自动保存到本地 * 使用验证方式优先级: 访问 > 刷新 > 账号密码
* *
* 优先级: 账号密码 > 提供刷新令牌 > 储存的刷新令牌 * 若传递了账号密码, 则同时缓存新的访问令牌和刷新令牌
* *
* 不会逐一尝试 * 如只传递两个令牌的其一, 按照优先级并在成功验证后赋值
*
* 多个验证方式不会逐一尝试
*/ */
export default async function performAuth(args: { export default async function performAuth(args: {
refresh_token?: string refresh_token?: string
@@ -21,7 +23,7 @@ export default async function performAuth(args: {
password: args.password, password: args.password,
}) })
else { 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.refresh_token = getClient().getCachedRefreshToken()
data.access_token = getClient().getCachedAccessToken() data.access_token = getClient().getCachedAccessToken()

View File

@@ -29,4 +29,4 @@ export default function AvatarMySelf({
}) })
return <Avatar avatarRef={avatarRef} {...props} {...args}></Avatar> return <Avatar avatarRef={avatarRef} {...props} {...args}></Avatar>
} }

View File

@@ -8,12 +8,11 @@ import MainSharedContext from '../MainSharedContext.ts'
export default function LoginDialog({ ...props }: { open: boolean } & React.HTMLAttributes<Dialog>) { export default function LoginDialog({ ...props }: { open: boolean } & React.HTMLAttributes<Dialog>) {
const shared = React.useContext(MainSharedContext) const shared = React.useContext(MainSharedContext)
const loginDialogRef = React.useRef<Dialog>(null)
const loginInputAccountRef = React.useRef<TextField>(null) const loginInputAccountRef = React.useRef<TextField>(null)
const loginInputPasswordRef = React.useRef<TextField>(null) const loginInputPasswordRef = React.useRef<TextField>(null)
return ( return (
<mdui-dialog {...props} headline="登录" ref={loginDialogRef}> <mdui-dialog {...props} headline="登录">
<mdui-text-field label="用户 ID / 用户名" ref={loginInputAccountRef}></mdui-text-field> <mdui-text-field label="用户 ID / 用户名" ref={loginInputAccountRef}></mdui-text-field>
<div style={{ <div style={{