From b033c06d26ffe8944f29a390ab751f655fb631cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Wed, 6 Mar 2024 10:08:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor(CRUD):=E5=A4=9A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=94=AF=E6=8C=81=E5=85=BC=E5=AE=B9=E6=97=A7=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=B6=E9=BB=98=E8=AE=A4=E5=80=BC=E5=B0=86=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/crud/Crud.php | 7 ++----- web/src/views/backend/crud/design.vue | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/admin/controller/crud/Crud.php b/app/admin/controller/crud/Crud.php index bb3574c0..6002ba99 100644 --- a/app/admin/controller/crud/Crud.php +++ b/app/admin/controller/crud/Crud.php @@ -307,12 +307,9 @@ class Crud extends Backend if (!$info) { $this->error(__('Record not found')); } - // 需要兼容旧纪录 - if(!isset($info['table']['databaseConnection'])) { - $info['table']['databaseConnection'] = config('database.default'); - } + // 数据表是否有数据 - $connection = TableManager::getConnection($info['table']['databaseConnection']); + $connection = TableManager::getConnection($info['table']['databaseConnection'] ?? ''); $tableName = TableManager::tableName($info['table']['name'], false, $connection); $adapter = TableManager::phinxAdapter(true, $connection); if ($adapter->hasTable($tableName)) { diff --git a/web/src/views/backend/crud/design.vue b/web/src/views/backend/crud/design.vue index c73554b9..8d801f31 100644 --- a/web/src/views/backend/crud/design.vue +++ b/web/src/views/backend/crud/design.vue @@ -1136,6 +1136,7 @@ const loadData = () => { state.table.rebuild = 'Yes' } state.table.isCommonModel = parseInt(res.data.table.isCommonModel) + state.table.databaseConnection = res.data.table.databaseConnection ? res.data.table.databaseConnection : '' const fields = res.data.fields for (const key in fields) { const field = handleFieldAttr(cloneDeep(fields[key]))