增加 模块状态

This commit is contained in:
iVampireSP.com 2023-02-11 16:46:57 +08:00
parent baf992ccbc
commit ea5beffaa2
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
3 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace App\View\Components;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class ModuleStatus extends Component
{
public ?string $status = null;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($status)
{
$this->status = $status;
}
/**
* Get the view / contents that represent the component.
*
* @return View
*/
public function render(): View
{
return view('components.module-status', ['status' => $this->status]);
}
}

View File

@ -4,7 +4,7 @@
@section('content') @section('content')
<h3>{{ $module->name }}</h3> <h3>{{ $module->name }}</h3>
<p>状态: {{ $module->status }}, 余额: {{ $module->balance }} 元。</p> <p>状态: <x-module-status :status="$module->status"/>, 余额: {{ $module->balance }} 元。</p>
<div class="mt-3"> <div class="mt-3">
<a href="{{ route('admin.modules.edit', $module) }}">编辑</a> <a href="{{ route('admin.modules.edit', $module) }}">编辑</a>

View File

@ -0,0 +1,18 @@
<span>
@switch($status)
@case('up')
<span class="badge bg-success">正常</span>
@break
@case('maintenance')
<span class="badge bg-warning">维护</span>
@break
@case('down')
<span class="badge bg-danger">异常</span>
@break
@default
<span class="badge bg-secondary">{{ $status }}</span>
@endswitch
</span>