WuYongJie 9595267ee7
Some checks failed
Tests / PHP 8.1 (push) Has been cancelled
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
chore: 导入 Akaunting 初始源码与团队协作规则
2026-07-20 18:20:25 +08:00

86 lines
5.3 KiB
PHP

<x-layouts.admin>
<x-slot name="title">数据库配置管理</x-slot>
<x-slot name="buttons">
<a href="{{ route('system-settings.databases.create') }}" class="inline-flex items-center gap-2 rounded-lg bg-green px-5 py-2 text-sm text-white hover:bg-green-700">
<span class="material-icons-outlined text-lg">add</span>新增配置
</a>
</x-slot>
<x-slot name="content">
<div class="my-6">
@include('system_settings.partials.navigation')
<div class="mb-5 rounded-lg border-l-4 border-purple bg-lilac-100 px-4 py-3 text-sm text-gray-700">
数据库密码加密保存,列表及导出文件均不会显示密码。导入时密码留空可保留已有密码。
</div>
@if ($errors->any())
<div class="mb-4 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700">
@foreach ($errors->all() as $error)<p>{{ $error }}</p>@endforeach
</div>
@endif
<div class="mb-5 flex flex-wrap items-end justify-between gap-4 rounded-xl border border-gray-200 bg-white p-4 shadow-sm">
<form method="POST" action="{{ route('system-settings.databases.import') }}" enctype="multipart/form-data" class="flex flex-wrap items-end gap-3">
@csrf
<label class="block">
<span class="mb-1 block text-xs font-semibold text-gray-600">导入 CSV</span>
<input type="file" name="file" accept=".csv,.txt" required class="block max-w-xs text-sm text-gray-600">
</label>
<button type="submit" class="inline-flex h-10 items-center gap-2 rounded-lg bg-green px-4 text-sm text-white hover:bg-green-700">
<span class="material-icons-outlined text-lg">upload_file</span>导入
</button>
</form>
<a href="{{ route('system-settings.databases.export') }}" class="inline-flex h-10 items-center gap-2 rounded-lg border border-gray-300 px-4 text-sm text-gray-600 hover:bg-gray-50">
<span class="material-icons-outlined text-lg">download</span>导出 / 下载模板
</a>
</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-gray-50 text-left text-gray-500">
<tr>
<th class="px-5 py-3">配置名称</th>
<th class="px-5 py-3">类型</th>
<th class="px-5 py-3">主机 / 端口</th>
<th class="px-5 py-3">数据库</th>
<th class="px-5 py-3">用户名</th>
<th class="px-5 py-3">状态</th>
<th class="px-5 py-3 text-right">操作</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-800">{{ $connection->name }}</td>
<td class="px-5 py-4 uppercase text-gray-600">{{ $connection->driver }}</td>
<td class="px-5 py-4 text-gray-600">{{ $connection->host ?: '-' }}{{ $connection->port ? ':' . $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">{{ $connection->username ?: '-' }}</td>
<td class="px-5 py-4">
<span @class([
'rounded-full px-2.5 py-1 text-xs font-semibold',
'bg-green-100 text-green-700' => $connection->enabled,
'bg-gray-100 text-gray-500' => ! $connection->enabled,
])>{{ $connection->enabled ? '启用' : '停用' }}</span>
</td>
<td class="px-5 py-4 text-right whitespace-nowrap">
<a href="{{ route('system-settings.databases.edit', $connection->id) }}" class="mr-4 text-purple hover:underline">修改</a>
<form method="POST" action="{{ route('system-settings.databases.destroy', $connection->id) }}" class="inline" onsubmit="return confirm('确定删除该数据库配置吗?')">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:underline">删除</button>
</form>
</td>
</tr>
@empty
<tr><td colspan="7" class="px-5 py-12 text-center text-gray-400">暂无数据库配置</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
</x-slot>
</x-layouts.admin>