mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 18:42:49 +08:00
feat: 发布智能体版
This commit is contained in:
@@ -202,16 +202,27 @@ if (!function_exists('auth')) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_session_admin($key = null)
|
||||
{
|
||||
$token = read_header_token();
|
||||
if (!empty($token)) {
|
||||
$admin = Cache::store('login')->get($token);
|
||||
} else {
|
||||
$admin = session('admin');
|
||||
}
|
||||
if (!function_exists('get_session_admin')) {
|
||||
/**
|
||||
* 获取当前登录管理员信息(全局函数)。
|
||||
*
|
||||
* 该函数用于无控制器上下文的场景(如 Service/Helper/Command 等)获取登录态数据。
|
||||
* 在控制器内建议优先使用 $this->getAdminId() / $this->sessionAdmin 获取已鉴权后的上下文。
|
||||
*
|
||||
* @param string|null $key 取值路径(支持 Arr::get 语法),为空返回整个管理员数据
|
||||
* @return mixed
|
||||
*/
|
||||
function get_session_admin($key = null)
|
||||
{
|
||||
$token = read_header_token();
|
||||
if (!empty($token)) {
|
||||
$admin = Cache::store('login')->get($token);
|
||||
} else {
|
||||
$admin = session('admin');
|
||||
}
|
||||
|
||||
return Arr::get($admin, $key);
|
||||
return Arr::get($admin, $key);
|
||||
}
|
||||
}
|
||||
|
||||
function read_header_token()
|
||||
|
||||
Reference in New Issue
Block a user