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,441 @@
<?php
namespace plugin\shortplay\app\control\controller;
use app\Basic;
use app\expose\build\builder\ActionBuilder;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use plugin\shortplay\app\model\PluginShortplayActor;
use plugin\shortplay\utils\enum\ActorAge;
use plugin\shortplay\utils\enum\ActorGender;
use plugin\shortplay\utils\enum\ActorSpeciesType;
use plugin\shortplay\utils\enum\ActorStatus;
use support\Request;
class ActorController extends Basic
{
public function __construct()
{
$this->model = new PluginShortplayActor;
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder;
$builder->addAction('操作', [
'width' => '180px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'model' => Action::DIALOG['value'],
'path' => '/app/shortplay/control/Actor/update',
'props' => [
'title' => '编辑《ID{id}》演员'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addTableAction('初始化', [
'model' => Action::COMFIRM['value'],
'path' => '/app/shortplay/control/Actor/submitInit',
'props' => [
'title' => '确定要初始化《{name}》演员吗?'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'warning',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('创建演员', [
'model' => Action::DIALOG['value'],
'path' => '/app/shortplay/control/Actor/create',
'props' => [
'title' => '创建演员'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder(null, null, [
'inline' => true
]);
$formBuilder->add('name', '名称', 'input', '', [
'props' => [
'placeholder' => '名称搜索',
'clearable' => true
]
]);
$formBuilder->add('actor_id', '演员ID', 'input', '', [
'props' => [
'placeholder' => '演员ID搜索',
'clearable' => true
]
]);
$formBuilder->add('drama_id','公共演员','select','',[
'options' => [
['label' => '是', 'value' => 1],
['label' => '否', 'value' => 0]
],
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '100px'
]
]);
$builder->add('user', '用户', [
'where' => [
['uid', '!=', null]
],
'component' => [
'name' => 'table-userinfo',
'props' => [
'nickname' => 'user.nickname',
'avatar' => 'user.headimg',
'info' => 'user.mobile',
'tags' => [
[
'field' => 'uid',
'props' => [
'type' => 'success',
'size' => 'small'
]
]
],
]
],
'props' => [
'width' => '300px'
]
]);
$builder->add('actorinfo', '演员', [
'component' => [
'name' => 'table-userinfo',
'props' => [
'nickname' => 'name',
'avatar' => 'headimg',
'info' => 'actor_id',
'preview' => true
]
],
'props' => [
'width' => '300px'
]
]);
$builder->add('three_view_image', '三视图', [
'component' => [
'name' => 'image',
'props' => [
'style' => 'width: 100px; height: 100px;',
'fit' => 'cover'
]
],
'props' => [
'width' => '133px'
]
]);
$builder->add('species_type', '物种', [
'component' => [
'name' => 'tag',
'options' => ActorSpeciesType::getOptions(),
],
'props' => [
'width' => '180px'
]
]);
$builder->add('gender', '性别', [
'component' => [
'name' => 'tag',
'options' => ActorGender::getOptions(),
],
'props' => [
'width' => '100px'
]
]);
$builder->add('age', '年龄', [
'component' => [
'name' => 'tag',
'options' => ActorAge::getOptions(),
],
'props' => [
'width' => '100px'
]
]);
$builder->add('status', '状态', [
'component' => [
'name' => 'tag',
'options' => ActorStatus::getOptions(),
],
'props' => [
'width' => '100px'
]
]);
$builder->add('remarks', '人物描述', [
'props' => [
'minWidth' => '300px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function query(Request $request)
{
$query = $request->post('query');
if (empty($query)) {
return $this->resData([]);
}
$where = [];
$where[] = ['name|actor_id|remarks', 'like', "%{$query}%"];
return $this->resData(PluginShortplayActor::options($where));
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$where[] = ['channels_uid', '=', $request->channels_uid];
$name = $request->get('name');
if ($name) {
$where[] = ['name', 'like', "%{$name}%"];
}
$actor_id = $request->get('actor_id');
if ($actor_id) {
$where[] = ['actor_id', 'like', "%{$actor_id}%"];
}
$drama_id = $request->get('drama_id');
if ($drama_id==1) {
$where[] = ['uid', '=', null];
} else {
$where[] = ['uid', '>', 0];
}
$list = PluginShortplayActor::where($where)->with(['user' => function ($query) {
$query->field('id,nickname,headimg,mobile,channels_uid');
}])
->order('id desc')->paginate($limit)->each(function ($item) {});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() === 'POST') {
$D = $request->post();
try {
$PluginShortplayActor = new PluginShortplayActor;
$PluginShortplayActor->channels_uid = $request->channels_uid;
$PluginShortplayActor->name = $D['name'];
$PluginShortplayActor->headimg = $D['headimg'];
$PluginShortplayActor->species_type = $D['species_type'];
$PluginShortplayActor->gender = $D['gender'];
$PluginShortplayActor->age = $D['age'];
$PluginShortplayActor->status = $D['status'];
$PluginShortplayActor->three_view_image = $D['three_view_image'];
$PluginShortplayActor->remarks = $D['remarks'];
$PluginShortplayActor->save();
} catch (\Throwable $th) {
return $this->exception($th);
}
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() === 'POST') {
$D = $request->post();
try {
$PluginShortplayActor = PluginShortplayActor::where(['id' => $D['id'], 'channels_uid' => $request->channels_uid])->find();
$PluginShortplayActor->channels_uid = $request->channels_uid;
$PluginShortplayActor->name = $D['name'];
$PluginShortplayActor->headimg = $D['headimg'];
$PluginShortplayActor->species_type = $D['species_type'];
$PluginShortplayActor->gender = $D['gender'];
$PluginShortplayActor->age = $D['age'];
$PluginShortplayActor->status = $D['status'];
$PluginShortplayActor->three_view_image = $D['three_view_image'];
$PluginShortplayActor->remarks = $D['remarks'];
$PluginShortplayActor->save();
} catch (\Throwable $th) {
return $this->exception($th);
}
return $this->success('更新成功');
}
$id = $request->get('id');
$Actor = PluginShortplayActor::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
$builder = $this->getFormBuilder();
$builder->setData($Actor->toArray());
return $this->resData($builder);
}
private function getFormBuilder()
{
$builder = new FormBuilder(null, null, [
'translations' => true,
'size' => 'large',
]);
$Component = new ComponentBuilder;
$builder->add('headimg', '形象', 'bundle', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 8,
'xl' => 8
],
'prompt' => [
$Component->add('text', ['default' => '支持jpg、png、jpeg格式,大小不超过3M'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'accept' => 'image/jpeg,image/png,image/jpg',
'multiple' => 1,
'size' => 3,
'customStyle' => '--el-upload-list-picture-card-height:200px;--el-upload-list-picture-card-width:160px;'
]
]);
$builder->add('three_view_image', '三视图', 'bundle', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 8,
'xl' => 8
],
'prompt' => [
$Component->add('text', ['default' => '支持jpg、png、jpeg格式,大小不超过3M,推荐1:1比例'], ['type' => 'info', 'size' => 'small'])->builder()
],
'props' => [
'accept' => 'image/jpeg,image/png,image/jpg',
'multiple' => 1,
'size' => 3,
'customStyle' => '--el-upload-list-picture-card-height:200px;--el-upload-list-picture-card-width:200px;'
]
]);
$builder->add('name', '名称', 'input', '', [
'required' => true,
'maxlength' => 30,
'show-word-limit' => true,
]);
$builder->add('species_type', '物种', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 8,
'xl' => 8
],
'options' => ActorSpeciesType::getOptions(),
'required' => true,
]);
$builder->add('gender', '性别', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 8,
'xl' => 8
],
'options' => ActorGender::getOptions(),
'required' => true,
]);
$builder->add('age', '年龄', 'select', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 8,
'xl' => 8
],
'options' => ActorAge::getOptions(),
'required' => true,
]);
$builder->add('status', '状态', 'radio', ActorStatus::INITIALIZING['value'], [
'options' => ActorStatus::getOptions(),
'subProps' => [
'border' => true
],
'required' => true,
]);
$builder->add('remarks', '人物描述', 'input', '', [
'props' => [
'type' => 'textarea',
'autosize' => [
'minRows' => 4,
'maxRows' => 20
]
]
]);
return $builder;
}
public function generateHeadimg(Request $request)
{
$prompt = $request->post('prompt');
if (empty($prompt)) {
return $this->fail('AI提示词不能为空');
}
$actionBuilder = new ActionBuilder();
$headimg = 'https://' . $request->host() . '/uploads/default/20251122/5b8dcf4cbec3ba58057884929194349c_69217f42205c5.jfif';
$actionBuilder->setData([
'headimg' => $headimg
]);
$actionBuilder->setDataAction('append');
return $this->success('生成成功', $actionBuilder);
}
public function generateThreeViewImage(Request $request)
{
$prompt = $request->post('prompt');
if (empty($prompt)) {
return $this->fail('AI提示词不能为空');
}
$actionBuilder = new ActionBuilder();
$headimg = 'https://' . $request->host() . '/uploads/default/20251122/5b8dcf4cbec3ba58057884929194349c_69217f42205c5.jfif';
$actionBuilder->setData([
'three_view_image' => $headimg
]);
$actionBuilder->setDataAction('append');
return $this->success('生成成功', $actionBuilder);
}
public function submitInit(Request $request)
{
$id = $request->post('id');
$Actor = PluginShortplayActor::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
if (!$Actor) {
return $this->fail('演员不存在');
}
$Actor->status = ActorStatus::PENDING['value'];
$Actor->actor_id = uniqid();
$Actor->three_view_image = $Actor->headimg;
$Actor->save();
return $this->success('初始化成功');
}
}
@@ -0,0 +1,165 @@
<?php
namespace plugin\shortplay\app\control\controller;
use app\Basic;
use app\expose\build\builder\ActionBuilder;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\State;
use plugin\shortplay\app\model\PluginShortplayDrama;
use plugin\shortplay\app\model\PluginShortplayStyle;
use plugin\shortplay\utils\enum\StyleClassify;
use support\Request;
class DramaController extends Basic
{
public function indexGetTable(Request $request)
{
$builder = new TableBuilder([
]);
// $builder->addAction('操作', [
// 'width' => '180px',
// 'fixed' => 'right'
// ]);
// $builder->addTableAction('编辑', [
// 'model' => Action::DIALOG['value'],
// 'path' => '/app/shortplay/control/Actor/update',
// 'props' => [
// 'title' => '编辑《ID{id}》演员'
// ],
// 'component' => [
// 'name' => 'button',
// 'props' => [
// 'type' => 'primary',
// 'size' => 'small'
// ]
// ]
// ]);
$builder->addHeader();
$formBuilder = new FormBuilder(null, null, [
'inline' => true
]);
$formBuilder->add('title', '名称', 'input', '', [
'props' => [
'placeholder' => '名称搜索',
'clearable' => true
]
]);
$formBuilder->add('uid', '用户ID', 'input', '', [
'props' => [
'placeholder' => '用户ID搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '100px'
]
]);
$builder->add('user', '用户', [
'where' => [
['uid', '!=', null]
],
'component' => [
'name' => 'table-userinfo',
'props' => [
'nickname' => 'user.nickname',
'avatar' => 'user.headimg',
'info' => 'user.mobile',
'tags' => [
[
'field' => 'uid',
'props' => [
'type' => 'success',
'size' => 'small'
]
]
],
]
],
'props' => [
'width' => '300px'
]
]);
$builder->add('title', '剧本名称', [
'props' => [
'minWidth' => '200px'
]
]);
$builder->add('description', '剧本简介', [
'props' => [
'minWidth' => '300px'
]
]);
$builder->add('cover', '封面', [
'component' => [
'name' => 'image',
'props' => [
'style' => 'width: 100px; height: 100px;',
'fit' => 'cover'
]
],
'props' => [
'width' => '133px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => '/app/shortplay/control/Drama/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '100px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$where[] = ['channels_uid', '=', $request->channels_uid];
$title = $request->get('title');
if ($title) {
$where[] = ['title', 'like', "%{$title}%"];
}
$uid = $request->get('uid');
if ($uid) {
$where[] = ['uid', '=', $uid];
}
$list = PluginShortplayDrama::where($where)
->order('id desc')->paginate($limit);
return $this->resData($list);
}
}
@@ -0,0 +1,167 @@
<?php
namespace plugin\shortplay\app\control\controller;
use app\Basic;
use app\expose\build\builder\ActionBuilder;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\State;
use plugin\shortplay\app\model\PluginShortplayDrama;
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
use plugin\shortplay\utils\enum\StyleClassify;
use support\Request;
class DramaEpisodeController extends Basic
{
public function indexGetTable(Request $request)
{
$list=PluginShortplayDrama::field('id as value,title as label')->select();
$builder = new TableBuilder( );
$builder->addHeader();
$formBuilder = new FormBuilder(null, null, [
'inline' => true
]);
$formBuilder->add('drama_id', '剧本', 'select', '', [
'options' => $list,
'props' => [
'placeholder' => '剧本搜索',
'clearable' => true
]
]);
$formBuilder->add('title', '分集名称', 'input', '', [
'props' => [
'placeholder' => '分集名称搜索',
'clearable' => true
]
]);
$formBuilder->add('uid', '用户ID', 'input', '', [
'props' => [
'placeholder' => '用户ID搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '100px'
]
]);
$builder->add('user', '用户', [
'where' => [
['uid', '!=', null]
],
'component' => [
'name' => 'table-userinfo',
'props' => [
'nickname' => 'user.nickname',
'avatar' => 'user.headimg',
'info' => 'user.mobile',
'tags' => [
[
'field' => 'uid',
'props' => [
'type' => 'success',
'size' => 'small'
]
]
],
]
],
'props' => [
'width' => '300px'
]
]);
$builder->add('drama.title', '剧本名称', [
'props' => [
'minWidth' => '200px',
]
]);
$builder->add('title', '分集名称', [
'props' => [
'minWidth' => '200px',
]
]);
$builder->add('content', '分集内容', [
'props' => [
'minWidth' => '300px',
'show-overflow-tooltip'=>true
]
]);
$builder->add('cover', '封面', [
'component' => [
'name' => 'image',
'props' => [
'style' => 'width: 100px; height: 100px;',
'fit' => 'cover'
]
],
'props' => [
'width' => '133px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => '/app/shortplay/control/Drama/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '100px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$where[] = ['channels_uid', '=', $request->channels_uid];
$title = $request->get('title');
if ($title) {
$where[] = ['title', 'like', "%{$title}%"];
}
$uid = $request->get('uid');
if ($uid) {
$where[] = ['uid', '=', $uid];
}
$drama_id = $request->get('drama_id');
if ($drama_id) {
$where[] = ['drama_id', '=', $drama_id];
}
$list = PluginShortplayDramaEpisode::where($where)
->with(['drama'])
->order('id desc')
->paginate($limit);
return $this->resData($list);
}
}
@@ -0,0 +1,319 @@
<?php
namespace plugin\shortplay\app\control\controller;
use app\Basic;
use app\expose\build\builder\ActionBuilder;
use app\expose\build\builder\ComponentBuilder;
use app\expose\build\builder\FormBuilder;
use app\expose\build\builder\TableBuilder;
use app\expose\enum\Action;
use app\expose\enum\State;
use plugin\shortplay\app\model\PluginShortplayStyle;
use plugin\shortplay\utils\enum\StyleClassify;
use support\Request;
class StyleController extends Basic
{
public function __construct()
{
$this->model = new PluginShortplayStyle;
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder;
$builder->addAction('操作', [
'width' => '180px',
'fixed' => 'right'
]);
$builder->addTableAction('编辑', [
'model' => Action::DIALOG['value'],
'path' => '/app/shortplay/control/Style/update',
'props' => [
'title' => '编辑《ID{id}》风格'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'primary',
'size' => 'small'
]
]
]);
$builder->addHeader();
$builder->addHeaderAction('创建风格', [
'model' => Action::DIALOG['value'],
'path' => '/app/shortplay/control/Style/create',
'props' => [
'title' => '创建风格'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$formBuilder = new FormBuilder(null, null, [
'inline' => true
]);
$formBuilder->add('name', '名称', 'input', '', [
'props' => [
'placeholder' => '名称搜索',
'clearable' => true
]
]);
$formBuilder->add('classify', '风格分类', 'select', '', [
'options' => StyleClassify::getOptions(),
'required' => true,
'props' => [
'placeholder' => '风格分类搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
$builder->add('id', 'ID', [
'props' => [
'width' => '100px'
]
]);
$builder->add('classify', '风格分类', [
'component' => [
'name' => 'tag',
'options' => StyleClassify::getOptions(),
],
'props' => [
'width' => '100px'
]
]);
$builder->add('styleinfo', '风格', [
'component' => [
'name' => 'table-userinfo',
'props' => [
'nickname' => 'name',
'avatar' => 'image',
'preview' => true
]
],
'props' => [
'width' => '300px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => '/app/shortplay/control/Style/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '100px'
]
]);
$builder->add('prompts', '提示词', [
'props' => [
'minWidth' => '300px'
]
]);
$builder->add('create_time', '时间', [
'props' => [
'width' => '200px'
],
'component' => [
'name' => 'table-times',
'props' => [
'group' => [
[
'field' => 'create_time',
'label' => '创建'
],
[
'field' => 'update_time',
'label' => '更新'
]
]
]
]
]);
$builder = $builder->builder();
return $this->resData($builder);
}
public function query(Request $request)
{
$query = $request->post('query');
if (empty($query)) {
return $this->resData([]);
}
$where = [];
$where[] = ['name|prompts', 'like', "%{$query}%"];
return $this->resData(PluginShortplayStyle::options($where));
}
public function index(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$where[] = ['channels_uid', '=', $request->channels_uid];
$name = $request->get('name');
if ($name) {
$where[] = ['name', 'like', "%{$name}%"];
}
$classify = $request->get('classify');
if ($classify) {
$where[] = ['classify', '=', $classify];
}
$list = PluginShortplayStyle::where($where)
->order('id desc')->paginate($limit)->each(function ($item) {});
return $this->resData($list);
}
public function create(Request $request)
{
if ($request->method() === 'POST') {
$D = $request->post();
try {
$PluginShortplayStyle = new PluginShortplayStyle;
$PluginShortplayStyle->channels_uid = $request->channels_uid;
$PluginShortplayStyle->name = $D['name'];
$PluginShortplayStyle->classify = $D['classify'];
$PluginShortplayStyle->image = $D['image'];
$PluginShortplayStyle->state = $D['state'];
$PluginShortplayStyle->prompts = $D['prompts'];
$PluginShortplayStyle->save();
} catch (\Throwable $th) {
return $this->exception($th);
}
return $this->success('创建成功');
}
$builder = $this->getFormBuilder();
return $this->resData($builder);
}
public function update(Request $request)
{
if ($request->method() === 'POST') {
$D = $request->post();
try {
$PluginShortplayStyle = PluginShortplayStyle::where(['id' => $D['id'], 'channels_uid' => $request->channels_uid])->find();
$PluginShortplayStyle->name = $D['name'];
$PluginShortplayStyle->classify = $D['classify'];
$PluginShortplayStyle->image = $D['image'];
$PluginShortplayStyle->state = $D['state'];
$PluginShortplayStyle->prompts = $D['prompts'];
$PluginShortplayStyle->save();
} catch (\Throwable $th) {
return $this->exception($th);
}
return $this->success('更新成功');
}
$id = $request->get('id');
$Style = PluginShortplayStyle::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
$builder = $this->getFormBuilder();
$builder->setData($Style->toArray());
return $this->resData($builder);
}
private function getFormBuilder()
{
$builder = new FormBuilder(null, null, [
'translations' => true,
'size' => 'large',
]);
$Component = new ComponentBuilder;
$builder->add('classify', '风格分类', 'radio', StyleClassify::ANIME['value'], [
'options' => StyleClassify::getOptions(),
'required' => true,
'subProps' => [
'border' => true
],
]);
$builder->add('image', '风格图', 'bundle', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 8,
'xl' => 8
],
'prompt' => [
$Component->add('text', ['default' => '支持jpg、png、jpeg格式,大小不超过2M'], ['type' => 'info', 'size' => 'small'])->builder()
],
'required' => true,
'props' => [
'accept' => 'image/jpeg,image/png,image/jpg',
'multiple' => 1,
'size' => 2,
'customStyle' => '--el-upload-list-picture-card-height:200px;--el-upload-list-picture-card-width:160px;'
]
]);
$actionBuilder = new ActionBuilder('', [
'class' => 'mt-4'
]);
$actionBuilder->add('AI 生成风格图', [
'model' => Action::REQUEST['value'],
'path' => '/app/shortplay/control/Style/generateImage',
'field' => '*',
'component' => [
'name' => 'button',
'props' => [
'type' => 'success',
'size' => 'small',
'bg' => true,
'text' => true,
'icon' => 'Refresh',
]
]
]);
$builder->add('prompt', 'AI 提示词', 'input', '', [
'col' => [
'xs' => 24,
'sm' => 24,
'md' => 12,
'lg' => 16,
'xl' => 16
],
'props' => [
'type' => 'textarea',
'autosize' => [
'minRows' => 4,
'maxRows' => 20
]
]
], $actionBuilder);
$builder->add('name', '名称', 'input', '', [
'required' => true,
'maxlength' => 30,
'show-word-limit' => true,
]);
$builder->add('state', '状态', 'radio', State::YES['value'], [
'options' => State::getOptions(),
'subProps' => [
'border' => true
],
'required' => true,
]);
$builder->add('prompts', '提示词', 'input', '', [
'required' => true,
'props' => [
'type' => 'textarea',
'autosize' => [
'minRows' => 4,
'maxRows' => 20
]
]
]);
return $builder;
}
public function generateImage(Request $request)
{
$prompt = $request->post('prompt');
if (empty($prompt)) {
return $this->fail('AI提示词不能为空');
}
$actionBuilder = new ActionBuilder();
$image = 'https://' . $request->host() . '/uploads/default/20251122/5b8dcf4cbec3ba58057884929194349c_69217f42205c5.jfif';
$actionBuilder->setData([
'image' => $image
]);
$actionBuilder->setDataAction('append');
return $this->success('生成成功', $actionBuilder);
}
}