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

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);
}
}

View File

@@ -85,6 +85,15 @@ class Auth
}
} elseif (in_array($rule, $name)) {
$list[] = $rule;
} else {
// 仅勾选父级菜单(如 auth/admin允许访问子路径auth/admin/index、add 等)
$baseRule = preg_replace('/\?.*$/U', '', $rule);
foreach ((array) $name as $n) {
if ($baseRule !== '' && str_starts_with((string) $n, $baseRule . '/')) {
$list[] = $rule;
break;
}
}
}
}
if ($relation === 'or' && !empty($list)) {

View File

@@ -1,6 +1,5 @@
export default {
'Upload administrator': 'Upload administrator',
'Upload user': 'Upload member',
'Storage mode': 'Storage mode',
'Physical path': 'Physical path',
'image width': 'Picture width',

View File

@@ -1,6 +1,5 @@
export default {
'Upload administrator': '上传管理员',
'Upload user': '上传会员',
'Storage mode': '存储方式',
'Physical path': '物理路径',
'image width': '图片宽度',

View File

@@ -82,13 +82,6 @@ const baTable = new baTableClass(new baTableApi('/admin/routine.Attachment/'), {
operator: 'LIKE',
operatorPlaceholder: t('Fuzzy query'),
},
{
label: t('routine.attachment.Upload user'),
prop: 'user.nickname',
align: 'center',
operator: 'LIKE',
operatorPlaceholder: t('Fuzzy query'),
},
{
label: t('utils.size'),
prop: 'size',