增加 模块状态
This commit is contained in:
parent
baf992ccbc
commit
ea5beffaa2
31
app/View/Components/ModuleStatus.php
Normal file
31
app/View/Components/ModuleStatus.php
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
||||||
|
18
resources/views/components/module-status.blade.php
Normal file
18
resources/views/components/module-status.blade.php
Normal 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>
|
Loading…
Reference in New Issue
Block a user