diff --git a/app/admin/controller/Ajax.php b/app/admin/controller/Ajax.php index 45bc6b99..f677eb15 100644 --- a/app/admin/controller/Ajax.php +++ b/app/admin/controller/Ajax.php @@ -62,6 +62,27 @@ class Ajax extends Backend return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/svg+xml'); } + /** + * 获取已脱敏的数据库连接配置列表 + * @throws Throwable + */ + public function getDatabaseConnections(): void + { + $connections = config('database.connections'); + $desensitization = []; + foreach ($connections as $key => $connection) { + $connection = TableManager::getConnectionConfig($key); + $desensitization[] = [ + 'type' => $connection['type'], + 'database' => substr_replace($connection['database'], '****', 1, strlen($connection['database']) > 4 ? 2 : 1), + 'key' => $key, + ]; + } + $this->success('', [ + 'list' => $desensitization, + ]); + } + /** * 获取表主键字段 * @param ?string $table