控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Weburlpush.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 聚合推送插件
  13. // +----------------------------------------------------------------------
  14. namespace addons\weburlpush;
  15. use addons\weburlpush\library\Push;
  16. use app\common\library\Menu;
  17. use think\Addons;
  18. class Weburlpush extends Addons
  19. {
  20. /**
  21. * 插件安装方法
  22. * @return bool
  23. */
  24. public function install()
  25. {
  26. $menu = [
  27. [
  28. "name" => "weburlpush",
  29. "title" => "百度推送",
  30. "sublist" => [
  31. ["name" => "weburlpush/index", "title" => "查看"],
  32. ["name" => "weburlpush/baidu", "title" => "百度推送"],
  33. ["name" => "weburlpush/shenma", "title" => "神马推送"],
  34. ],
  35. ],
  36. ];
  37. Menu::create($menu);
  38. return true;
  39. }
  40. /**
  41. * 插件卸载方法
  42. * @return bool
  43. */
  44. public function uninstall()
  45. {
  46. Menu::delete("weburlpush");
  47. return true;
  48. }
  49. /**
  50. * 插件启用方法
  51. * @return bool
  52. */
  53. public function enable()
  54. {
  55. Menu::enable("weburlpush");
  56. return true;
  57. }
  58. /**
  59. * 插件禁用方法
  60. * @return bool
  61. */
  62. public function disable()
  63. {
  64. Menu::disable("weburlpush");
  65. return true;
  66. }
  67. public function weburlpush(Push $push, $params, $extra = null)
  68. {
  69. $config = $this->getAddonConfig();
  70. $urls = is_string($params) ? [$params] : $params;
  71. $extra = $extra ? $extra : 'push';
  72. $status = explode(',', $config['status']);
  73. try {
  74. foreach ($status as $index => $item) {
  75. if ($extra == 'push') {
  76. $push->channel($item)->push($urls);
  77. }
  78. }
  79. } catch (\Exception $e) {
  80. //$this->error("推送失败:" . $e->getMessage());
  81. }
  82. }
  83. }