优化CURD可视化操作

This commit is contained in:
wolfcode
2023-12-01 00:03:31 +08:00
parent 83165c403c
commit 959fa6687c
2 changed files with 38 additions and 26 deletions

View File

@@ -11,6 +11,7 @@ use app\Request;
use think\db\exception\PDOException;
use think\exception\FileException;
use think\facade\Db;
use think\helper\Str;
use think\response\Json;
/**
@@ -66,7 +67,14 @@ class CurdGenerate extends AdminController
$fileList = $build->getFileList();
if (empty($fileList)) return $this->error('这里什么都没有');
$result = $build->create();
return $this->success('生成成功', compact('result'));
$_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';
}
return $this->success('生成成功', compact('result', 'link'));
} catch (FileException $exception) {
return json(['code' => -1, 'msg' => $exception->getMessage()]);
}