94 lines
6.0 KiB
PHP
94 lines
6.0 KiB
PHP
<x-layouts.admin>
|
|
<x-slot name="title">数据库管理</x-slot>
|
|
|
|
@if ($editable)
|
|
<x-slot name="buttons">
|
|
<a href="{{ route('system-settings.databases.create') }}" class="inline-flex items-center gap-2 rounded-lg bg-purple-700 px-4 py-2 text-sm font-semibold text-white hover:bg-purple-800">
|
|
<span class="material-icons-outlined text-lg" aria-hidden="true">add</span>添加数据库
|
|
</a>
|
|
</x-slot>
|
|
@endif
|
|
|
|
<x-slot name="content">
|
|
<div class="my-6">
|
|
@include('system_settings.partials.navigation')
|
|
|
|
@if ($errors->any())
|
|
<div class="mb-5 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700" role="alert">
|
|
@foreach ($errors->all() as $error)<p>{{ $error }}</p>@endforeach
|
|
</div>
|
|
@endif
|
|
|
|
<div class="mb-5 rounded-xl bg-purple-100 px-5 py-4 text-sm leading-6 text-gray-700">
|
|
<div class="flex flex-wrap items-start justify-between gap-3">
|
|
<p class="font-semibold text-gray-900">当前系统数据库</p>
|
|
<a href="{{ route('system-settings.databases.system.edit') }}" class="font-semibold text-purple-700 hover:text-purple-800 hover:underline">修改系统数据库</a>
|
|
</div>
|
|
<p class="mt-1">
|
|
{{ strtoupper($systemDatabase['driver']) }} · {{ $systemDatabase['host'] }}{{ $systemDatabase['port'] ? ':' . $systemDatabase['port'] : '' }} · {{ $systemDatabase['database'] ?: $systemDatabase['connection'] }}
|
|
</p>
|
|
<p class="mt-1">用户、侧边栏设置和下方所有云数据库配置都保存在这个数据库中。系统库启动连接与云数据库配置相互独立,密码不会回显。</p>
|
|
<p class="mt-1">传输加密:{{ $systemDatabase['tls_required'] ? 'TLS 已启用' : '未启用' }}</p>
|
|
@if ($editable)
|
|
<p class="mt-1">下方可继续添加多个云数据库;连接测试只执行 <code>SELECT 1</code>。</p>
|
|
@else
|
|
<p class="mt-1">生产环境不允许在网页中修改数据库凭据。</p>
|
|
@endif
|
|
</div>
|
|
|
|
<div class="mb-3 flex items-center justify-between gap-3">
|
|
<div>
|
|
<p class="font-semibold text-gray-900">云数据库</p>
|
|
<p class="text-xs text-gray-500">每条密码均使用系统 APP_KEY 加密后存入上方系统数据库。</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="overflow-x-auto rounded-xl border border-gray-200 bg-white">
|
|
<table class="min-w-full divide-y divide-gray-200 text-sm">
|
|
<thead class="bg-purple-50 text-left text-gray-700">
|
|
<tr>
|
|
<th class="px-5 py-3 font-semibold">名称</th>
|
|
<th class="px-5 py-3 font-semibold">地址</th>
|
|
<th class="px-5 py-3 font-semibold">数据库</th>
|
|
<th class="px-5 py-3 font-semibold">业务绑定</th>
|
|
<th class="px-5 py-3 font-semibold">状态</th>
|
|
<th class="px-5 py-3 text-right font-semibold">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
@forelse ($connections as $connection)
|
|
<tr>
|
|
<td class="px-5 py-4 font-semibold text-gray-900">{{ $connection->name }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $connection->host }}:{{ $connection->port }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $connection->database_name }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $sourceLabels[$connection->source_key] ?? '未绑定' }}</td>
|
|
<td class="px-5 py-4">
|
|
<span @class([
|
|
'inline-flex rounded-full px-2.5 py-1 text-xs font-semibold',
|
|
'bg-green-100 text-green-700' => $connection->enabled,
|
|
'bg-gray-100 text-gray-600' => ! $connection->enabled,
|
|
])>{{ $connection->enabled ? '启用' : '停用' }}</span>
|
|
</td>
|
|
<td class="px-5 py-4 text-right whitespace-nowrap">
|
|
<form method="POST" action="{{ route('system-settings.databases.test', $connection->id) }}" class="inline">
|
|
@csrf
|
|
<button type="submit" class="font-semibold text-gray-600 hover:text-purple-700 hover:underline">测试</button>
|
|
</form>
|
|
<a href="{{ route('system-settings.databases.edit', $connection->id) }}" class="ml-4 font-semibold text-purple-700 hover:text-purple-800 hover:underline">修改</a>
|
|
<form method="POST" action="{{ route('system-settings.databases.destroy', $connection->id) }}" class="ml-4 inline" onsubmit="return confirm('确定删除这个数据库配置吗?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="font-semibold text-red-600 hover:underline">删除</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="6" class="px-5 py-12 text-center text-gray-500">还没有数据库配置,点击“添加数据库”开始。</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</x-slot>
|
|
</x-layouts.admin>
|