formPagePublishTrait.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <?php
  2. namespace App\Admin\Controllers\Traits\WxSettingTraits;
  3. use App\Admin\Renderable\IconRender;
  4. use App\Admin\Renderable\PostRender;
  5. use App\Admin\Renderable\TagRender;
  6. use App\Admin\Renderable\UsersRender;
  7. use App\Models\Posts\WxPost;
  8. use App\Models\Posts\WxTag;
  9. use App\Models\User\WxUser;
  10. use App\Models\WxIcon;
  11. use App\Models\WxUniversity;
  12. use App\Wen\Utils\AdminUtils;
  13. use App\Wen\Utils\FieldUtils;
  14. use App\Wen\Utils\GatewayUtils;
  15. use App\Wen\Utils\Settings;
  16. use App\Wen\Utils\SiteUtils;
  17. use Dcat\Admin\Layout\Content;
  18. use Dcat\Admin\Widgets\Form;
  19. use Dcat\Admin\Widgets\Tooltip;
  20. use Illuminate\Http\Request;
  21. use Illuminate\Support\Facades\Cache;
  22. use Illuminate\Support\Facades\DB;
  23. trait formPagePublishTrait{
  24. public function index_publish(Content $content)
  25. {
  26. return $content->title('发布配置')
  27. // ->body($this->buildPreviewButton())
  28. // ->body($this->newline())
  29. ->body(
  30. <<<HTML
  31. <div class="card">{$this->form_publish()->render()}</div>
  32. HTML
  33. );
  34. }
  35. protected function form_publish(){
  36. $form = new Form();
  37. $form->confirm('您确定要提交表单吗?', 'content');
  38. $form->disableResetButton();
  39. $form->tab('弹窗', function (Form $form) {
  40. $form->row(function ($form) {
  41. $form->html(function () {
  42. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;display: inline-block;">提示:已登录的顶部提示<span style="color: red;">留空</span>,则代表关闭整个发布弹窗,直接跳转到发布页</div>';
  43. }, '');
  44. });
  45. $form->row(function ($form) {
  46. $form->html(function () {
  47. return '';
  48. }, '<b>1、顶部提示</b>');
  49. $form->width(3)->text('uni_tabbar_popup_tip_1', '已登录')->help('[in_days]将会被替换该用户的在线天数,默认:今天是你加入宠也的第[in_days]天')->default(Settings::get('uni_tabbar_popup_tip_1', '', true));
  50. $form->width(3)->text('uni_tabbar_popup_tip_2', '未登录')->default(Settings::get('uni_tabbar_popup_tip_2', '请先登录', true));
  51. });
  52. $form->divider();
  53. $form->row(function ($form) {
  54. $form->html(function () {
  55. return '';
  56. }, '<b>2、四个发布按钮</b>');
  57. });
  58. $form->row(function ($form) {
  59. $form->html(function () {
  60. return '<img src="https://img.mini.minisns.cn/hbx/tabbar/bg/page_publish_1.jpg" style="width: 300px;" />';
  61. }, '');
  62. });
  63. $form->html(function () {
  64. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;display: inline-flex;width: 330px; text-align: center; justify-content: center;">①</div>';
  65. }, '')->width(2);
  66. $form->row(function ($form) {
  67. $form->width(2)->text('uni_tabbar_popup_1_text_1', '第一行')->default(Settings::get('uni_tabbar_popup_1_text_1', '发笔记/图文', true));
  68. $form->width(2)->text('uni_tabbar_popup_1_text_2', '第二行')->default(Settings::get('uni_tabbar_popup_1_text_2', '分享好玩的', true));
  69. $form->width(2)->text('uni_tabbar_popup_1_path', '路径')->help('怎么填请看<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>')->default(Settings::get('uni_tabbar_popup_1_path', '/pages/creat/index/creat', true));
  70. });
  71. $form->divider();
  72. $form->html(function () {
  73. return '<div style="width:330px;display: flex;justify-content: space-between;"><div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;display: inline-flex;width: 100px; text-align: center; justify-content: center;">②</div><div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;display: inline-flex;width: 100px; text-align: center; justify-content: center;">③</div><div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;display: inline-flex;width: 100px; text-align: center; justify-content: center;">④</div></div>';
  74. }, '')->width(2);
  75. $form->row(function ($form) {
  76. $form->width(2)->image('uni_tabbar_popup_2_icon', '②')->url('files/uploads')->help('<a href="https://img.mini.minisns.cn/hbx/tabbar/icon-img1.png" target="_blank">点击下载默认图</a>')->uniqueName()->autoUpload()->required()->default(Settings::get('uni_tabbar_popup_2_icon', 'https://img.mini.minisns.cn/hbx/tabbar/icon-img1.png', true));
  77. $form->width(2)->image('uni_tabbar_popup_3_icon', '③')->url('files/uploads')->help('<a href="https://img.mini.minisns.cn/hbx/tabbar/icon-img2.png" target="_blank">点击下载默认图</a>')->uniqueName()->autoUpload()->required()->default(Settings::get('uni_tabbar_popup_3_icon', 'https://img.mini.minisns.cn/hbx/tabbar/icon-img2.png', true));
  78. $form->width(2)->image('uni_tabbar_popup_4_icon', '④')->url('files/uploads')->help('<a href="https://img.mini.minisns.cn/hbx/tabbar/icon-img3.png" target="_blank">点击下载默认图</a>')->uniqueName()->autoUpload()->required()->default(Settings::get('uni_tabbar_popup_4_icon', 'https://img.mini.minisns.cn/hbx/tabbar/icon-img3.png', true));
  79. });
  80. $form->row(function ($form) {
  81. $form->width(2)->text('uni_tabbar_popup_2_text', '')->default(Settings::get('uni_tabbar_popup_2_text', '', true));
  82. $form->width(2)->text('uni_tabbar_popup_3_text', '')->default(Settings::get('uni_tabbar_popup_3_text', '', true));
  83. $form->width(2)->text('uni_tabbar_popup_4_text', '')->default(Settings::get('uni_tabbar_popup_4_text', '', true));
  84. });
  85. $form->row(function ($form) {
  86. $form->width(2)->text('uni_tabbar_popup_2_path', '路径')->help('怎么填请看<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>')->default(Settings::get('uni_tabbar_popup_2_path', '', true));
  87. $form->width(2)->text('uni_tabbar_popup_3_path', '路径')->help('怎么填请看<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>')->default(Settings::get('uni_tabbar_popup_3_path', '', true));
  88. $form->width(2)->text('uni_tabbar_popup_4_path', '路径')->help('怎么填请看<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>')->default(Settings::get('uni_tabbar_popup_4_path', '', true));
  89. });
  90. $form->divider();
  91. $form->row(function ($form) {
  92. $form->html(function () {
  93. return '';
  94. }, '<b>3、创作灵感</b>');
  95. });
  96. $form->row(function ($form) {
  97. $form->html(function () {
  98. return '<img src="https://img.mini.minisns.cn/hbx/tabbar/bg/page_publish_2.jpg" style="width: 300px;" />';
  99. }, '');
  100. });
  101. $form->row(function ($form) {
  102. $form->width(3)->text('uni_tabbar_popup_5_title', '标题')->default(Settings::get('uni_tabbar_popup_5_title', '创作灵感', true));
  103. $form->width(3)->text('uni_tabbar_popup_5_desc', '描述')->default(Settings::get('uni_tabbar_popup_5_desc', '大家都想看,跟着创作热度高', true));
  104. });
  105. $form->row(function ($form) {
  106. $form->width(6)->multipleSelectTable('uni_tabbar_popup_5_tags', '选择话题')
  107. ->title('话题库')
  108. ->max(3)
  109. ->from(TagRender::make())
  110. ->model(WxTag::class, 'id', 'tags_name', 'selectTable:formPagePublishTrait:uni_tabbar_popup_5_tags')
  111. ->default(Settings::get('uni_tabbar_popup_5_tags', '', true));
  112. });
  113. });
  114. $form->tab('笔记', function (Form $form) {
  115. $form->html(function () {
  116. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">位置一、底部第二行开闭</div>';
  117. }, '');
  118. $form->html(function (){
  119. return '<div> <img src="https://img.mini.minisns.cn/hbx/fixed_2.jpg" style="width: 200px;" /></div>';
  120. });
  121. $form->checkbox('app_publish_tools_fixed2_left', '左边按钮')->options(['location' => '添加位置', 'circle' => env('circle_call', '圈子')])->default(Settings::get('app_publish_tools_fixed2_left', ['location', 'circle'], true));
  122. $form->checkbox('app_publish_tools_fixed2_right', '右边按钮')->options(['pay' => '付费', 'anonymous'=>'匿名'])->default(Settings::get('app_publish_tools_fixed2_right', ['pay'], true));
  123. $form->html(function () {
  124. return '<div style="border: 2px dashed red; padding: 10px;">101:图片&nbsp;&nbsp;&nbsp;102:视频&nbsp;&nbsp;&nbsp;103:话题&nbsp;&nbsp;&nbsp;104:Gif&nbsp;&nbsp;&nbsp;105:表情&nbsp;&nbsp;&nbsp;106:更多&nbsp;&nbsp;&nbsp;107:@&nbsp;&nbsp;&nbsp;108:电话<br/>
  125. 201:音频&nbsp;&nbsp;&nbsp;202:投票&nbsp;&nbsp;&nbsp;203:商品&nbsp;&nbsp;&nbsp;204:附件&nbsp;&nbsp;&nbsp;205:链接&nbsp;&nbsp;&nbsp;206:第三方商品&nbsp;&nbsp;&nbsp;207:视频号&nbsp;&nbsp;&nbsp;208:闲置&nbsp;&nbsp;&nbsp;209:组局</div>';
  126. }, '');
  127. $form->html(function () {
  128. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">位置二、底部倒数一行排列</div>';
  129. }, '');
  130. $form->html(function (){
  131. return '<div> <img src="https://img.mini.minisns.cn/images/publish/simple.jpg" style="width: 200px;" /></div>';
  132. });
  133. $form->text('app_publish_simple_fixed', '固定底部')->placeholder('101,102,103,104,105,106')->help('英文逗号隔开')->default(Settings::get('app_publish_simple_fixed', '101,102,103,104,105,106', true));
  134. $form->html(function () {
  135. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">位置三、底部弹窗排列</div>';
  136. }, '');
  137. $form->html(function (){
  138. return '<div> <img src="https://img.mini.minisns.cn/images/publish/simple2.jpg" style="width: 200px;" /></div>';
  139. });
  140. $form->text('app_publish_simple_popup', '底部弹窗')->placeholder('201,202,203,204')->help('英文逗号隔开')->default(Settings::get('app_publish_simple_popup', '201,202,203,204', true));
  141. });
  142. $form->tab('图文', function (Form $form) {
  143. $form->radio('app_publish_imagetext_switch', '发布图文')->options([0=>'关闭', 1=>'开启'])->default(Settings::get('app_publish_imagetext_switch', 1, true));
  144. $form->html(function () {
  145. return '<div style="border: 2px dashed red; padding: 10px;">301:段落&nbsp;&nbsp;&nbsp;302:图片&nbsp;&nbsp;&nbsp;303:视频&nbsp;&nbsp;&nbsp;304:链接&nbsp;&nbsp;&nbsp;305:音频&nbsp;&nbsp;&nbsp;306:表格&nbsp;&nbsp;&nbsp;307:撤回&nbsp;&nbsp;&nbsp;308:更多</div>';
  146. }, '');
  147. $form->html(function () {
  148. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">位置一、固定底部</div>';
  149. }, '');
  150. $form->text('app_publish_imagetext_fixed', '固定底部')->placeholder('301,302,303,305,307,308')->help('英文逗号隔开')->default(Settings::get('app_publish_imagetext_fixed', '301,302,303,305,307,308', true));
  151. $form->html(function () {
  152. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">位置二、底部弹窗</div>';
  153. }, '');
  154. $form->html(function (){
  155. return '<div> <img src="https://img.mini.minisns.cn/images/publish/simple2.jpg" style="width: 200px;" /></div>';
  156. });
  157. $form->text('app_publish_imagetext_popup', '底部弹窗')->placeholder('304,306')->help('英文逗号隔开')->default(Settings::get('app_publish_imagetext_popup', '304,306', true));
  158. });
  159. $form->tab('提示', function (Form $form) {
  160. $form->textarea('app_publish_placeholder_text', '发笔记默认提示')->default(Settings::get('app_publish_placeholder_text', '分享我的笔记', true));
  161. global $__MINI_GLOBAL_TENANT_ID__;
  162. if($__MINI_GLOBAL_TENANT_ID__ === 0){
  163. $form->switch('app_publish_success_popup', '发布成功弹窗')->default(Settings::get('app_publish_success_popup', 0) == 1 ? 1 : 0);
  164. }
  165. });
  166. $form->tab('媒体', function (Form $form) {
  167. $form->switch('app_upload_video_compress', '上传视频是否压缩')->help('压缩会牺牲画质,但减少空间,该配置仅对App生效,小程序内,微信默认会有压缩机制,需要你在相册选择的时候,勾选原图')->default(Settings::get('app_upload_video_compress', 1, true));
  168. $form->number('video_snapshot_time', 'App视频封面截第几秒')->default(Settings::get('video_snapshot_time', 3, true));
  169. $form->divider();
  170. $form->html(function () {
  171. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">小提示: 你可以将此值设置为10000,则默认关闭该功能,因为图片应该达不到这么大的宽度</div>';
  172. }, '');
  173. $form->number('app_upload_image_max_width', '图片最大宽度')->help('如果用户上传的图片大于该宽度,则自动等比缩小到该宽度,后台上传的图片不影响。')->default(Settings::get('app_upload_image_max_width', 800, true));
  174. $form->rate('app_upload_image_slimming', '图片保存质量')->default(Settings::get('app_upload_image_slimming', 100, true));
  175. });
  176. $form->tab('付费', function (Form $form) {
  177. $form->number('app_pay_max_coins', '最大金币付费')->default(Settings::get('app_pay_max_coins', 10000, true));
  178. $res7 = __system__paycode__tip__(7);
  179. Tooltip::make('.mini_global_admin_open_not_support_tip')
  180. ->bottom()
  181. ->title($res7['tip']);
  182. $form->number('app_pay_max_balance', '最大余额付费')->help($res7['text'])->default(Settings::get('app_pay_max_balance', 1000, true));
  183. });
  184. $form->tab('限制', function (Form $form) {
  185. $form->radio('app_publish_permissions', '发布权限')->options(FieldUtils::userPermissions())->default(Settings::get('app_publish_permissions', 0, true));
  186. $form->number('app_publish_frequency_min', '距上次发布最小分钟')->default(Settings::get('app_publish_frequency_min', 10, true));
  187. $form->number('app_publish_times_max', '每天最多发布数量')->default(Settings::get('app_publish_times_max', 3, true));
  188. $form->radio('app_publish_circle_required', '必选'.env('circle_call', '圈子'))->options([0=>'非必选', 1=>'必选'])->default(Settings::get('app_publish_circle_required', 0, true));
  189. $form->radio('app_publish_media_required', '禁止纯文字笔记')->options([0=>'不禁止', 1=>'禁止'])->default(Settings::get('app_publish_media_required', 0, true));
  190. $form->radio('app_publish_force_bind_phone', '强制绑定手机号')->options([0=>'不强制', 1=>'强制'])->default(Settings::get('app_publish_force_bind_phone', 0, true));
  191. $form->radio('app_publish_force_real_name', '强制实名')->options([0=>'不强制', 1=>'强制'])->default(Settings::get('app_publish_force_real_name', 0, true));
  192. global $__MINI_GLOBAL_TENANT_ID__;
  193. $form->radio('app_publish_force_subscribe_mp', '强制关注公众号')->options([0=>'不强制', 1=>'强制'])->help($__MINI_GLOBAL_TENANT_ID__ > 0 ? '必须开启服务器地址' : '必须开启服务器地址,具体请去[全局配置-支付-微信-公众号]')->default(Settings::get('app_publish_force_subscribe_mp', 0, true));
  194. $form->multipleSelect('app_publish_force_university', '强制学生认证')->options(function ($sids) {
  195. if($sids){
  196. $res = ['-1'=>'全域'];
  197. foreach ($sids as $sid){
  198. $university = WxUniversity::where('sid', $sid)->first();
  199. if ($university) {
  200. $res[$university->sid] = $university->name;
  201. }
  202. }
  203. return $res;
  204. }else{
  205. return ['-1'=>'全域'];
  206. }
  207. })->placeholder('请输入学校名字进行搜索')->ajax('select/universities')->default(Settings::get('app_publish_force_university', [], true));
  208. $form->html(function () {
  209. return '';
  210. }, '<b>上传</b>');
  211. $form->number('app_upload_max_files', '最大上传附件数')->help('不包活图片,仅指附件形式的等')->default(Settings::get('app_upload_max_files', 5, true));
  212. $form->number('app_upload_max_size_files', '单个附件最大(单位M)')->help('默认10M,这里每次更改,都需要重新更新前端才能生效')->default(Settings::get('app_upload_max_size_files', 10, true));
  213. $form->number('app_upload_max_sounds', '最大上传音频数')->default(Settings::get('app_upload_max_sounds', 1, true));
  214. // $form->number('app_upload_max_imgs', '最大上传图片数')->default(Settings::get('app_upload_max_imgs', 9));
  215. $form->html(function () {
  216. return '';
  217. }, '<b>投票</b>');
  218. $form->number('app_vote_max_options', '最大投票选项数')->default(Settings::get('app_vote_max_options', 10, true));
  219. $form->html(function () {
  220. return '';
  221. }, '<b>二次编辑</b>');
  222. $form->number('app_publish_edit_need_coin', '二次编辑消耗金币')->default(Settings::get('app_publish_edit_need_coin', ($__MINI_GLOBAL_TENANT_ID__ > 0 ? Settings::get('app_publish_edit_need_coin', 100) : 100), true));
  223. });
  224. $form->tab('水印', function (Form $form) {
  225. $form->html(function () {
  226. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">特别注意:<br/>1、后台上传的图片不会处理<br/>2、这种方式处理之后,查看原图,列表页等所有场景都会存在水印,且需要php安装imagemagick扩展(记得重启PHP)<br/>3、水印和图片之间是相对大小的,也就是说,系统会根据图片的大小做对应的调整,使整体看起来,水印都占比一样大</div>';
  227. }, '');
  228. $form->radio('app_upload_image_mask_type', '水印类型')->options([0=>'无', 1=> '图片', 2=>'文字(未开发)'])->when(1, function (Form $form){
  229. $form->rate('app_upload_image_mask_rate', '水印大小')->help('相对于上传的图片的百分比,然后对水印图片进行放缩到该大小,比如上传了很小的图片,水印也会相应的变小')->default(Settings::get('app_upload_image_mask_rate', 5, true));
  230. $form->rate('app_upload_image_mask_opacity', '水印透明度')->help('1-100')->default(Settings::get('app_upload_image_mask_opacity', 100, true));
  231. $form->text('app_upload_image_mask_img', '水印图片地址')->help('填例如: mask/mask.png,同时把水印文件上传到storage/mask目录下,点击查看<a href="https://img.mini.minisns.cn/images/hbx/mask_tip.jpg" target="_blank">教程图</a>')->default(Settings::get('app_upload_image_mask_img', '', true));
  232. $form->radio('app_upload_image_mask_pos', '水印位置')->options(['1'=>1, '2'=>2, '3'=>3, '4'=>4, '5'=>5, '6'=>6, '7'=>7, '8'=>8, '9'=>9])->help('1-9分包对应9个位置宫格,默认5代表中间')->default(Settings::get('app_upload_image_mask_pos', 5, true));
  233. })->default(Settings::get('app_upload_image_mask_type', 0, true));
  234. });
  235. $form->tab('选择话题', function (Form $form) {
  236. $form->html(function () {
  237. return '<a href="https://img.mini.minisns.cn/hbx/select_topic.jpg" target="_blank">点击查看,这里设置的是什么地方</a>';
  238. }, '');
  239. $form->multipleSelectTable('app_page_create_tags', '热门话题')
  240. ->title('话题库')
  241. ->max(10)
  242. ->from(TagRender::make())
  243. ->model(WxTag::class, 'id', 'tags_name', 'selectTable:formPagePublishTrait:app_page_create_tags')
  244. ->help('没有手动配置的情况下:如果捐助了<a href="https://ext.dcloud.net.cn/plugin?id=11115" target="_blank">【实时热榜】</a>,则使用实时热榜的数据,如果没有该付费模块,则按照话题引用累计总次数进行排序<a href="https://doc.minisns.cn/doc/70/" target="_blank" style="color: red;">(ps:如何控制顺序?)&nbsp;</a>')
  245. ->default(Settings::get('app_page_create_tags', '', true));
  246. });
  247. $form->tab('发布页2', function (Form $form) {
  248. $form->html(function () {
  249. return '<a href="https://img.mini.minisns.cn/images/mini/uni/971.jpg" target="_blank">点击查看,这里设置的是什么地方</a>';
  250. }, '');
  251. $form->html(function () {
  252. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">一、背景</div>';
  253. }, '');
  254. $form->image('app_publish2_bg_img', '背景')->help('<a href="https://img.mini.minisns.cn/images/hbx/publish2-bg.jpg" download="app_share_vip_img.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_publish2_bg_img', 'https://img.mini.minisns.cn/images/hbx/publish2-bg.jpg'));
  255. $form->html(function () {
  256. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">二、笔记展示</div>';
  257. }, '');
  258. $form->multipleSelectTable('app_publish2_post_show', '笔记展示')
  259. ->title('笔记库')
  260. ->max(10)
  261. ->from(PostRender::make())
  262. ->model(WxPost::class, 'id', 'id', 'selectTable:formPagePublishTrait:app_publish2_post_show')
  263. ->help('只能选择一个,<a href="'.admin_url('/posts/index').'" target="_blank">管理笔记库>></a><a href="https://doc.minisns.cn/doc/70/" target="_blank" style="color: red;">(ps:如何控制顺序?)&nbsp;</a>')
  264. ->default(Settings::get('app_publish2_post_show', '', true));
  265. $form->html(function () {
  266. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">三、发布选项</div>';
  267. }, '');
  268. $form->multipleSelectTable('app_publish2_square_list', '发布选项')
  269. ->title('图标库')
  270. ->max(2)
  271. ->from(IconRender::make())
  272. ->model(WxIcon::class, 'id', 'name', 'selectTable:formPagePublishTrait:app_publish2_square_list')
  273. ->help('<a href="'.admin_url('settings/icons').'" target="_blank">管理图标库>></a><a href="https://doc.minisns.cn/doc/70/" target="_blank" style="color: red;">(ps:如何控制顺序?)&nbsp;</a>')
  274. ->default(Settings::get('app_publish2_square_list', '', true));
  275. });
  276. $form->tab('视频号', function (Form $form) {
  277. $form->multipleSelectTable('app_publish_post_sph_user', '视频号笔记发布员')
  278. ->title('用户')
  279. ->max(100)
  280. ->from(UsersRender::make())
  281. ->model(WxUser::class, 'id', 'user_name', 'selectTable:formPagePublishTrait:app_publish_post_sph_user')
  282. ->help('视频号发布用户设置,默认只允许管理员发布视频号笔记,但若你找了别人替你发布视频号笔记,可以这里增加,那么他的发布页就会显示 视频号 的功能')
  283. ->default(Settings::get('app_publish_post_sph_user', '', true));
  284. });
  285. $form->action('settings/action/publish');
  286. return $form;
  287. }
  288. public function publish(Request $request){
  289. global $__MINI_GLOBAL_TENANT_ID__;
  290. if(!_empty_($request->input('app_upload_image_mask_img')) && !file_exists(storage_path($request->input('app_upload_image_mask_img')))){
  291. return $this->response()->error('您配置的水印图片不存在!');
  292. }
  293. SiteUtils::forget_config_data();
  294. $tags = [];
  295. if($request->get('uni_tabbar_popup_5_tags')){
  296. $_5_tags = explode(',', $request->get('uni_tabbar_popup_5_tags'));
  297. if($_5_tags){
  298. $tags = WxTag::whereIn('id', $_5_tags)->orderBy(DB::raw('FIND_IN_SET(id, "' . implode(",", $_5_tags) . '"' . ")"))->limit(3)->get(['id', 'tags_name']);
  299. if($tags){
  300. $tags = $tags->map(function ($v){
  301. $v->path = '/pages/creat/index/creat?tag_id='.$v->id.'&tags_name='.$v->tags_name;
  302. return $v;
  303. });
  304. $tags = $tags->toArray();
  305. }
  306. }
  307. }
  308. $popup_obj = [
  309. 'tip' => [
  310. 'login' => $request->input('uni_tabbar_popup_tip_1'),
  311. 'nologin' => $request->input('uni_tabbar_popup_tip_2'),
  312. ],
  313. 'button' => [
  314. 'first' => [
  315. 'text1' => $request->input('uni_tabbar_popup_1_text_1'),
  316. 'text2' => $request->input('uni_tabbar_popup_1_text_2'),
  317. 'path' => $request->input('uni_tabbar_popup_1_path'),
  318. ],
  319. 'second' => [
  320. 'icon' => $request->input('uni_tabbar_popup_2_icon'),
  321. 'text' => $request->input('uni_tabbar_popup_2_text'),
  322. 'path' => $request->input('uni_tabbar_popup_2_path'),
  323. ],
  324. 'third' => [
  325. 'icon' => $request->input('uni_tabbar_popup_3_icon'),
  326. 'text' => $request->input('uni_tabbar_popup_3_text'),
  327. 'path' => $request->input('uni_tabbar_popup_3_path'),
  328. ],
  329. 'fourth' => [
  330. 'icon' => $request->input('uni_tabbar_popup_4_icon'),
  331. 'text' => $request->input('uni_tabbar_popup_4_text'),
  332. 'path' => $request->input('uni_tabbar_popup_4_path'),
  333. ]
  334. ],
  335. 'hot' => [
  336. 'title' => $request->input('uni_tabbar_popup_5_title'),
  337. 'desc' => $request->input('uni_tabbar_popup_5_desc'),
  338. 'list' => $tags
  339. ]
  340. ];
  341. update_site_meta(_multi_key('app_publish_popup_config'), $popup_obj, 'j');
  342. Settings::set('uni_tabbar_popup_tip_1', $request->input('uni_tabbar_popup_tip_1'), true, true);
  343. Settings::set('uni_tabbar_popup_tip_2', $request->input('uni_tabbar_popup_tip_2'), true, true);
  344. Settings::set('uni_tabbar_popup_1_text_1', $request->input('uni_tabbar_popup_1_text_1'), true, true);
  345. Settings::set('uni_tabbar_popup_1_text_2', $request->input('uni_tabbar_popup_1_text_2'), true, true);
  346. Settings::set('uni_tabbar_popup_1_path', $request->input('uni_tabbar_popup_1_path'), true, true);
  347. Settings::set('uni_tabbar_popup_2_icon', $request->input('uni_tabbar_popup_2_icon'), true, true);
  348. Settings::set('uni_tabbar_popup_3_icon', $request->input('uni_tabbar_popup_3_icon'), true, true);
  349. Settings::set('uni_tabbar_popup_4_icon', $request->input('uni_tabbar_popup_4_icon'), true, true);
  350. Settings::set('uni_tabbar_popup_2_text', $request->input('uni_tabbar_popup_2_text'), true, true);
  351. Settings::set('uni_tabbar_popup_3_text', $request->input('uni_tabbar_popup_3_text'), true, true);
  352. Settings::set('uni_tabbar_popup_4_text', $request->input('uni_tabbar_popup_4_text'), true, true);
  353. Settings::set('uni_tabbar_popup_2_path', $request->input('uni_tabbar_popup_2_path'), true, true);
  354. Settings::set('uni_tabbar_popup_3_path', $request->input('uni_tabbar_popup_3_path'), true, true);
  355. Settings::set('uni_tabbar_popup_4_path', $request->input('uni_tabbar_popup_4_path'), true, true);
  356. Settings::set('uni_tabbar_popup_5_title', $request->input('uni_tabbar_popup_5_title'), true, true);
  357. Settings::set('uni_tabbar_popup_5_desc', $request->input('uni_tabbar_popup_5_desc'), true, true);
  358. Settings::set('uni_tabbar_popup_5_tags', AdminUtils::_multipleSelectTable_order_process('selectTable:formPagePublishTrait:uni_tabbar_popup_5_tags', $request->input('uni_tabbar_popup_5_tags')) , true, true);
  359. Settings::set('app_publish_tools_fixed2_left', $request->input('app_publish_tools_fixed2_left'), true, true);
  360. Settings::set('app_publish_tools_fixed2_right', $request->input('app_publish_tools_fixed2_right'), true, true);
  361. Settings::set('app_publish_simple_fixed', trim($request->input('app_publish_simple_fixed'), ','), true, true);
  362. Settings::set('app_publish_simple_popup', trim($request->input('app_publish_simple_popup'), ','), true, true);
  363. Settings::set('app_publish_imagetext_switch', trim($request->input('app_publish_imagetext_switch'), ','), true, true);
  364. Settings::set('app_publish_imagetext_fixed', trim($request->input('app_publish_imagetext_fixed'), ','), true, true);
  365. Settings::set('app_publish_imagetext_popup', trim($request->input('app_publish_imagetext_popup'), ','), true, true);
  366. Settings::set('app_upload_max_files', $request->input('app_upload_max_files'), true, true);
  367. Settings::set('app_upload_max_size_files', $request->input('app_upload_max_size_files'), true, true);
  368. Settings::set('app_upload_max_sounds', $request->input('app_upload_max_sounds'), true, true);
  369. // Settings::set('app_upload_max_imgs', $request->input('app_upload_max_imgs'), true);
  370. Settings::set('app_vote_max_options', _between_($request->input('app_vote_max_options'), 2, 20), true, true);
  371. Settings::set('app_publish_edit_need_coin', $request->input('app_publish_edit_need_coin'), true, true);
  372. Settings::set('video_snapshot_time', $request->input('video_snapshot_time'), true, true);
  373. Settings::set('app_upload_video_compress', $request->input('app_upload_video_compress'), true, true);
  374. Settings::set('app_upload_image_max_width', $request->input('app_upload_image_max_width'), true, true);
  375. Settings::set('app_upload_image_slimming', _between_($request->input('app_upload_image_slimming'), 0, 100), true, true);
  376. // 水印
  377. Settings::set('app_upload_image_mask_type', $request->input('app_upload_image_mask_type'), true, true);
  378. Settings::set('app_upload_image_mask_opacity', $request->input('app_upload_image_mask_opacity'), true, true);
  379. Settings::set('app_upload_image_mask_rate', $request->input('app_upload_image_mask_rate'), true, true);
  380. Settings::set('app_upload_image_mask_img', $request->input('app_upload_image_mask_img'), true, true);
  381. Settings::set('app_upload_image_mask_pos', $request->input('app_upload_image_mask_pos'), true, true);
  382. Settings::set('app_publish_times_max', $request->input('app_publish_times_max'), true, true);
  383. Settings::set('app_publish_frequency_min', $request->input('app_publish_frequency_min'), true, true);
  384. Settings::set('app_pay_max_coins', $request->input('app_pay_max_coins'), true, true);
  385. Settings::set('app_pay_max_balance', $request->input('app_pay_max_balance'), true, true);
  386. Settings::set('app_publish_permissions', $request->input('app_publish_permissions'), true, true);
  387. Settings::set('app_publish_placeholder_text', $request->input('app_publish_placeholder_text'), true, true);
  388. if($__MINI_GLOBAL_TENANT_ID__ === 0){
  389. Settings::set('app_publish_success_popup', $request->input('app_publish_success_popup', 0) == 1 ? 1 : 0);
  390. }
  391. Settings::set('app_publish_circle_required', $request->input('app_publish_circle_required'), true, true);
  392. Settings::set('app_publish_media_required', $request->input('app_publish_media_required'), true, true);
  393. Settings::set('app_publish_force_bind_phone', $request->input('app_publish_force_bind_phone'), true, true);
  394. Settings::set('app_publish_force_real_name', $request->input('app_publish_force_real_name'), true, true);
  395. Settings::set('app_publish_force_subscribe_mp', $request->input('app_publish_force_subscribe_mp'), true, true);
  396. Settings::set('app_publish_force_university', $request->input('app_publish_force_university'), true, true);
  397. $force_university = $request->input('app_publish_force_university');
  398. if(_empty_(end($force_university))){
  399. array_pop($force_university);
  400. }
  401. if(!_empty_($force_university)){
  402. $str = '';
  403. foreach ($force_university as $sid){
  404. if(!_empty_($str)){
  405. $str .= '、';
  406. }
  407. $str .= WxUniversity::where('sid', $sid)->value('name');
  408. }
  409. Settings::set('app_publish_force_university_tip', $str, true, true);
  410. }
  411. Settings::set('app_page_create_tags', AdminUtils::_multipleSelectTable_order_process('selectTable:formPagePublishTrait:app_page_create_tags', $request->input('app_page_create_tags')) , true, true);
  412. Settings::set('app_publish2_bg_img', $request->input('app_publish2_bg_img'), true, true);
  413. Settings::set('app_publish2_square_list', AdminUtils::_multipleSelectTable_order_process('selectTable:formPagePublishTrait:app_publish2_square_list', $request->input('app_publish2_square_list')) , true, true);
  414. Settings::set('app_publish2_post_show', AdminUtils::_multipleSelectTable_order_process('selectTable:formPagePublishTrait:app_publish2_post_show', $request->input('app_publish2_post_show')) , true, true);
  415. $app_publish_post_sph_user = AdminUtils::_multipleSelectTable_order_process('selectTable:formPagePublishTrait:app_publish_post_sph_user', $request->input('app_publish_post_sph_user'));
  416. Settings::set('app_publish_post_sph_user', $app_publish_post_sph_user, true, true);
  417. if(is_array($app_publish_post_sph_user)){
  418. $app_publish_post_sph_user = implode(',', $app_publish_post_sph_user);
  419. }
  420. _update_env([
  421. _multi_key('APP_PUBLISH_POST_SPH_USER') => $app_publish_post_sph_user,
  422. ], [], 1);
  423. $__global_config_version__ = Settings::get('__global_config_version__', 1) + 1;
  424. Settings::set('__global_config_version__', $__global_config_version__);
  425. GatewayUtils::success('all', 13, [ 'version' => $__global_config_version__, 'file' => basename(__FILE__) ]);
  426. return $this->response()->success('成功!');
  427. }
  428. }