From 2d561f81b5a0d4be9530956bef6f47382fac9263 Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Mon, 30 Mar 2026 15:17:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B9=E7=9B=AE=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=AE=A1=E7=90=86=E5=91=98=E7=99=BB=E5=BD=95=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=9D=83=E9=99=90=E4=B8=8D=E8=B6=B3=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/routine/Attachment.php | 2 +- app/common/model/Attachment.php | 5 ----- app/functions.php | 17 +++++++++++++++-- extend/ba/Auth.php | 9 +++++++++ web/src/lang/backend/en/routine/attachment.ts | 1 - .../lang/backend/zh-cn/routine/attachment.ts | 1 - .../views/backend/routine/attachment/index.vue | 7 ------- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/admin/controller/routine/Attachment.php b/app/admin/controller/routine/Attachment.php index 91c840e..6a0bfff 100644 --- a/app/admin/controller/routine/Attachment.php +++ b/app/admin/controller/routine/Attachment.php @@ -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 diff --git a/app/common/model/Attachment.php b/app/common/model/Attachment.php index be2786f..0f49c1b 100644 --- a/app/common/model/Attachment.php +++ b/app/common/model/Attachment.php @@ -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'); - } } diff --git a/app/functions.php b/app/functions.php index 2540183..b02fc06 100644 --- a/app/functions.php +++ b/app/functions.php @@ -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); } } diff --git a/extend/ba/Auth.php b/extend/ba/Auth.php index 6fdd077..ba30168 100644 --- a/extend/ba/Auth.php +++ b/extend/ba/Auth.php @@ -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)) { diff --git a/web/src/lang/backend/en/routine/attachment.ts b/web/src/lang/backend/en/routine/attachment.ts index 23606ff..a38b96d 100644 --- a/web/src/lang/backend/en/routine/attachment.ts +++ b/web/src/lang/backend/en/routine/attachment.ts @@ -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', diff --git a/web/src/lang/backend/zh-cn/routine/attachment.ts b/web/src/lang/backend/zh-cn/routine/attachment.ts index a33d93a..11886df 100644 --- a/web/src/lang/backend/zh-cn/routine/attachment.ts +++ b/web/src/lang/backend/zh-cn/routine/attachment.ts @@ -1,6 +1,5 @@ export default { 'Upload administrator': '上传管理员', - 'Upload user': '上传会员', 'Storage mode': '存储方式', 'Physical path': '物理路径', 'image width': '图片宽度', diff --git a/web/src/views/backend/routine/attachment/index.vue b/web/src/views/backend/routine/attachment/index.vue index e279069..47fc897 100644 --- a/web/src/views/backend/routine/attachment/index.vue +++ b/web/src/views/backend/routine/attachment/index.vue @@ -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',