FastMovieAI AI短剧创作平台 二开基线

- 源码: xhadmincn/FastMovieAI (Apache 2.0)
- 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION
- vendor/示例资源已gitignore
This commit is contained in:
李建琦
2026-08-26 18:37:36 +08:00
commit eae151fd57
888 changed files with 105571 additions and 0 deletions
@@ -0,0 +1,72 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
class ActionBuilder extends DataModel
{
protected $data = [];
public function __construct($label = '', $props = [])
{
$this->data = [
'label' => $label,
'extra' => [
'group' => [],
'props' => $props,
]
];
}
/**
* 向操作按钮中添加字段
*
* @param string $label 操作按钮标题
* @param mixed $extra 额外参数
* @param string $extra.path 路径, 例如: '/app/pluginExample/admin/Form/index'
* @param string $extra.model 操作模式, 详见 \app\expose\enum\Action::class,例如:Action::COMFIRM['value']
* @param mixed $extra.where 显示条件, 例如: [['is_system', '!=', 1]]
* @param mixed $extra.params 额外传参, 例如: [['id' => 1]]
* @param string|array $extra.field 指定提交字段, 例如: *或['id'=>'uid']id:数据集中字段名,uid:提交数据中字段名
* @param mixed $extra.props 操作属性, 例如: ['type' => 'primary', 'title' => '编辑《{nickname}》']
* @param mixed $extra.component 操作展示组件
* @param string $extra.component.name 组件名, 例如: 'button'
* @param mixed $extra.component.props 组件属性, 例如: ['type' => 'primary', 'size' => 'small']
* @return ActionBuilder
*/
public function add(string $label, mixed $extra = [])
{
$this->data['extra']['group'][] = [
'label' => $label,
'extra' => array_merge([
'loading' => false,
], $extra)
];
return $this;
}
/**
* 设置数据
*
* @param array $data 数据
* @return ActionBuilder
*/
public function setData(array $data)
{
$this->data['data'] = $data;
return $this;
}
/**
* 设置数据操作
*
* @param string $action 操作,append:追加合并数据
* @return ActionBuilder
*/
public function setDataAction(string $action)
{
$this->data['callback'] = $action;
return $this;
}
public function builder()
{
return $this->data;
}
}
@@ -0,0 +1,48 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
class AppsBuilder extends DataModel
{
protected $data = [];
public function __construct($props = [])
{
$this->data['props'] = array_merge([], $props);
$this->data['columns'] = [];
}
public function add(string $prop, string $label, mixed $extra = [])
{
$this->data['columns'][] = [
'prop' => $prop,
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addAction(string $label, mixed $extra = [])
{
$this->data['action'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addTabs(string $label, string $name, mixed $extra)
{
$this->data['tabs'][] = [
'label' => $label,
'name' => $name,
'extra' => $extra
];
return $this;
}
public function addScreen()
{
}
public function builder()
{
return $this->data;
}
}
@@ -0,0 +1,25 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
class ComponentBuilder extends DataModel
{
protected $data = [];
public function add(string $component, mixed $children = null, array $props = [])
{
$this->data[] = [
'component' => $component,
'children' => $children,
'props' => $props
];
return $this;
}
public function builder()
{
$result = $this->data;
$this->data = [];
return $result;
}
}
@@ -0,0 +1,27 @@
<?php
namespace app\expose\build\builder;
use app\expose\build\builder\databoardBuilder\Basic;
use app\expose\utils\DataModel;
class DataboardBuilder extends DataModel
{
protected $data = [];
public function __construct($props = [])
{
$this->data['props'] = array_merge([
'gutter' => 0
], $props);
$this->data['rows'] = [];
}
public function add(Basic $component, array $props = [], array $row = [])
{
$this->data['rows'][] = [
'props' => $props,
'row' => $row,
'component' => $component
];
return $this;
}
}
@@ -0,0 +1,117 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
/**
* 审核表单构建器
*
* @package app\expose\build\builder
* @property string $formName 审核表单名
* @property string $formTitle 审核表单标题
* @property array $props Form Attributes
* @method ExamineBuilder add(string $field, string $title, string $component, string $value = null, mixed $extra = []) 向审核表单中添加字段
* @method ExamineBuilder remove(string $field) 从审核表单中移除字段
* @method ExamineBuilder setOldData(array $data) 设置审核原始对比数据
* @method ExamineBuilder setNewData(array $data) 设置审核最新对比数据
* @method FormBuilder addForm(FormBuilder $builder) 添加表单
*/
class ExamineBuilder extends DataModel
{
protected $data = [];
protected $translations=false;
public function __construct( $props = [])
{
if(isset($props['translations'])){
$this->translations=$props['translations'];
unset($props['translations']);
}
$this->data['props'] = $props;
$this->data['rule'] = [];
$this->data['form'] = [];
}
public function setTranslations(bool $state=true){
$this->translations=$state;
return $this;
}
/**
* 向审核表单中添加字段
*
* @param string $field 字段名
* @param string $title 字段标题
* @param string $component 组件名,ElementUI不含"el-"前缀组件名,例如: input,自定义组件:bundle:附件库
* @param mixed $extra 额外参数
* @param mixed $extra.options 子选项数据, 例如: [['label' => '选项1', 'value' => 1], ['label' => '选项2', 'value' => 2]]
* @param mixed $extra.props 组件属性, 例如: ['placeholder' => '请输入内容']
* @param mixed $extra.subProps 子组件选项属性,和$extra.props类似
* @param mixed $extra.children 插槽内容,['default' => '内容']或['default' => ComponentBuilder ]
* @param mixed $extra.prompt 提示信息, 详见 \app\expose\build\builder\ComponentBuilder
* @return ExamineBuilder
*/
public function add(string $field, string $title, string $component, mixed $extra = []): ExamineBuilder
{
$title = $this->trans($title);
$this->data['rule'][] = [
'field' => $field,
'title' => $title,
'component' => $component,
'extra' => $extra
];
return $this;
}
/**
* 从审核表单中移除字段
*
* @param string $field 字段名
* @return ExamineBuilder
*/
public function remove(string $field): ExamineBuilder
{
$rule = array_filter($this->data['rule'], function ($item) use ($field) {
return $item['field'] != $field;
});
$this->data['rule'] = array_values($rule);
return $this;
}
/**
* 设置审核原始对比数据
*
* @param array $data 数据
* @return ExamineBuilder
*/
public function setOldData(array $data): ExamineBuilder
{
$this->data['old']=$data;
return $this;
}
/**
* 设置审核最新对比数据
*
* @param array $data 数据
* @return ExamineBuilder
*/
public function setNewData(array $data): ExamineBuilder
{
$this->data['new']=$data;
return $this;
}
public function addForm(FormBuilder $builder)
{
$this->data['form']=$builder;
}
public function trans(string|null $val,array $parameters =[])
{
if(!$val||!$this->translations){
return $val;
}
$request=request();
$lang = '';
$domain=null;
if ($request && $request->lang) {
$lang = $request->lang;
$domain=$request->app;
}
return trans($val,$parameters,$domain,$lang);
}
}
@@ -0,0 +1,172 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
/**
* 表单构建器
*
* @package app\expose\build\builder
* @property string $formName 表单名
* @property string $formTitle 表单标题
* @property array $props Form Attributes
* @method FormBuilder add(string $field, string $title, string $component, string $value = null, mixed $extra = [],?ActionBuilder $action = null) 向表单中添加字段
* @method FormBuilder remove(string $field) 从表单中移除字段
* @method FormBuilder addValue(string $field, mixed $value) 向表单中添加数据
* @method FormBuilder setData(array $data) 设置表单数据
* @method string getFormName() 获取表单名
* @method string getFormTitle() 获取表单标题
* @method FormBuilder addGroupForm(FormBuilder $builder) 向表单中添加分组
* @method FormBuilder setUrl(string $url) 设置表单提交地址
*/
class FormBuilder extends DataModel
{
protected $data = [];
protected $url = '';
protected $translations=false;
public function __construct($formName = null, $formTitle = null, $props = [])
{
if(isset($props['translations'])){
$this->translations=$props['translations'];
unset($props['translations']);
}
$this->data['props'] = $props;
$this->data['name'] = $formName ?? 'basic';
$this->data['title'] = $this->trans($formTitle) ?? $this->trans('form_basic_title');
$this->data['rule'] = [];
$this->data['form'] = [];
$this->data['group'] = [];
$this->data['url'] = $this->url;
}
public function setTranslations(bool $state=true){
$this->translations=$state;
return $this;
}
/**
* 向表单中添加字段
*
* @param string $field 字段名
* @param string $title 字段标题
* @param string $component 组件名,ElementUI不含"el-"前缀组件名,例如: input,自定义组件:bundle:附件库
* @param mixed|null $value 默认值
* @param mixed $extra 额外参数
* @param mixed $extra.options 子选项数据, 例如: [['label' => '选项1', 'value' => 1], ['label' => '选项2', 'value' => 2]]
* @param mixed $extra.props 组件属性, 例如: ['placeholder' => '请输入内容']
* @param mixed $extra.subProps 子组件选项属性,和$extra.props类似
* @param mixed $extra.children 插槽内容,['default' => '内容']或['default' => ComponentBuilder ]
* @param mixed $extra.prompt 提示信息, 详见 \app\expose\build\builder\ComponentBuilder
* @param ActionBuilder|null $action 操作按钮, 详见 \app\expose\build\builder\ActionBuilder
* @return FormBuilder
*/
public function add(string $field, string $title, string $component, mixed $value = null, mixed $extra = [],?ActionBuilder $action = null): FormBuilder
{
$title = $this->trans($title);
$this->data['rule'][] = [
'field' => $field,
'title' => $title,
'component' => $component,
'extra' => $extra,
'action' => $action ? $action->builder() : null
];
$this->addValue($field, $value);
return $this;
}
/**
* 从表单中移除字段
*
* @param string $field 字段名
* @return FormBuilder
*/
public function remove(string $field): FormBuilder
{
$rule = array_filter($this->data['rule'], function ($item) use ($field) {
return $item['field'] != $field;
});
$this->data['rule'] = array_values($rule);
return $this;
}
/**
* 向表单中添加数据
*
* @param string $field 字段名
* @param mixed $value 默认值
* @return FormBuilder
*/
public function addValue(string $field, mixed $value): FormBuilder
{
$this->data['form'][$field] = $value;
return $this;
}
/**
* 设置表单数据
*
* @param array $data 数据
* @return FormBuilder
*/
public function setData(array $data): FormBuilder
{
foreach ($data as $key => $value) {
$this->addValue($key, $value);
}
return $this;
}
/**
* 获取表单名
*
* @return string
*/
public function getFormName(): string
{
return $this->data['name'];
}
/**
* 获取表单标题
*
* @return string
*/
public function getFormTitle(): string
{
return $this->data['title'];
}
/**
* 向表单中添加分组
*
* @param FormBuilder $builder 分组表单
* @return FormBuilder
*/
public function addGroupForm(FormBuilder $builder): FormBuilder
{
$formName = $builder->getFormName();
$temp = $builder->toArray();
$this->data['group'][] = $temp;
$this->addValue($formName, $temp['form']);
return $this;
}
/**
* 设置表单提交地址
*
* @param string $url 地址
* @return FormBuilder
*/
public function setUrl(string $url): FormBuilder
{
$this->url = $url;
$this->data['url'] = $url;
return $this;
}
public function trans(string|null $val,array $parameters =[])
{
if(!$val||!$this->translations){
return $val;
}
$request=request();
$lang = '';
$domain=null;
if ($request && $request->lang) {
$lang = $request->lang;
$domain=$request->app;
}
return trans($val,$parameters,$domain,$lang);
}
}
@@ -0,0 +1,96 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
class ImagesBuilder extends DataModel
{
protected $data = [];
public function __construct($props = [])
{
$this->data['props'] = array_merge([
'image'=>'url',
'title'=>'title',
'info'=>'info'
], $props);
}
public function addSelection(string $prop = '', string $label = '', mixed $extra = [])
{
if (!isset($extra['props'])) {
$extra['props'] = [
'width' => '50px',
'type' => 'selection'
];
}
$extra['props']['type'] = 'selection';
$this->data['selection'] = true;
return $this;
}
public function addAction(string|ActionBuilder $label, mixed $extra = [])
{
if ($label instanceof ActionBuilder) {
$this->data['action'] = $label->builder();
return $this;
}
if (!isset($this->data['action'])) {
$this->data['action'] = [];
}
$this->data['action'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addFooter(mixed $props = [])
{
if (!isset($this->data['selection'])) {
$this->addSelection();
}
$this->data['footer'] = [
'extra' => [
'group' => [],
'props' => $props,
]
];
return $this;
}
public function addFooterAction(string $label, mixed $extra = [])
{
$this->data['footer']['extra']['group'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addHeader(array|ActionBuilder $props = [])
{
if ($props instanceof ActionBuilder) {
$this->data['header'] = $props->builder();
return $this;
}
$this->data['header'] = [
'extra' => [
'group' => [],
'props' => $props,
]
];
return $this;
}
public function addHeaderAction(string $label, mixed $extra = [])
{
$this->data['header']['extra']['group'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addScreen(FormBuilder $builder)
{
$this->data['screen'] = $builder;
}
public function builder()
{
return $this->data;
}
}
@@ -0,0 +1,154 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
/**
* 信息展示构建器
*
* @package app\expose\build\builder
* @property string $formName 信息展示名
* @property string $formTitle 信息展示标题
* @property array $props Form Attributes
* @method InfoBuilder add(string $field, string $title, string $component, mixed $extra = [],?ActionBuilder $action = null) 向信息展示中添加字段
* @method InfoBuilder remove(string $field) 从信息展示中移除字段
* @method InfoBuilder addValue(string $field, mixed $value) 向信息展示中添加数据
* @method InfoBuilder setData(array $data) 设置信息展示数据
* @method InfoBuilder addGroupInfo(InfoBuilder $builder) 向信息展示中添加分组
*/
class InfoBuilder extends DataModel
{
protected $data = [];
protected $translations = false;
public function __construct($formName = null, $formTitle = null, $props = [])
{
if (isset($props['translations'])) {
$this->translations = $props['translations'];
unset($props['translations']);
}
$this->data['props'] = $props;
$this->data['name'] = $formName ?? 'basic';
$this->data['title'] = $this->trans($formTitle) ?? $this->trans('form_basic_title');
$this->data['rule'] = [];
$this->data['group'] = [];
$this->data['data'] = [];
}
public function setTranslations(bool $state = true)
{
$this->translations = $state;
return $this;
}
/**
* 向信息展示中添加字段
*
* @param string $field 字段名
* @param string $title 字段标题
* @param string $component 组件名,ElementUI不含"el-"前缀组件名,例如: input,自定义组件:bundle:附件库
* @param mixed $extra 额外参数
* @param mixed $extra.options 子选项数据, 例如: [['label' => '选项1', 'value' => 1], ['label' => '选项2', 'value' => 2]]
* @param mixed $extra.props 组件属性, 例如: ['placeholder' => '请输入内容']
* @param mixed $extra.subProps 子组件选项属性,和$extra.props类似
* @param mixed $extra.children 插槽内容,['default' => '内容']或['default' => ComponentBuilder ]
* @param mixed $extra.prompt 提示信息, 详见 \app\expose\build\builder\ComponentBuilder
* @param ActionBuilder|null $action 操作按钮, 详见 \app\expose\build\builder\ActionBuilder
* @return InfoBuilder
*/
public function add(string $field, string $title, string $component, mixed $extra = [], ?ActionBuilder $action = null): InfoBuilder
{
$title = $this->trans($title);
$this->data['rule'][] = [
'field' => $field,
'title' => $title,
'component' => $component,
'extra' => $extra,
'action' => $action ? $action->builder() : null
];
return $this;
}
/**
* 从信息展示中移除字段
*
* @param string $field 字段名
* @return InfoBuilder
*/
public function remove(string $field): InfoBuilder
{
$rule = array_filter($this->data['rule'], function ($item) use ($field) {
return $item['field'] != $field;
});
$this->data['rule'] = array_values($rule);
return $this;
}
/**
* 向表单中添加数据
*
* @param string $field 字段名
* @param mixed $value 默认值
* @return InfoBuilder
*/
public function addValue(string $field, mixed $value): InfoBuilder
{
$this->data['data'][$field] = $value;
return $this;
}
/**
* 设置表单数据
*
* @param array $data 数据
* @return InfoBuilder
*/
public function setData(array $data): InfoBuilder
{
foreach ($data as $key => $value) {
$this->addValue($key, $value);
}
return $this;
}
/**
* 获取表单名
*
* @return string
*/
public function getInfoName(): string
{
return $this->data['name'];
}
/**
* 获取表单标题
*
* @return string
*/
public function getInfoTitle(): string
{
return $this->data['title'];
}
/**
* 向表单中添加分组
*
* @param InfoBuilder $builder 分组表单
* @return InfoBuilder
*/
public function addGroupInfo(InfoBuilder $builder): InfoBuilder
{
$infoName = $builder->getInfoName();
$temp = $builder->toArray();
$this->data['group'][] = $temp;
$this->addValue($infoName, $temp['data']);
return $this;
}
public function trans(string|null $val, array $parameters = [])
{
if (!$val || !$this->translations) {
return $val;
}
$request = request();
$lang = '';
$domain = null;
if ($request && $request->lang) {
$lang = $request->lang;
$domain = $request->app;
}
return trans($val, $parameters, $domain, $lang);
}
}
@@ -0,0 +1,60 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
class RechargeBuilder extends DataModel
{
protected $data = [];
public function __construct($props = [])
{
$this->data['props'] = array_merge([], $props);
$this->data['list'] = [];
$this->data['prompt']=[];
}
public function addPayment(mixed $data)
{
$this->data['payment']=$data;
return $this;
}
public function addList(mixed $data)
{
$this->data['list']=$data;
return $this;
}
public function addQrcodePrompt(ComponentBuilder $builder)
{
$this->data['prompt']['qrcode'][] = $builder->builder();
return $this;
}
public function addAgreementPrompt(ComponentBuilder $builder)
{
$this->data['prompt']['agreement'][] = $builder->builder();
return $this;
}
public function addFooterPrompt(ComponentBuilder $builder)
{
$this->data['prompt']['footer'][] = $builder->builder();
return $this;
}
public function addSwiperPrompt(ComponentBuilder $builder)
{
$this->data['prompt']['swiper'][] = $builder->builder();
return $this;
}
public function setCreateOrdersApi(string $api)
{
$this->data['create_orders']=$api;
return $this;
}
public function setGetOrdersStateApi(string $api)
{
$this->data['get_orders_state']=$api;
return $this;
}
public function builder()
{
return $this->data;
}
}
@@ -0,0 +1,31 @@
<?php
namespace app\expose\build\builder;
class SoltBuilder
{
public $name = 'default';
public function __construct($name = 'default')
{
$this->name = $name;
}
public static function solt(string $solt = 'default')
{
$self = new self($solt);
return $self;
}
public function text(string $text)
{
return [$this->name => $text];
}
public function add(mixed $component, mixed $props = [], mixed $children = null)
{
return [
$this->name => [
'component' => $component,
'props' => $props,
'children' => $children
]
];
}
}
@@ -0,0 +1,118 @@
<?php
namespace app\expose\build\builder;
use app\expose\utils\DataModel;
class TableBuilder extends DataModel
{
protected $data = [];
public function __construct($props = [])
{
$this->data['props'] = array_merge([
'border' => true,
'stripe' => true,
'size' => 'large',
'header-row-style' => [
'--el-table-header-bg-color' => 'var(--el-bg-color-page)'
]
], $props);
$this->data['columns'] = [];
}
public function add(string $prop, string $label, mixed $extra = [])
{
$this->data['columns'][] = [
'prop' => $prop,
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addSelection(string $prop = '', string $label = '', mixed $extra = [])
{
if (!isset($extra['props'])) {
$extra['props'] = [
'width' => '50px',
'type' => 'selection'
];
}
$extra['props']['type'] = 'selection';
$this->add($prop, $label, $extra);
$this->data['selection'] = true;
return $this;
}
public function addAction(string|ActionBuilder $label, mixed $props = [])
{
if ($label instanceof ActionBuilder) {
$this->data['action'] = $label->builder();
return $this;
}
$this->data['action'] = [
'label' => $label,
'extra' => [
'group' => [],
'props' => $props,
]
];
return $this;
}
public function addTableAction(string $label, mixed $extra = [])
{
$this->data['action']['extra']['group'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addFooter(mixed $props = [])
{
if (!isset($this->data['selection'])) {
$this->addSelection();
}
$this->data['footer'] = [
'extra' => [
'group' => [],
'props' => $props,
]
];
return $this;
}
public function addFooterAction(string $label, mixed $extra = [])
{
$this->data['footer']['extra']['group'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addHeader(array|ActionBuilder $props = [])
{
if ($props instanceof ActionBuilder) {
$this->data['header'] = $props->builder();
return $this;
}
$this->data['header'] = [
'extra' => [
'group' => [],
'props' => $props,
]
];
return $this;
}
public function addHeaderAction(string $label, mixed $extra = [])
{
$this->data['header']['extra']['group'][] = [
'label' => $label,
'extra' => $extra
];
return $this;
}
public function addScreen(FormBuilder $builder)
{
$this->data['screen'] = $builder;
}
public function builder()
{
return $this->data;
}
}
@@ -0,0 +1,9 @@
<?php
namespace app\expose\build\builder\databoardBuilder;
use app\expose\utils\DataModel;
class Basic extends DataModel
{
}
@@ -0,0 +1,53 @@
<?php
namespace app\expose\build\builder\databoardBuilder\component;
use app\expose\build\builder\databoardBuilder\interface\DataboardBuilderInterface;
use app\expose\build\builder\databoardBuilder\Basic;
use app\expose\utils\Str;
/**
* 申请组件
*
* 使用set+属性名的方式设置属性,如setLabel、setTips、setUnit等
*
* @method Apply setLabel(string $label) 设置标签
* @method Apply setTips(string $tips) 设置提示
* @method Apply setApply(bool $apply) 设置是否可以申请
* @method Apply setPrice(int $price) 设置价格
* @method Apply setAgreement(array $agreement) 设置协议
* @method Apply setClass(string $class) 设置class属性
* @method Apply setInterval(int $interval) 自动更新数据的时间间隔
*/
class Apply extends Basic implements DataboardBuilderInterface
{
protected $data = [];
public function __construct()
{
$this->data['name'] = 'apply';
$this->data['props'] = [];
}
public function __call($name, $arguments)
{
$name = lcfirst(str_replace('set', '', $name));
$name = Str::snake($name, '_');
$this->data['props'][$name] = $arguments[0];
return $this;
}
/**
* 设置数据
*
* @param mixed $data
* @return Apply
*/
public function setData(mixed $data): Apply
{
$this->data['props']['data'] = $data;
return $this;
}
public function setApi(string $api): Apply
{
$this->data['props']['api'] = $api;
return $this;
}
}
@@ -0,0 +1,50 @@
<?php
namespace app\expose\build\builder\databoardBuilder\component;
use app\expose\build\builder\databoardBuilder\interface\DataboardBuilderInterface;
use app\expose\build\builder\databoardBuilder\Basic;
use app\expose\utils\Str;
/**
* 申请组件
*
* 使用set+属性名的方式设置属性,如setLabel、setTips、setUnit等
*
* @method Domain setLabel(string $label) 设置标签
* @method Domain setTips(string $tips) 设置提示
* @method Domain setClass(string $class) 设置class属性
* @method Domain setInterval(int $interval) 自动更新数据的时间间隔
*/
class Domain extends Basic implements DataboardBuilderInterface
{
protected $data = [];
public function __construct()
{
$this->data['name'] = 'domain';
$this->data['props'] = [];
}
public function __call($name, $arguments)
{
$name = lcfirst(str_replace('set', '', $name));
$name = Str::snake($name, '_');
$this->data['props'][$name] = $arguments[0];
return $this;
}
/**
* 设置数据
*
* @param mixed $data
* @return Domain
*/
public function setData(mixed $data): Domain
{
$this->data['props']['data'] = $data;
return $this;
}
public function setApi(string $api): Domain
{
$this->data['props']['api'] = $api;
return $this;
}
}
@@ -0,0 +1,40 @@
<?php
namespace app\expose\build\builder\databoardBuilder\component;
use app\expose\build\builder\databoardBuilder\interface\DataboardBuilderInterface;
use app\expose\build\builder\databoardBuilder\Basic;
use app\expose\utils\Str;
class Echarts extends Basic implements DataboardBuilderInterface
{
protected $data = [];
public function __construct()
{
$this->data['name'] = 'echarts';
$this->data['props'] = [];
}
public function __call($name, $arguments)
{
$name = lcfirst(str_replace('set', '', $name));
$name = Str::snake($name, '_');
$this->data['props'][$name] = $arguments[0];
return $this;
}
/**
* 设置数据
*
* @param mixed $data
* @return echarts
*/
public function setData(mixed $data): echarts
{
$this->data['props']['data'] = $data;
return $this;
}
public function setApi(string $api): echarts
{
$this->data['props']['api'] = $api;
return $this;
}
}
@@ -0,0 +1,33 @@
<?php
namespace app\expose\build\builder\databoardBuilder\component;
use app\expose\build\builder\databoardBuilder\interface\DataboardBuilderInterface;
use app\expose\build\builder\databoardBuilder\Basic;
use app\expose\utils\Str;
class Placeholder extends Basic implements DataboardBuilderInterface
{
protected $data = [];
public function __construct()
{
$this->data['name'] = 'div';
$this->data['props'] = [];
}
public function __call($name, $arguments)
{
$name = lcfirst(str_replace('set', '', $name));
$name = Str::snake($name, '_');
$this->data['props'][$name] = $arguments[0];
return $this;
}
public function setData(mixed $data): Placeholder
{
$this->data['props']['data'] = $data;
return $this;
}
public function setApi(string $api): Placeholder
{
$this->data['props']['api'] = $api;
return $this;
}
}
@@ -0,0 +1,56 @@
<?php
namespace app\expose\build\builder\databoardBuilder\component;
use app\expose\build\builder\databoardBuilder\interface\DataboardBuilderInterface;
use app\expose\build\builder\databoardBuilder\Basic;
use app\expose\utils\Str;
/**
* 统计组件
*
* 使用set+属性名的方式设置属性,如setLabel、setTips、setUnit等
*
* @method statistic setLabel(string $label) 设置标签
* @method statistic setTips(string $tips) 设置提示
* @method statistic setUnit(string $unit) 设置单位
* @method statistic setClass(string $class) 设置class属性
* @method statistic setInterval(int $interval) 自动更新数据的时间间隔
*/
class Statistic extends Basic implements DataboardBuilderInterface
{
protected $data = [];
public function __construct()
{
$this->data['name'] = 'statistic';
$this->data['props'] = [
'yesterday_label'=>'昨日',
];
}
public function __call($name, $arguments)
{
$name = lcfirst(str_replace('set', '', $name));
$name = Str::snake($name, '_');
$this->data['props'][$name] = $arguments[0];
return $this;
}
/**
* 设置数据
*
* @param mixed $data
* @param number $data.today 今日数据
* @param number $data.yesterday 昨日数据
* @param number $data.growth_rate 增长率
* @return statistic
*/
public function setData(mixed $data): statistic
{
$this->data['props']['data'] = $data;
return $this;
}
public function setApi(string $api): statistic
{
$this->data['props']['api'] = $api;
return $this;
}
}
@@ -0,0 +1,11 @@
<?php
namespace app\expose\build\builder\databoardBuilder\interface;
use app\expose\build\builder\databoardBuilder\Basic;
interface DataboardBuilderInterface
{
public function setData(mixed $data): Basic;
public function setApi(string $api): Basic;
}