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]))