From a56a8918835b40bbb34ea1f86aee85efcd49e8f0 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Mon, 14 Apr 2025 19:14:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3workerman=E4=B8=ADonMessage?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=B0=83=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Views/chapter/live/chats.volt | 22 +++-- app/Http/Home/Views/chapter/live/forbid.volt | 4 +- .../Home/Views/chapter/live/inactive.volt | 8 +- app/Http/Home/Views/chapter/live/sticky.volt | 4 +- app/Library/Paginator/Adapter/NativeArray.php | 51 +++++++++++ app/Services/Logic/Search/Article.php | 2 +- app/Services/Logic/Search/Course.php | 2 +- app/Services/Logic/Search/Question.php | 2 +- public/static/home/css/common.css | 86 ++++++------------- public/static/home/js/chapter.live.chat.js | 34 ++++++-- websocket/start.php | 13 ++- 11 files changed, 134 insertions(+), 94 deletions(-) create mode 100644 app/Library/Paginator/Adapter/NativeArray.php diff --git a/app/Http/Home/Views/chapter/live/chats.volt b/app/Http/Home/Views/chapter/live/chats.volt index 850ac2f9..a52618f1 100644 --- a/app/Http/Home/Views/chapter/live/chats.volt +++ b/app/Http/Home/Views/chapter/live/chats.volt @@ -1,9 +1,15 @@ {% for chat in chats %} -
- {% if chat.user.vip == 1 %} - - {% endif %} - {{ chat.user.name }} - {{ chat.content }} -
-{% endfor %} \ No newline at end of file + {% if chat.user.vip == 1 %} +
+ + {{ chat.user.name }} + {{ chat.content }} +
+ {% else %} +
+ + {{ chat.user.name }} + {{ chat.content }} +
+ {% endif %} +{% endfor %} diff --git a/app/Http/Home/Views/chapter/live/forbid.volt b/app/Http/Home/Views/chapter/live/forbid.volt index e41255aa..bcd94d80 100644 --- a/app/Http/Home/Views/chapter/live/forbid.volt +++ b/app/Http/Home/Views/chapter/live/forbid.volt @@ -11,9 +11,9 @@ -
+
直播已禁止,谢谢关注!
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/Http/Home/Views/chapter/live/inactive.volt b/app/Http/Home/Views/chapter/live/inactive.volt index 5efcda9b..213e08eb 100644 --- a/app/Http/Home/Views/chapter/live/inactive.volt +++ b/app/Http/Home/Views/chapter/live/inactive.volt @@ -13,19 +13,19 @@
{% if time() < chapter.start_time %} -
+
直播倒计时开始啦,敬请关注!
{% elseif chapter.start_time < time() and chapter.end_time > time() %} -
+
直播时间到了,老师去哪了?
{% else %} -
+
直播已结束,谢谢关注!
@@ -43,4 +43,4 @@ {{ js_include('home/js/chapter.live.countdown.js') }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/Http/Home/Views/chapter/live/sticky.volt b/app/Http/Home/Views/chapter/live/sticky.volt index f4365469..cf3c2c94 100644 --- a/app/Http/Home/Views/chapter/live/sticky.volt +++ b/app/Http/Home/Views/chapter/live/sticky.volt @@ -7,7 +7,7 @@
-
{{ chapter.like_count }}
+
{{ chapter.like_count }}
@@ -15,4 +15,4 @@
0
-
\ No newline at end of file +
diff --git a/app/Library/Paginator/Adapter/NativeArray.php b/app/Library/Paginator/Adapter/NativeArray.php new file mode 100644 index 00000000..c54e19ce --- /dev/null +++ b/app/Library/Paginator/Adapter/NativeArray.php @@ -0,0 +1,51 @@ +baseUrl = $query->getBaseUrl(); + $this->params = $query->getParams(); + + $pager->first = $this->buildPageUrl($pager->first); + $pager->previous = $this->buildPageUrl($pager->previous); + $pager->next = $this->buildPageUrl($pager->next); + $pager->last = $this->buildPageUrl($pager->last); + + return $pager; + } + + protected function buildPageUrl($page) + { + $this->params['page'] = $page; + + return $this->baseUrl . '?' . http_build_query($this->params); + } + +} diff --git a/app/Services/Logic/Search/Article.php b/app/Services/Logic/Search/Article.php index 57857c45..6b95aa70 100644 --- a/app/Services/Logic/Search/Article.php +++ b/app/Services/Logic/Search/Article.php @@ -33,7 +33,7 @@ class Article extends Handler 'limit' => $limit, ]); - $pager = $paginator->getPaginate(); + $pager = $paginator->paginate(); return $this->handleArticles($pager); } diff --git a/app/Services/Logic/Search/Course.php b/app/Services/Logic/Search/Course.php index 77b92702..c94b5fd9 100644 --- a/app/Services/Logic/Search/Course.php +++ b/app/Services/Logic/Search/Course.php @@ -33,7 +33,7 @@ class Course extends Handler 'limit' => $limit, ]); - $pager = $paginator->getPaginate(); + $pager = $paginator->paginate(); return $this->handleCourses($pager); } diff --git a/app/Services/Logic/Search/Question.php b/app/Services/Logic/Search/Question.php index c035178f..f1d0e73b 100644 --- a/app/Services/Logic/Search/Question.php +++ b/app/Services/Logic/Search/Question.php @@ -33,7 +33,7 @@ class Question extends Handler 'limit' => $limit, ]); - $pager = $paginator->getPaginate(); + $pager = $paginator->paginate(); return $this->handleQuestions($pager); } diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index a0ef5b71..27710fdd 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -112,6 +112,16 @@ margin-bottom: 20px; } +.breadcrumb .share { + position: absolute; + top: 2px; + right: -5px; +} + +.breadcrumb .share a { + margin-right: 5px; +} + .wrap { padding: 20px; margin-bottom: 20px; @@ -144,10 +154,6 @@ text-align: center; } -.layer .pager { - margin-top: 0; -} - .loading { padding: 30px; text-align: center; @@ -198,12 +204,6 @@ min-height: 80px; } -.breadcrumb .share { - position: absolute; - top: 2px; - right: -5px; -} - #header { left: 0; top: 0; @@ -313,10 +313,6 @@ line-height: 30px; } -.cs-sidebar p { - line-height: 40px; -} - .index-wrap { padding-bottom: 15px; } @@ -1359,44 +1355,21 @@ background-color: #f2f2f2; } -.share .layui-icon { - margin-right: 5px; - cursor: pointer; -} - -.share .active, -.share .layui-icon-star-fill { - color: orange; -} - -.share a { - margin-right: 5px; -} - -.share i { - margin-right: 5px; -} - -.share em { - font-style: normal; - color: #666; -} - -.preview { +.live-preview { color: #666; margin-top: 30px; text-align: center; } -.preview .icon { +.live-preview .icon { margin-bottom: 10px; } -.preview .icon .layui-icon { +.live-preview .icon .layui-icon { font-size: 150px; } -.preview .tips { +.live-preview .tips { font-size: 16px; margin: 20px 0; } @@ -1424,7 +1397,6 @@ height: 428px; } - .play-mask { top: 50%; left: 50%; @@ -1458,37 +1430,33 @@ overflow-y: auto; } -.chat-msg-list .chat, .chat-msg-list .chat-sys { +.chat { margin-bottom: 10px; - line-height: 25px; + line-height: 1.5em; word-break: break-all; -} - -.chat-sys { + font-size: 12px; color: #999; } -.chat-sys span, .chat span { +.chat-sys { + padding: 5px; + background-color: black; + color: white; +} + +.chat span { margin-right: 5px; } -.chat .user { - color: orange; -} - -.chat .icon-vip { - color: orange; -} - -.chat .content { - color: #666; +.chat .icon .layui-icon { + font-size: 14px; } .chat-msg-form .layui-input { height: 32px; line-height: 32px; font-size: 12px; - color: #666; + color: #999; } .vip-header { diff --git a/public/static/home/js/chapter.live.chat.js b/public/static/home/js/chapter.live.chat.js index 77eb4522..ea3e49c8 100644 --- a/public/static/home/js/chapter.live.chat.js +++ b/public/static/home/js/chapter.live.chat.js @@ -67,19 +67,19 @@ layui.use(['jquery', 'form', 'helper'], function () { } function showNewMessage(res) { - var html = '
'; + var html = ''; if (res.user.vip === 1) { - html += ''; + html = getVipUserMessage(res); + } else { + html = getNormalUserMessage(res); } - html += '' + res.user.name + ':'; - html += '' + res.content + ''; - html += '
'; $chatMsgList.append(html); scrollToBottom(); } function showLoginMessage(res) { var html = '
'; + html += ''; html += '' + res.user.name + ''; html += '进入了直播间'; html += '
'; @@ -87,11 +87,27 @@ layui.use(['jquery', 'form', 'helper'], function () { scrollToBottom(); } + function getVipUserMessage(res) { + var html = '
'; + html += ''; + html += '' + res.user.name + ''; + html += '' + res.content + ''; + html += '
'; + return html; + } + + function getNormalUserMessage(res) { + var html = '
'; + html += ''; + html += '' + res.user.name + ''; + html += '' + res.content + ''; + html += '
'; + return html; + } + function scrollToBottom() { var $scrollTo = $chatMsgList.find('.chat:last'); - $chatMsgList.scrollTop( - $scrollTo.offset().top - $chatMsgList.offset().top + $chatMsgList.scrollTop() - ); + $chatMsgList.scrollTop($scrollTo.offset().top - $chatMsgList.offset().top + $chatMsgList.scrollTop()); } function refreshLiveStats() { @@ -105,4 +121,4 @@ layui.use(['jquery', 'form', 'helper'], function () { helper.ajaxLoadHtml($chatMsgList.data('url'), $chatMsgList.attr('id')); } -}); \ No newline at end of file +}); diff --git a/websocket/start.php b/websocket/start.php index 0be3596f..6cb65b1f 100644 --- a/websocket/start.php +++ b/websocket/start.php @@ -9,25 +9,24 @@ ini_set('display_errors', 'on'); use Workerman\Worker; -if(strpos(strtolower(PHP_OS), 'win') === 0) -{ +if (strpos(strtolower(PHP_OS), 'win') === 0) { exit("start.php not support windows, please use start_for_win.bat\n"); } -if(!extension_loaded('pcntl')) -{ +if (!extension_loaded('pcntl')) { exit("Please install pcntl extension. See http://doc3.workerman.net/appendices/install-extension.html\n"); } -if(!extension_loaded('posix')) -{ +if (!extension_loaded('posix')) { exit("Please install posix extension. See http://doc3.workerman.net/appendices/install-extension.html\n"); } -define('GLOBAL_START', 1); +const GLOBAL_START = 1; require_once dirname(__DIR__) . '/vendor/autoload.php'; +require_once __DIR__ . '/Events.php'; + require_once __DIR__ . '/start_business_worker.php'; require_once __DIR__ . '/start_gateway.php';