feat: 发布智能体版

This commit is contained in:
augushong
2026-03-26 20:22:34 +08:00
parent 7ee9e102a5
commit 8cc08bcb8c
138 changed files with 7964 additions and 660 deletions

View File

@@ -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()