优化项目修复管理员登录提示权限不足报错

This commit is contained in:
2026-03-30 15:17:47 +08:00
parent 7db09b119e
commit 2d561f81b5
7 changed files with 25 additions and 17 deletions

View File

@@ -14,7 +14,7 @@ class Attachment extends Backend
protected ?object $model = null;
protected array|string $quickSearchField = 'name';
protected array $withJoinTable = ['admin', 'user'];
protected array $withJoinTable = ['admin'];
protected array|string $defaultSortField = ['last_upload_time' => 'desc'];
protected function initController(Request $request): ?Response

View File

@@ -37,9 +37,4 @@ class Attachment extends Model
{
return $this->belongsTo(\app\admin\model\Admin::class, 'admin_id');
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
}

View File

@@ -200,7 +200,8 @@ if (!function_exists('get_controller_path')) {
$parts = explode('\\', $relative);
$path = [];
foreach ($parts as $p) {
$path[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $p));
// 与 admin_rule.name / 前端 path 一致:驼峰首字母小写(如 AdminInfo -> adminInfo不用 snake_case
$path[] = lcfirst($p);
}
return implode('/', $path);
}
@@ -216,7 +217,19 @@ if (!function_exists('get_controller_path')) {
if (count($parts) < 2) {
return $parts[0] ?? null;
}
return implode('/', array_slice($parts, 1, -1)) ?: $parts[1];
// admin/routine.Attachment/index -> routine/attachmentThinkPHP 风格 URL 中带点的控制器段)
$middle = array_slice($parts, 1, -1);
$segments = [];
foreach ($middle as $m) {
if (str_contains($m, '.')) {
foreach (explode('.', $m) as $dotPart) {
$segments[] = lcfirst($dotPart);
}
} else {
$segments[] = lcfirst($m);
}
}
return $segments !== [] ? implode('/', $segments) : ($parts[1] ?? null);
}
}