Files
xk-api-yii/admin/components/UI/Widget/Images.php
2024-09-19 11:32:39 +08:00

64 lines
1.2 KiB
PHP

<?php
namespace admin\components\UI\Widget;
/**
* Class Images
* @package backend\components\UI\Widget
*/
class Images extends Widget
{
private array $list;
private int $size = 60;
/**
* Images constructor.
* @param array $list
* @param callable|null $callback
*/
public function __construct(array $list, callable $callback = NULL)
{
$this->list = $list;
$this->callback = $callback;
}
/**
* 图像大小
* @param int $size
* @return $this
*/
public function size(int $size): self
{
$this->size = $size;
return $this;
}
/**
* @return array
*/
public function render(): array
{
$list = [];
foreach ($this->list as $vo) {
$list[] = [
'nodeName' => 'a-image',
'src' => $vo,
'width' => $this->size,
'height' => $this->size,
];
}
return [
'nodeName' => 'a-image-preview-group',
'infinite' => true,
'child' => [
'nodeName' => 'a-space',
'child' => $list
]
];
}
}