Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-07-07 11:28:44 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1fad2d8761770e35947353a5b456f65eb2bdf4a8
1fad2d87
1 parent
598e34e8
fix(auth): 修复用户登录状态判断逻辑
添加对用户ID的判断条件,确保已登录用户状态正确更新
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
src/contexts/auth.js
src/contexts/auth.js
View file @
1fad2d8
/*
* @Date: 2025-03-20 21:11:31
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
6-15 20:06:25
* @LastEditTime: 2025-0
7-07 11:27:17
* @FilePath: /mlaj/src/contexts/auth.js
* @Description: 认证上下文管理模块,提供用户认证状态管理、登录登出功能
*/
...
...
@@ -71,13 +71,19 @@ export function provideAuth() {
logout
()
}
}
else
{
// 查询用户是否授权, 从服务器获取用户信息并更新本地存储
const
{
code
,
data
}
=
await
getAuthInfoAPI
();
if
(
code
)
{
// 查询用户是否授权, 从服务器获取用户信息并更新本地存储
if
(
data
.
openid_has
)
{
currentUser
.
value
=
{
...
data
.
user
,
...
data
.
checkin
}
localStorage
.
setItem
(
'currentUser'
,
JSON
.
stringify
(
currentUser
.
value
))
}
// 判断用户是否已经登录
if
(
data
?.
user
?.
id
)
{
// 已登录,更新用户状态
currentUser
.
value
=
{
...
data
.
user
,
...
data
.
checkin
}
localStorage
.
setItem
(
'currentUser'
,
JSON
.
stringify
(
currentUser
.
value
))
}
}
}
// 初始化完成,关闭加载状态
...
...
Please
register
or
login
to post a comment