改登录接口

This commit is contained in:
李志强 2025-12-26 17:21:06 +08:00
parent 3519525af8
commit 99d4fc303a

View File

@ -81,7 +81,18 @@ class UserController extends BaseController
// 记录登录日志
Log::record('用户登录成功:' . $user->account, 'info');
return json(['code' => 0, 'msg' => '登录成功']);
// 返回用户信息给前端缓存
return json([
'code' => 0,
'msg' => '登录成功',
'data' => [
'user_id' => $user->id,
'user_name' => $user->name,
'user_account' => $user->account,
'user_avatar' => $user->avatar ?? '/static/images/avatar.png',
'login_time' => time()
]
]);
} catch (\Exception $e) {
Log::record('登录失败:' . $e->getMessage(), 'error');