mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-12 23:48:53 +00:00
🚀 Refactor Blade
- Optimize Blade JavaScript code. - Refactored multiple admin controllers for improved validation, error handling, and query efficiency. - Added ProxyConfig trait to centralize proxy configuration options. - Updated NodeStatusDetection to use model relationships for heartbeat checks. - Improved category, label, and country management logic and error logging. - Added new Blade components for admin UI and updated language files and assets for better localization and frontend support. - Bug fixed & introduced more bug :)
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Node;
|
||||
use App\Models\NodeHeartbeat;
|
||||
use App\Services\ProxyService;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -14,20 +13,22 @@ class NodeController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{ // 节点列表
|
||||
$nodeList = auth()->user()->nodes()->whereIn('is_display', [1, 3])->with(['labels', 'level_table'])->get(); // 获取当前用户可用节点
|
||||
$onlineNode = NodeHeartbeat::recently()->distinct()->pluck('node_id')->toArray();
|
||||
foreach ($nodeList as $node) {
|
||||
$node->offline = ! in_array($node->id, $onlineNode, true); // 节点在线状态
|
||||
}
|
||||
$nodes = auth()->user()->nodes()->whereIn('is_display', [1, 3])->with(['labels', 'level_table:level,name', 'latestHeartbeat'])->orderByDesc('sort')->orderBy('id')->get(); // 获取当前用户可用节点
|
||||
|
||||
return view('user.nodeList', [
|
||||
'nodesGeo' => $nodeList->pluck('name', 'geo')->toArray(),
|
||||
'nodeList' => $nodeList,
|
||||
]);
|
||||
// 直接在节点集合上标记在线状态和标签名称
|
||||
$nodes->each(function ($node) {
|
||||
$node->offline = is_null($node->latestHeartbeat);
|
||||
$node->label_names = $node->labels->sortByDesc('sort')->sortBy('id')->pluck('name');
|
||||
});
|
||||
|
||||
// 提取节点地理位置信息用于地图显示
|
||||
$nodesGeo = $nodes->pluck('name', 'geo');
|
||||
|
||||
return view('user.nodeList', compact('nodesGeo', 'nodes'));
|
||||
}
|
||||
|
||||
public function show(Request $request, Node $node, ProxyService $proxyServer): JsonResponse
|
||||
{ // 节点详细
|
||||
{ // 节点详细信息
|
||||
$server = $proxyServer->getProxyConfig($node);
|
||||
|
||||
return response()->json(['status' => 'success', 'data' => $proxyServer->getUserProxyConfig($server, $request->input('type') !== 'text'), 'title' => $server['type']]);
|
||||
|
||||
Reference in New Issue
Block a user