组件抽象
This commit is contained in:
parent
0d238c29af
commit
b9a46390e0
34
app/View/Components/Append.php
Normal file
34
app/View/Components/Append.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use App\Models\ProgramAppends;
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
|
class Append extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ProgramAppends
|
||||||
|
*/
|
||||||
|
public $append;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new component instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ProgramAppends $append)
|
||||||
|
{
|
||||||
|
$this->append = $append;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represent the component.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View|\Closure|string
|
||||||
|
*/
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('components.append');
|
||||||
|
}
|
||||||
|
}
|
43
app/View/Components/Links/UserLink.php
Normal file
43
app/View/Components/Links/UserLink.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components\Links;
|
||||||
|
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
|
class UserLink extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
public $plt_id;
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
public $mid;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new component instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(string $name, $pltId, $mid)
|
||||||
|
{
|
||||||
|
$this->plt_id = $pltId;
|
||||||
|
$this->mid = $mid;
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represent the component.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View|\Closure|string
|
||||||
|
*/
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('components.links.user_link');
|
||||||
|
}
|
||||||
|
}
|
57
app/View/Components/Links/VideoLink.php
Normal file
57
app/View/Components/Links/VideoLink.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components\Links;
|
||||||
|
|
||||||
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
|
class VideoLink extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $bvid;
|
||||||
|
/**
|
||||||
|
* @var int|string
|
||||||
|
*/
|
||||||
|
public $part;
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
public $time;
|
||||||
|
/**
|
||||||
|
* @var int|string|null
|
||||||
|
*/
|
||||||
|
public $sec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new component instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(string $bvid, $part = 1, $time = null, $sec=null)
|
||||||
|
{
|
||||||
|
$this->bvid = $bvid;
|
||||||
|
$this->part = $part;
|
||||||
|
if ($sec == null) {
|
||||||
|
try {
|
||||||
|
$sec = Carbon::createFromFormat("H:i:s", $time)->secondsSinceMidnight();
|
||||||
|
} catch (InvalidFormatException $ex) {
|
||||||
|
$time = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->time = $time;
|
||||||
|
$this->sec = $sec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represent the component.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View|\Closure|string
|
||||||
|
*/
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('components.links.video_link');
|
||||||
|
}
|
||||||
|
}
|
19
resources/views/components/append.blade.php
Normal file
19
resources/views/components/append.blade.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
@if($append->is_original)
|
||||||
|
<div>
|
||||||
|
<x-links.user_link :name="$append->from" :plt-id="$append->platform_id" :mid="$append->from_mid"></x-links.user_link>
|
||||||
|
老板点播
|
||||||
|
<span title="一分10块">{{$append->price}}分</span>
|
||||||
|
@if($append->append)
|
||||||
|
<span>({{$append->append}})</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="my-2">
|
||||||
|
<x-links.user_link :name="$append->from" :plt-id="$append->platform_id" :mid="$append->from_mid"></x-links.user_link>
|
||||||
|
老板追加@if($append->broadcast!=0)常驻留言@endif:{{$append->name}}
|
||||||
|
<span title="一分10块">{{$append->price}}分</span>
|
||||||
|
@if($append->append)
|
||||||
|
<span>({{$append->append}})</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
27
resources/views/components/links/user_link.blade.php
Normal file
27
resources/views/components/links/user_link.blade.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<span>
|
||||||
|
@switch($plt_id)
|
||||||
|
@case(1)
|
||||||
|
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/bilibili.ico" alt="B站">
|
||||||
|
@isset($mid)
|
||||||
|
<a class="underline" href="https://space.bilibili.com/{{$mid}}" target="_blank">{{$name}}</a>
|
||||||
|
@else
|
||||||
|
{{$name}}
|
||||||
|
@endisset
|
||||||
|
@break
|
||||||
|
@case(2)
|
||||||
|
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/ixigua.ico" alt="西瓜视频">
|
||||||
|
@isset($mid)
|
||||||
|
<a class="underline" href="https://www.ixigua.com/home/{{$mid}}/" target="_blank">{{$name}}</a>
|
||||||
|
@else
|
||||||
|
{{$name}}
|
||||||
|
@endisset
|
||||||
|
@break
|
||||||
|
@case(3)
|
||||||
|
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/douyin.ico" alt="抖音">
|
||||||
|
{{$name}}
|
||||||
|
@break
|
||||||
|
@default
|
||||||
|
{{$name}}
|
||||||
|
@break
|
||||||
|
@endswitch
|
||||||
|
</span>
|
7
resources/views/components/links/video_link.blade.php
Normal file
7
resources/views/components/links/video_link.blade.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<a class="block"
|
||||||
|
target="_blank"
|
||||||
|
href="https://www.bilibili.com/video/{{$bvid}}?p={{$part}}@if($time)&t={{$sec}}@endif"
|
||||||
|
title="P{{$part}}@if($time)#{{$time}}@endif"
|
||||||
|
>
|
||||||
|
{{ $slot }}
|
||||||
|
</a>
|
@ -28,23 +28,7 @@
|
|||||||
@foreach($danmakus as $danmaku)
|
@foreach($danmakus as $danmaku)
|
||||||
<tr>
|
<tr>
|
||||||
<td class="border">
|
<td class="border">
|
||||||
@switch($danmaku->platform_id)
|
<x-links.user_link :name="$danmaku->from" :plt-id="$danmaku->platform_id" :mid="$danmaku->from_mid"></x-links.user_link>
|
||||||
@case(1)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/bilibili.ico" alt="B站">
|
|
||||||
<a class="underline" href="https://space.bilibili.com/{{$danmaku->from_mid}}" target="_blank">{{$danmaku->from}}</a>
|
|
||||||
@break
|
|
||||||
@case(2)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/ixigua.ico" alt="西瓜视频">
|
|
||||||
<a class="underline" href="https://www.ixigua.com/home/{{$danmaku->from_mid}}/" target="_blank">{{$danmaku->from}}</a>
|
|
||||||
@break
|
|
||||||
@case(3)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/douyin.ico" alt="抖音">
|
|
||||||
{{$danmaku->from}}
|
|
||||||
@break
|
|
||||||
@default
|
|
||||||
{{$danmaku->from}}
|
|
||||||
@break
|
|
||||||
@endswitch
|
|
||||||
</td>
|
</td>
|
||||||
<td class="border">{{$danmaku->content}}</td>
|
<td class="border">{{$danmaku->content}}</td>
|
||||||
<td class="border text-sm">{{$danmaku->created_at}}</td>
|
<td class="border text-sm">{{$danmaku->created_at}}</td>
|
||||||
|
@ -22,63 +22,36 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="{{route("program.construct.edit", ["program"=>$program->id])}}">编辑</a>
|
<a href="{{route("program.construct.edit", ["program"=>$program->id])}}">编辑</a>
|
||||||
<span title="节目">{{$program->name}}</span>
|
<span title="节目">{{$program->name}}</span>
|
||||||
|
<span title="难度">{{$program->difficulty}}</span>
|
||||||
<span title="要求">{{$program->desc}}</span>
|
<span title="要求">{{$program->desc}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@foreach($program->appends as $append)
|
@foreach($program->appends as $append)
|
||||||
@if($append->is_original)
|
<x-append :append="$append"></x-append>
|
||||||
<div>
|
|
||||||
@if($append->from_mid)
|
|
||||||
<a target="_blank"
|
|
||||||
href="https://space.bilibili.com/{{$append->from_mid}}">{{$append->from}}</a>
|
|
||||||
@else
|
|
||||||
{{$append->from}}
|
|
||||||
@endif
|
|
||||||
老板点播
|
|
||||||
<span title="一分10块">{{$append->price}}分</span>
|
|
||||||
@if($append->append)
|
|
||||||
<span>({{$append->append}})</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@else
|
|
||||||
<div>
|
|
||||||
@if($append->from_mid)
|
|
||||||
<a target="_blank"
|
|
||||||
href="https://space.bilibili.com/{{$append->from_mid}}">{{$append->from}}</a>
|
|
||||||
@else
|
|
||||||
{{$append->from}}
|
|
||||||
@endif
|
|
||||||
老板追加:{{$append->name}}
|
|
||||||
<span title="一分10块">{{$append->price}}分</span>
|
|
||||||
@if($append->append)
|
|
||||||
<span>({{$append->append}})</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@foreach($program->video_pivots as $video_pivot)
|
@foreach($program->video_pivots as $video_pivot)
|
||||||
<a
|
<x-links.video_link :bvid="$video_pivot->video_bvid" :part="$video_pivot->start_part" :time="$video_pivot->start_time">
|
||||||
target="_blank"
|
<div>{{$video_pivot->created_at}} P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}</div>
|
||||||
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->start_part}}&t={{$video_pivot->start_sec}}"
|
|
||||||
title="P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}"
|
|
||||||
>
|
|
||||||
@if($video_pivot->start_image)
|
@if($video_pivot->start_image)
|
||||||
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
|
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
|
||||||
@else
|
@else
|
||||||
节目开始位置
|
节目开始位置
|
||||||
@endif
|
@endif
|
||||||
</a>
|
</x-links.video_link>
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@foreach($program->video_pivots as $video_pivot)
|
@foreach($program->video_pivots as $video_pivot)
|
||||||
@if($video_pivot->stop_image)
|
<x-links.video_link :bvid="$video_pivot->video_bvid" :part="$video_pivot->stop_part" :time="$video_pivot->stop_time">
|
||||||
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
|
<div>P{{$video_pivot->stop_part}}#{{$video_pivot->stop_time}}</div>
|
||||||
@else
|
@if($video_pivot->start_image)
|
||||||
<div>暂无</div>
|
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
|
||||||
@endif
|
@else
|
||||||
|
节目结束位置
|
||||||
|
@endif
|
||||||
|
</x-links.video_link>
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -34,92 +34,31 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="border align-top">
|
<td class="border align-top">
|
||||||
@foreach($program->appends as $append)
|
@foreach($program->appends as $append)
|
||||||
@if($append->is_original)
|
<x-append :append="$append"></x-append>
|
||||||
<div>
|
|
||||||
@switch($append->platform_id)
|
|
||||||
@case(1)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/bilibili.ico" alt="B站">
|
|
||||||
<a class="underline" href="https://space.bilibili.com/{{$append->from_mid}}" target="_blank">{{$append->from}}</a>
|
|
||||||
@break
|
|
||||||
@case(2)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/ixigua.ico" alt="西瓜视频">
|
|
||||||
<a class="underline" href="https://www.ixigua.com/home/{{$append->from_mid}}/" target="_blank">{{$append->from}}</a>
|
|
||||||
@break
|
|
||||||
@case(3)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/douyin.ico" alt="抖音">
|
|
||||||
{{$append->from}}
|
|
||||||
@break
|
|
||||||
@default
|
|
||||||
{{$append->from}}
|
|
||||||
@break
|
|
||||||
@endswitch
|
|
||||||
老板点播
|
|
||||||
<span title="一分10块">{{$append->price}}分</span>
|
|
||||||
@if($append->append)
|
|
||||||
<span>({{$append->append}})</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@else
|
|
||||||
<div class="my-2">
|
|
||||||
@switch($append->platform_id)
|
|
||||||
@case(1)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/bilibili.ico" alt="B站">
|
|
||||||
<a class="underline" href="https://space.bilibili.com/{{$append->from_mid}}" target="_blank">{{$append->from}}</a>
|
|
||||||
@break
|
|
||||||
@case(2)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/ixigua.ico" alt="西瓜视频">
|
|
||||||
<a class="underline" href="https://www.ixigua.com/home/{{$append->from_mid}}/" target="_blank">{{$append->from}}</a>
|
|
||||||
@break
|
|
||||||
@case(3)
|
|
||||||
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/douyin.ico" alt="抖音">
|
|
||||||
{{$append->from}}
|
|
||||||
@break
|
|
||||||
@default
|
|
||||||
{{$append->from}}
|
|
||||||
@break
|
|
||||||
@endswitch
|
|
||||||
老板追加:{{$append->name}}
|
|
||||||
<span title="一分10块">{{$append->price}}分</span>
|
|
||||||
@if($append->append)
|
|
||||||
<span>({{$append->append}})</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
@endforeach
|
||||||
@if(sizeof($program->appends) === 0)
|
|
||||||
<a href="{{route('program.construct.append.list', ['program'=>$program->id])}}">去建设</a>
|
|
||||||
@endif
|
|
||||||
</td>
|
</td>
|
||||||
<td class="border align-top hidden lg:table-cell">
|
<td class="border align-top hidden lg:table-cell">
|
||||||
@foreach($program->video_pivots as $video_pivot)
|
@foreach($program->video_pivots as $video_pivot)
|
||||||
<a class="block"
|
<x-links.video_link :bvid="$video_pivot->video_bvid" :part="$video_pivot->start_part" :time="$video_pivot->start_time">
|
||||||
target="_blank"
|
|
||||||
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->start_part}}&t={{$video_pivot->start_sec}}"
|
|
||||||
title="P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}"
|
|
||||||
>
|
|
||||||
<div>{{$video_pivot->created_at}} P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}</div>
|
<div>{{$video_pivot->created_at}} P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}</div>
|
||||||
@if($video_pivot->start_image)
|
@if($video_pivot->start_image)
|
||||||
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
|
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
|
||||||
@else
|
@else
|
||||||
节目开始位置
|
节目开始位置
|
||||||
@endif
|
@endif
|
||||||
</a>
|
</x-links.video_link>
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
<td class="border align-top hidden lg:table-cell">
|
<td class="border align-top hidden lg:table-cell">
|
||||||
@foreach($program->video_pivots as $video_pivot)
|
@foreach($program->video_pivots as $video_pivot)
|
||||||
<a class="block"
|
<x-links.video_link :bvid="$video_pivot->video_bvid" :part="$video_pivot->stop_part" :time="$video_pivot->stop_time">
|
||||||
target="_blank"
|
|
||||||
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->stop_part}}&t={{$video_pivot->stop_sec}}"
|
|
||||||
title="P{{$video_pivot->stop_part}}#{{$video_pivot->stop_time}}"
|
|
||||||
>
|
|
||||||
<div>P{{$video_pivot->stop_part}}#{{$video_pivot->stop_time}}</div>
|
<div>P{{$video_pivot->stop_part}}#{{$video_pivot->stop_time}}</div>
|
||||||
@if($video_pivot->start_image)
|
@if($video_pivot->start_image)
|
||||||
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
|
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
|
||||||
@else
|
@else
|
||||||
节目结束位置
|
节目结束位置
|
||||||
@endif
|
@endif
|
||||||
</a>
|
</x-links.video_link>
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user