From 6939bb18f74371c5b4f119e4c224067f649f42f5 Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Sun, 10 Dec 2023 12:16:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96CURD=E7=94=9F=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=8D=E5=B8=A6=E8=A1=A8=E5=89=8D?= =?UTF-8?q?=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/system/CurdGenerate.php | 10 ++++++---- app/admin/view/system/curd_generate/index.html | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/system/CurdGenerate.php b/app/admin/controller/system/CurdGenerate.php index a2486d2..f10be82 100644 --- a/app/admin/controller/system/CurdGenerate.php +++ b/app/admin/controller/system/CurdGenerate.php @@ -37,7 +37,7 @@ class CurdGenerate extends AdminController if (!$request->isAjax()) return $this->error(); $tb_prefix = $request->param('tb_prefix/s', ''); $tb_name = $request->param('tb_name/s', ''); - if (empty($tb_name) || empty($tb_prefix)) return $this->error('参数错误'); + if (empty($tb_name)) return $this->error('参数错误'); switch ($type) { case "search": try { @@ -70,9 +70,11 @@ class CurdGenerate extends AdminController $_file = $result[0] ?? ''; $link = ''; if (!empty($_file)) { - $_fileExp = explode(DIRECTORY_SEPARATOR, $_file); - $_fileExp_last = array_slice($_fileExp, -2); - $link = '/' . env('EASYADMIN.ADMIN', 'admin') . '/' . $_fileExp_last[0] . '.' . Str::snake(explode('.php', end($_fileExp_last))[0] ?? '') . '/index'; + $_fileExp = explode(DIRECTORY_SEPARATOR, $_file); + $_fileExp_last = array_slice($_fileExp, -2); + $_fileExp_last_0 = $_fileExp_last[0] . '.'; + if ($_fileExp_last[0] == 'controller') $_fileExp_last_0 = ''; + $link = '/' . env('EASYADMIN.ADMIN', 'admin') . '/' . $_fileExp_last_0 . Str::snake(explode('.php', end($_fileExp_last))[0] ?? '') . '/index'; } return $this->success('生成成功', compact('result', 'link')); } catch (FileException $exception) { diff --git a/app/admin/view/system/curd_generate/index.html b/app/admin/view/system/curd_generate/index.html index 88ea1c3..5191f3b 100644 --- a/app/admin/view/system/curd_generate/index.html +++ b/app/admin/view/system/curd_generate/index.html @@ -8,9 +8,9 @@
- + + 可为空,为空则不带前缀
-