From 2c974c826356dab9f4af1cc922d4a668bc99f9cb Mon Sep 17 00:00:00 2001 From: hashbro Date: Sat, 26 Sep 2026 19:37:55 +0000 Subject: [PATCH] =?UTF-8?q?feat(devices):=20=E8=AE=BE=E5=A4=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=9B=BD=E5=AE=B6=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 与访问记录列表实现保持一致: - DeviceController::index() 向视图传入 countries (CfIpCountry::names()) - filtersFrom() 解析 country 参数 (CfIpCountry::normalize,支持 ISO 代码与中文名) - filteredQuery() 按 devices.country 过滤 - 视图在 iOS 版本与钱包之间新增 lay-search 国家下拉框 - 重置按钮 reload where 增加 country: '' --- app/Http/Controllers/Admin/DeviceController.php | 7 ++++++- resources/views/admin/devices/index.blade.php | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/DeviceController.php b/app/Http/Controllers/Admin/DeviceController.php index a9f2598..5d4aeb4 100644 --- a/app/Http/Controllers/Admin/DeviceController.php +++ b/app/Http/Controllers/Admin/DeviceController.php @@ -45,6 +45,7 @@ class DeviceController extends Controller return view('admin.devices.index', [ 'portal' => $this->portal(), 'agents' => $agents, + 'countries' => CfIpCountry::names(), ]); } @@ -851,6 +852,7 @@ class DeviceController extends Controller 'model' => trim((string) $request->query('model', '')), 'ip' => trim((string) $request->query('ip', '')), 'ios' => trim((string) $request->query('ios', '')), + 'country' => CfIpCountry::normalize((string) $request->query('country', '')), 'installed_from' => trim((string) $request->query('installed_from', '')), 'installed_to' => trim((string) $request->query('installed_to', '')), 'has_wallet' => $hasWalletInt, @@ -860,7 +862,7 @@ class DeviceController extends Controller } /** - * @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters + * @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, country: ?string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters */ private function filteredQuery(array $filters): Builder { @@ -885,6 +887,9 @@ class DeviceController extends Controller if ($filters['ios'] !== '') { $q->where('devices.ios_version', 'like', '%'.$filters['ios'].'%'); } + if ($filters['country'] !== null) { + $q->where('devices.country', $filters['country']); + } if ($filters['installed_from'] !== '' && preg_match('/^\d{4}-\d{2}-\d{2}/', $filters['installed_from'])) { $q->whereDate('devices.created_at', '>=', substr($filters['installed_from'], 0, 10)); } diff --git a/resources/views/admin/devices/index.blade.php b/resources/views/admin/devices/index.blade.php index ac46f07..2cf5ea4 100644 --- a/resources/views/admin/devices/index.blade.php +++ b/resources/views/admin/devices/index.blade.php @@ -43,6 +43,17 @@ +
+ +
+ +
+
@@ -220,6 +231,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () { model: '', ip: '', ios: '', + country: '', has_wallet: '', has_im: '', installed_from: '',