优化项目修复管理员登录提示权限不足报错
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/attachment(ThinkPHP 风格 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user