title('首页')
// ->body($this->buildPreviewButton())
// ->body($this->newline())
->body(
<<{$this->form_pageindex()->render()}
HTML
);
}
protected function form_pageindex(){
$form = new Form();
$form->confirm('您确定要提交表单吗?', 'content');
$form->disableResetButton();
$form->tab('首页', function (Form $form){
global $__MINI_GLOBAL_TENANT_ID__;
if($__MINI_GLOBAL_TENANT_ID__ == 0){
$form->radio('app_index_top_nav_style', '顶部头部风格')->options([0=>'关注 推荐 附近', 1=>'搜索轮播'])->default(Settings::get('app_index_top_nav_style', 0));
$form->divider();
$form->html(function () {
return '
---------------------------------------------------------------------------------
';
}, '小程序');
$form->multipleSelectTable('app_index_header_icon', '头部左右侧')
->title('图标库')
->max(2)
->from(IconRender::make())
->model(WxIcon::class, 'id', 'name', 'selectTable:formPageIndexTrait:app_index_header_icon')
->help('添加两个,分别是左右侧,小程序不显示右侧, 管理图标库>>(ps:如何控制顺序?) ')
->default(Settings::get('app_index_header_icon', ''));
$form->html(function () {
return '---------------------------------------------------------------------------------
';
}, 'App');
$form->multipleSelectTable('app_app_index_header_icon', '头部左右侧')
->title('图标库')
->max(2)
->from(IconRender::make())
->model(WxIcon::class, 'id', 'name', 'selectTable:formPageIndexTrait:app_app_index_header_icon')
->help('添加两个,分别是左右侧,小程序不显示右侧, 管理图标库>>(ps:如何控制顺序?) ')
->default(Settings::get('app_app_index_header_icon', ''));
$form->text('app_search_carousel', '搜索提示上下轮播')->help('就是首页搜索框里面的灰色字,用|号隔开')->default(Settings::get('app_search_carousel', '搜索笔记/'.env('circle_call', '圈子').'/用户|在这里写下你想寻找的'));
$form->divider();
}else{
if(Settings::get('app_index_top_nav_style', 0) == 1){
$form->text('app_search_carousel', '搜索提示上下轮播')->help('就是首页搜索框里面的灰色字,用|号隔开')->default(Settings::get('app_search_carousel', '搜索笔记/'.env('circle_call', '圈子').'/用户|在这里写下你想寻找的',true));
$form->divider();
}
}
if($__MINI_GLOBAL_TENANT_ID__ > 0){
$form->text('app_multi_index_text_share', '分享标题')->placeholder(Settings::get('app_share_right', ''))->default(Settings::get('app_multi_index_text_share', '', true));
$form->image('app_multi_index_img_share', '分享图片')->help('点击下载默认图,和默认图大小差不多就行')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('app_multi_index_img_share', '', true));
$form->divider();
}
$form->html(function () {
return '';
}, '');
$form->html(function () {
return '小提示:
1、你选择tab为“其他”类型时才需要配置跳转类型和id。
2、tab类型选择“板块”时,如果你不想用户重复添加这个板块,那么你就把tab“名字”写成板块的名字,相同的名字前端会去重处理
3、瀑布流控制不一定对所有tab都有效,有些强制瀑布流
4、icon正常不用配置,如果你需要,你也可以加,点击查看
使用说明
5、选择圈子类型时,可以在“跳转id”配置多个'.env('circle_call', '圈子').'id,用英文逗号隔开,请看
教程 ';
}, '');
$form->table('app_index_tab','固定tab自定义', function (NestedForm $table) {
$table->text('plate_name', '名字')->required();
$table->text('icon', '图标')->help('mini-xxx');
$table->select('show', '显示方式')->options([0=>'图标+名字', 1=>'仅显示图标']);
$table->radio('type', '类型 ')->options(
[0 => '关注', 1 => '推荐', 2 => '热门-全站', 9=>'热门-仅本站', 3=>'好物',4=>'板块', 5=>'视频',6=>'长图文', 7=>'附近', 8=>env('circle_call', '圈子'), 999=>'其他']
)->required()->default(1);
$table->switch('waterfall', '列表式/瀑布流');
$table->switch('force', '是否强制');
$table->multipleSelectTable('plate_ids', '板块(板块类型时)')->title('板块库')
->max(10)
->from(PlateRender::make())
->model(WxPlate::class, 'id', 'plate_name', 'selectTable:formPageIndexTrait:app_index_tab:plate_ids')
->help('允许选择多个,管理板块>>');
$table->select('target_type', '跳转类型(其他类型时)')->options(FieldUtils::getUrlTypes())->default(0);
$table->text('target', '跳转id(其他类型时)')->help('怎么填请看路径大全');
})->default(Settings::get('app_index_tab', '',true));
});
$form->tab('推荐tab', function (Form $form) {
$form->multipleSelectTable('app_index_banner', '轮播图')
->title('轮播图库')
->max(10)
->from(BannerRender::make())
->model(WxSlideshow::class, 'id', 'id', 'selectTable:formPageIndexTrait:app_index_banner')
->help('运营管理-轮播图中心(ps:如何控制顺序?) ')
->default(Settings::get('app_index_banner', '',true));
$form->number('app_index_banner_height', '轮播图高度')->help('默认是300rpx')->default(Settings::get('app_index_banner_height', 300,true));
$form->divider();
$form->table('app_index_notice','垂直滚动通知1', function (NestedForm $table) {
$table->text('text', '文本')->default('文字');
$table->image('img', '左侧图')->help('点击下载默认图')->default('https://img.mini.minisns.cn/2023/06/23/c8186968da891a2dac10ff5d4fbe0351.png')->uniqueName()->url('files/uploads')->autoUpload();
$table->radio('type', '类型')->options(FieldUtils::getUrlTypes())->default(0);
$table->text('target', '跳转id')->help('怎么填请看路径大全');
})->default(Settings::get('app_index_notice', '',true));
$form->divider();
$form->html(function () {
return '简单说明一下:
1、每行多少个是根据后台配置了多少个菜单除以2,如你配置了16个菜单,那么每行就是8个,配置了100个菜单,那每行是50个
2、跳转id怎么填,请看
这里 ';
}, '');
$xxx = '';
$form->table('app_index_nav','格子菜单', function (NestedForm $table) {
$table->text('name', '文本')->default('文字');
$table->image('img', '图片')->help('点击下载默认图')->default('https://img.mini.minisns.cn/images/nav/nav.png')->uniqueName()->url('files/uploads')->autoUpload();
$table->select('type', '类型')->options(FieldUtils::getUrlTypes())->default(0);
$table->text('target', '跳转id')->help('怎么填请看路径大全');
})->default(Settings::get('app_index_nav', '',true));
$form->divider();
global $__MINI_GLOBAL_TENANT_ID__;
if($__MINI_GLOBAL_TENANT_ID__ === 0){
$form->switch('app_index_realtime_post', '热帖榜')->help('每次更改需重新下载前端后生效')->default(Settings::get('app_index_realtime_post', 0));
}
$form->divider();
$form->html(function () {
return '首页排序说明:若不是配置了随机排序,则请至少添加2种排序,推荐的排序顺序为:1、计算热度 2、发表时间 3、文章ID
';
}, '');
$form->html(function () {
return '计算热度说明:
1、每次发布新内容时,都给这个笔记一个热度值,这个热度值是跟当前时间成正比,也就是越新发布的,热度值越大
2、如果有评论,喜欢等互动,就给这个热度值增加相应的热度
3、评论,喜欢等互动越来越多的时候,后面增加的热度值越来越小,但不会小到0。
4、效果是新发表的内容有稳定的曝光,同时增加互动量高的笔记曝光时间
';
}, '');
$form->html(function () {
return '随机排序说明:如果你想实现随机排序,则仅需要配置一个随机天数,其他的都不要选择
';
}, '');
$res5 = __system__paycode__tip__(5);
Tooltip::make('.mini_global_admin_open_not_support_tip')
->bottom()
->title($res5['tip']);
$form->listbox('app_index_list_sort', '内容列表排序')->options([
'weight' => '计算热度',
'created_at'=>'发表时间',
'last_reply_at' => '最后回复时间',
'id' => '文章ID',
'rand_3650' => '随机—3650天',
'rand_365' => '随机—365天',
'rand_100' => '随机—100天',
'rand_60' => '随机—60天',
'rand_30' => '随机—30天',
'rand_10' => '随机—10天',
'rand_7' => '随机—7天',
'rand_new_1000' => '随机—1000篇',
'rand_new_3000' => '随机—3000篇',
'rand_new_5000' => '随机—5000篇',
'rand_new_10000' => '随机—10000篇',
'rand_new_100000' => '随机—100000篇',
])->customFormat(function ($value){
return Settings::get('app_index_list_sort', ['id'],true);
})->help($res5['text'].'(这里解锁说的是 计算热度 ,并非这个配置用不了) 右边代表选中');
$form->divider();
$form->radio('app_index_flow', '扩展推流')->options([0=>'关闭', 1=>'开启'])->default(Settings::get('app_index_flow', 1,true));
$form->divider();
$form->multipleSelectTable('app_index_not_list_circles', '不显示内容的'.env('circle_call', '圈子'))
->title(env('circle_call', '圈子').'列表')
->max(100)
->from(CircleRender::make())
->model(WxCircle::class, 'id', 'circle_name', 'selectTable:formPageIndexTrait:app_index_not_list_circles')
->help('配置了之后,首页不显示对应的'.env('circle_call', '圈子').'内容(ps:如何控制顺序?) ')
->default(Settings::get('app_index_not_list_circles', '',true));
});
$form->tab('热门tab', function (Form $form) {
$form->html(function () {
return '说明一下:开源版本的热门内容是依据喜欢数排序,捐助实时热榜的用户,自动采用热度排序。
';
}, '');
});
$form->tab('好物tab', function (Form $form) {
$form->html(function () {
return '';
}, '');
$form->table('app_index_shop_nav','格子菜单', function (NestedForm $table) {
$table->text('name', '文本')->default('文字');
$table->image('img', '图片')->help('点击下载默认图')->default('https://img.mini.minisns.cn/images/nav/nav.png')->uniqueName()->url('files/uploads')->autoUpload();
$table->radio('type', '类型')->options(FieldUtils::getUrlTypes())->default(0);
$table->text('target', '跳转id')->help('怎么填请看路径大全');
})->default(Settings::get('app_index_shop_nav', '',true));
$form->multipleSelect('app_index_shop_classify', '加载商品分类')->options(WxShopClassify::pluck('name', 'id'))->help('留空则加载全部分类')->default(Settings::get('app_index_shop_classify', [], true));
});
$form->tab('相亲Tab', function (Form $form) {
$form->multipleSelectTable('app_xiangqin_index_banner', '轮播图')
->title('轮播图库')
->max(10)
->from(BannerRender::make())
->model(WxSlideshow::class, 'id', 'id', 'selectTable:formPageIndexTrait:app_xiangqin_index_banner')
->help('运营管理-轮播图中心(ps:如何控制顺序?) ')
->default(Settings::get('app_xiangqin_index_banner', '',true));
$form->number('app_xiangqin_index_banner_height', '轮播图高度')->help('默认是300rpx')->default(Settings::get('app_xiangqin_index_banner_height', 300,true));
$form->divider();
$form->table('app_xiangqin_index_notice','垂直滚动通知', function (NestedForm $table) {
$table->text('text', '文本')->default('文字');
$table->image('img', '左侧图')->help('点击下载默认图')->default('https://img.mini.minisns.cn/2023/06/23/c8186968da891a2dac10ff5d4fbe0351.png')->uniqueName()->url('files/uploads')->autoUpload();
$table->radio('type', '类型')->options(FieldUtils::getUrlTypes())->default(0);
$table->text('target', '跳转id')->help('怎么填请看路径大全');
})->default(Settings::get('app_xiangqin_index_notice', '',true));
$form->divider();
// $form->html(function () {
// return '简单说明一下:
1、每行多少个是根据后台配置了多少个菜单除以2,如你配置了16个菜单,那么每行就是8个,配置了100个菜单,那每行是50个
2、跳转id怎么填,请看
这里 ';
// }, '');
$form->table('app_xiangqin_index_nav','格子菜单', function (NestedForm $table) {
$table->text('name', '文本')->default('文字');
$table->image('img', '图片')->help('点击下载默认图')->default('https://img.mini.minisns.cn/images/nav/nav.png')->uniqueName()->url('files/uploads')->autoUpload();
$table->select('type', '类型')->options(FieldUtils::getUrlTypes())->default(0);
$table->text('target', '跳转id')->help('怎么填请看路径大全');
})->default(Settings::get('app_xiangqin_index_nav', '',true));
$form->divider();
});
$form->action('settings/action/pageindex');
return $form;
}
public function pageindex(Request $request)
{
global $__MINI_GLOBAL_TENANT_ID__;
$app_index_tab = AdminUtils::_table_data($request->input('app_index_tab'));
if(count(json_decode($app_index_tab, true)) < 2){
return $this->response()->error('首页固定tab最少配置2个');
}
SiteUtils::forget_config_data();
if($__MINI_GLOBAL_TENANT_ID__ > 0){
Settings::set('app_multi_index_text_share', $request->input('app_multi_index_text_share'), true, true);
Settings::set('app_multi_index_img_share', $request->input('app_multi_index_img_share'), true, true);
SettingImgToJpgJob::dispatch([ _multi_key('app_multi_index_img_share') ]);
}
Settings::set('app_index_not_list_circles', $request->input('app_index_not_list_circles'), true, true);
Settings::set('app_index_banner', AdminUtils::_multipleSelectTable_order_process('selectTable:formPageIndexTrait:app_index_banner', $request->input('app_index_banner')) , true, true);
Settings::set('app_index_banner_height', $request->input('app_index_banner_height'), true, true);
Settings::set('app_index_flow', $request->input('app_index_flow'), true, true);
Settings::set('app_xiangqin_index_banner', AdminUtils::_multipleSelectTable_order_process('selectTable:formPageIndexTrait:app_xiangqin_index_banner', $request->input('app_xiangqin_index_banner')) , true, true);
Settings::set('app_xiangqin_index_banner_height', $request->input('app_xiangqin_index_banner_height'), true, true);
global $__MINI_GLOBAL_TENANT_ID__;
if($__MINI_GLOBAL_TENANT_ID__ == 0){
Settings::set('app_index_top_nav_style', $request->input('app_index_top_nav_style'), true);
Settings::set('app_index_header_icon', AdminUtils::_multipleSelectTable_order_process('selectTable:formPageIndexTrait:app_index_header_icon', $request->input('app_index_header_icon')) , true);
Settings::set('app_app_index_header_icon', AdminUtils::_multipleSelectTable_order_process('selectTable:formPageIndexTrait:app_app_index_header_icon', $request->input('app_app_index_header_icon')) , true);
Settings::set('app_search_carousel', $request->input('app_search_carousel'), true);
}else{
if(Settings::get('app_index_top_nav_style', 0) == 1){
Settings::set('app_search_carousel', $request->input('app_search_carousel'), true, true);
}
}
if($__MINI_GLOBAL_TENANT_ID__ === 0){
Settings::set('app_index_realtime_post', $request->input('app_index_realtime_post') == 1 ? 1 : 0, true);
}
Settings::set('app_index_tab', $app_index_tab, true, true);
Settings::set('app_index_notice', AdminUtils::_table_data($request->input('app_index_notice')), true, true);
Settings::set('app_index_nav', AdminUtils::_table_data($request->input('app_index_nav')), true, true);
Settings::set('app_xiangqin_index_nav', AdminUtils::_table_data($request->input('app_xiangqin_index_nav')), true, true);
Settings::set('app_index_list_sort', $request->input('app_index_list_sort'), true, true);
Settings::set('app_index_shop_nav', AdminUtils::_table_data($request->input('app_index_shop_nav')), true, true);
Settings::set('app_xiangqin_index_notice', AdminUtils::_table_data($request->input('app_xiangqin_index_notice')), true, true);
Settings::set('app_index_shop_classify', $request->input('app_index_shop_classify'), true, true);
$__global_config_version__ = Settings::get('__global_config_version__', 1) + 1;
Settings::set('__global_config_version__', $__global_config_version__);
GatewayUtils::success('all', 13, [ 'version' => $__global_config_version__, 'file' => basename(__FILE__) ]);
return $this->response()->success('成功!');
}
}