diff --git a/CHANGELOG.md b/CHANGELOG.md index 2046d530..9d97dff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +### [v1.6.2](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.1)(2023-01-12) + +- 增加ServerMonitor监控指标配置 +- 同步更新腾讯云短信内容规则 +- 文章和问答增加评论开关属性 +- 修正视频记忆播放无效问题 +- 升级composer包版本 +- 优化Repo查询默认排序 +- 优化管理后台细节 +- 优化二维码输出 +- 优化评分检查 + +### [v1.6.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.1)(2022-12-12) + +- 富文本编辑器增加粘贴图片和远程图片本地化 +- 修正用户通知标记为已读,计数不归零问题 +- 修正播放器中央按钮显示问题 +- 优化腾讯云播放地址鉴权参数 +- 优化热门作者,答主和问题 +- 优化学员学习记录显示 +- 优化表单数据提交体验 +- 优化单章节层级显示 +- 优化ServerInfo类 + ### [v1.6.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.0)(2022-10-26) - 播放器中间增加大号播放按钮 diff --git a/app/Console/Tasks/DeliverTask.php b/app/Console/Tasks/DeliverTask.php index 41608ae9..1e34d458 100644 --- a/app/Console/Tasks/DeliverTask.php +++ b/app/Console/Tasks/DeliverTask.php @@ -60,7 +60,6 @@ class DeliverTask extends Task break; default: $this->noMatchedHandler($order); - break; } $order->status = OrderModel::STATUS_FINISHED; diff --git a/app/Console/Tasks/ServerMonitorTask.php b/app/Console/Tasks/ServerMonitorTask.php index 897d5999..8f054931 100644 --- a/app/Console/Tasks/ServerMonitorTask.php +++ b/app/Console/Tasks/ServerMonitorTask.php @@ -10,7 +10,7 @@ namespace App\Console\Tasks; use App\Library\Benchmark; use App\Models\User as UserModel; use App\Services\Logic\Notice\External\DingTalk\ServerMonitor as ServerMonitorNotice; -use App\Services\Search\UserSearcher; +use App\Services\Search\CourseSearcher; use GatewayClient\Gateway; class ServerMonitorTask extends Task @@ -53,9 +53,13 @@ class ServerMonitorTask extends Task $load = sys_getloadavg(); - if ($load[1] > $cpuCount * 0.8) { + $limit = $this->getConfig()->path('server_monitor.cpu', 0.8); + + if ($load[1] > $cpuCount * $limit) { return sprintf("cpu负载超过%s", $load[1]); } + + return null; } protected function checkMemory() @@ -64,25 +68,29 @@ class ServerMonitorTask extends Task $total = null; - if (preg_match('/MemTotal\:\s+(\d+) kB/', $memInfo, $totalMatches)) { + if (preg_match('/MemTotal:\s+(\d+) kB/', $memInfo, $totalMatches)) { $total = $totalMatches[1]; } - if ($total === null) return; + if ($total === null) return null; $available = null; - if (preg_match('/MemAvailable\:\s+(\d+) kB/', $memInfo, $avaMatches)) { + if (preg_match('/MemAvailable:\s+(\d+) kB/', $memInfo, $avaMatches)) { $available = $avaMatches[1]; } - if ($available === null) return; + if ($available === null) return null; $left = 100 * ($available / $total); - if ($left < 20) { + $limit = $this->getConfig()->path('server_monitor.memory', 10); + + if ($left < $limit) { return sprintf("memory剩余不足%s%%", round($left)); } + + return null; } protected function checkDisk() @@ -92,9 +100,13 @@ class ServerMonitorTask extends Task $left = 100 * $free / $total; - if ($left < 20) { + $limit = $this->getConfig()->path('server_monitor.disk', 20); + + if ($left < $limit) { return sprintf("disk剩余不足%s%%", round($left)); } + + return null; } protected function checkMysql() @@ -111,8 +123,8 @@ class ServerMonitorTask extends Task $elapsedTime = $benchmark->getElapsedTime(); - if ($user === false) { - return sprintf("mysql查询失败"); + if (!$user) { + return "mysql查询失败"; } if ($elapsedTime > 1) { @@ -120,8 +132,10 @@ class ServerMonitorTask extends Task } } catch (\Exception $e) { - return sprintf("mysql可能存在异常"); + return "mysql可能存在异常"; } + + return null; } protected function checkRedis() @@ -139,7 +153,7 @@ class ServerMonitorTask extends Task $elapsedTime = $benchmark->getElapsedTime(); if (empty($site)) { - return sprintf("redis查询失败"); + return "redis查询失败"; } if ($elapsedTime > 1) { @@ -147,8 +161,10 @@ class ServerMonitorTask extends Task } } catch (\Exception $e) { - return sprintf("redis可能存在异常"); + return "redis可能存在异常"; } + + return null; } protected function checkXunsearch() @@ -159,16 +175,16 @@ class ServerMonitorTask extends Task $benchmark->start(); - $searcher = new UserSearcher(); + $searcher = new CourseSearcher(); - $user = $searcher->search('id:10000'); + $user = $searcher->search('id:1'); $benchmark->stop(); $elapsedTime = $benchmark->getElapsedTime(); if (empty($user)) { - return sprintf("xunsearch搜索失败"); + return "xunsearch搜索失败"; } if ($elapsedTime > 1) { @@ -176,8 +192,10 @@ class ServerMonitorTask extends Task } } catch (\Exception $e) { - return sprintf("xunsearch可能存在异常"); + return "xunsearch可能存在异常"; } + + return null; } protected function checkWebsocket() @@ -203,8 +221,10 @@ class ServerMonitorTask extends Task } } catch (\Exception $e) { - return sprintf("websocket可能存在异常"); + return "websocket可能存在异常"; } + + return null; } protected function getCpuCount() diff --git a/app/Console/Tasks/SyncLearningTask.php b/app/Console/Tasks/SyncLearningTask.php index a1b9dbe0..c8a86463 100644 --- a/app/Console/Tasks/SyncLearningTask.php +++ b/app/Console/Tasks/SyncLearningTask.php @@ -48,10 +48,12 @@ class SyncLearningTask extends Task */ protected function handleLearning($itemKey) { + $cache = $this->getCache(); + /** * @var LearningModel $cacheLearning */ - $cacheLearning = $this->cache->get($itemKey); + $cacheLearning = $cache->get($itemKey); if (!$cacheLearning) return; @@ -76,7 +78,7 @@ class SyncLearningTask extends Task $this->updateChapterUser($dbLearning); } - $this->cache->delete($itemKey); + $cache->delete($itemKey); } /** @@ -111,7 +113,12 @@ class SyncLearningTask extends Task $progress = floor(100 * $chapterUser->duration / $duration); - $chapterUser->position = floor($learning->position); + /** + * 过于接近结束位置当作已结束处理,播放位置为起点0 + */ + $playPosition = $duration - $learning->position > 10 ? floor($learning->position) : 0; + + $chapterUser->position = $playPosition; $chapterUser->progress = $progress < 100 ? $progress : 100; $chapterUser->consumed = $chapterUser->duration > 0.3 * $duration ? 1 : 0; diff --git a/app/Http/Admin/Services/Article.php b/app/Http/Admin/Services/Article.php index 6a9931f2..368dc2cb 100644 --- a/app/Http/Admin/Services/Article.php +++ b/app/Http/Admin/Services/Article.php @@ -9,7 +9,6 @@ namespace App\Http\Admin\Services; use App\Builders\ArticleList as ArticleListBuilder; use App\Builders\ReportList as ReportListBuilder; -use App\Caches\Article as ArticleCache; use App\Library\Paginator\Query as PagerQuery; use App\Library\Utils\Word as WordUtil; use App\Models\Article as ArticleModel; @@ -27,7 +26,6 @@ use App\Services\Logic\Article\XmTagList as XmTagListService; use App\Services\Logic\Notice\Internal\ArticleApproved as ArticleApprovedNotice; use App\Services\Logic\Notice\Internal\ArticleRejected as ArticleRejectedNotice; use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory; -use App\Services\Sync\ArticleIndex as ArticleIndexSync; use App\Validators\Article as ArticleValidator; class Article extends Service @@ -209,8 +207,6 @@ class Article extends Service $this->saveDynamicAttrs($article); - $this->rebuildArticleIndex($article); - $owner = $this->findUser($article->owner_id); $this->recountUserArticles($owner); @@ -230,8 +226,6 @@ class Article extends Service $this->saveDynamicAttrs($article); - $this->rebuildArticleIndex($article); - $owner = $this->findUser($article->owner_id); $this->recountUserArticles($owner); @@ -251,8 +245,6 @@ class Article extends Service $this->saveDynamicAttrs($article); - $this->rebuildArticleIndex($article); - $owner = $this->findUser($article->owner_id); $this->recountUserArticles($owner); @@ -292,7 +284,6 @@ class Article extends Service if ($type == 'approve') { - $this->rebuildArticleIndex($article); $this->handleArticlePostPoint($article); $this->handleArticleApprovedNotice($article, $sender); @@ -403,20 +394,6 @@ class Article extends Service $user->update(); } - protected function rebuildArticleCache(ArticleModel $article) - { - $cache = new ArticleCache(); - - $cache->rebuild($article->id); - } - - protected function rebuildArticleIndex(ArticleModel $article) - { - $sync = new ArticleIndexSync(); - - $sync->addItem($article->id); - } - protected function handleArticlePostPoint(ArticleModel $article) { if ($article->published != ArticleModel::PUBLISH_APPROVED) return; diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index cdd951f9..e3f20997 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -8,7 +8,6 @@ namespace App\Http\Admin\Services; use App\Builders\CourseList as CourseListBuilder; -use App\Caches\Course as CourseCache; use App\Caches\CourseCategoryList as CourseCategoryListCache; use App\Caches\CourseRelatedList as CourseRelatedListCache; use App\Caches\CourseTeacherList as CourseTeacherListCache; @@ -25,7 +24,6 @@ use App\Repos\CourseCategory as CourseCategoryRepo; use App\Repos\CourseRelated as CourseRelatedRepo; use App\Repos\CourseUser as CourseUserRepo; use App\Repos\User as UserRepo; -use App\Services\Sync\CourseIndex as CourseIndexSync; use App\Validators\Course as CourseValidator; use App\Validators\CourseOffline as CourseOfflineValidator; @@ -399,20 +397,6 @@ class Course extends Service return $validator->checkCourse($id); } - protected function rebuildCourseCache(CourseModel $course) - { - $cache = new CourseCache(); - - $cache->rebuild($course->id); - } - - protected function rebuildCourseIndex(CourseModel $course) - { - $sync = new CourseIndexSync(); - - $sync->addItem($course->id); - } - protected function saveTeachers(CourseModel $course, $teacherIds) { $courseRepo = new CourseRepo(); diff --git a/app/Http/Admin/Services/Package.php b/app/Http/Admin/Services/Package.php index c49ee55f..4cc1d666 100644 --- a/app/Http/Admin/Services/Package.php +++ b/app/Http/Admin/Services/Package.php @@ -101,7 +101,6 @@ class Package extends Service $data = []; $data['title'] = $validator->checkTitle($post['title']); - $data['summary'] = $validator->checkSummary($post['summary']); $package = new PackageModel(); diff --git a/app/Http/Admin/Services/Page.php b/app/Http/Admin/Services/Page.php index 022afa64..3ed047c3 100644 --- a/app/Http/Admin/Services/Page.php +++ b/app/Http/Admin/Services/Page.php @@ -7,7 +7,6 @@ namespace App\Http\Admin\Services; -use App\Caches\Page as PageCache; use App\Library\Paginator\Query as PagerQuery; use App\Models\Page as PageModel; use App\Repos\Page as PageRepo; @@ -53,8 +52,6 @@ class Page extends Service $page->create($data); - $this->rebuildPageCache($page); - return $page; } @@ -96,8 +93,6 @@ class Page extends Service $page->update($data); - $this->rebuildPageCache($page); - return $page; } @@ -109,8 +104,6 @@ class Page extends Service $page->update(); - $this->rebuildPageCache($page); - return $page; } @@ -122,18 +115,9 @@ class Page extends Service $page->update(); - $this->rebuildPageCache($page); - return $page; } - protected function rebuildPageCache(PageModel $page) - { - $cache = new PageCache(); - - $cache->rebuild($page->id); - } - protected function findOrFail($id) { $validator = new PageValidator(); diff --git a/app/Http/Admin/Services/Question.php b/app/Http/Admin/Services/Question.php index 52b548b7..44a456ef 100644 --- a/app/Http/Admin/Services/Question.php +++ b/app/Http/Admin/Services/Question.php @@ -9,7 +9,6 @@ namespace App\Http\Admin\Services; use App\Builders\QuestionList as QuestionListBuilder; use App\Builders\ReportList as ReportListBuilder; -use App\Caches\Question as QuestionCache; use App\Library\Paginator\Query as PagerQuery; use App\Models\Category as CategoryModel; use App\Models\Question as QuestionModel; @@ -26,7 +25,6 @@ use App\Services\Logic\Point\History\QuestionPost as QuestionPostPointHistory; use App\Services\Logic\Question\QuestionDataTrait; use App\Services\Logic\Question\QuestionInfo as QuestionInfoService; use App\Services\Logic\Question\XmTagList as XmTagListService; -use App\Services\Sync\QuestionIndex as QuestionIndexSync; use App\Validators\Question as QuestionValidator; class Question extends Service @@ -191,8 +189,6 @@ class Question extends Service $this->saveDynamicAttrs($question); - $this->rebuildQuestionIndex($question); - $owner = $this->findUser($question->owner_id); $this->recountUserQuestions($owner); @@ -212,8 +208,6 @@ class Question extends Service $this->saveDynamicAttrs($question); - $this->rebuildQuestionIndex($question); - $owner = $this->findUser($question->owner_id); $this->recountUserQuestions($owner); @@ -231,8 +225,6 @@ class Question extends Service $question->update(); - $this->rebuildQuestionIndex($question); - $owner = $this->findUser($question->owner_id); $this->recountUserQuestions($owner); @@ -268,7 +260,6 @@ class Question extends Service if ($type == 'approve') { - $this->rebuildQuestionIndex($question); $this->handleQuestionPostPoint($question); $this->handleQuestionApprovedNotice($question, $sender); @@ -379,20 +370,6 @@ class Question extends Service $user->update(); } - protected function rebuildQuestionCache(QuestionModel $question) - { - $cache = new QuestionCache(); - - $cache->rebuild($question->id); - } - - protected function rebuildQuestionIndex(QuestionModel $question) - { - $sync = new QuestionIndexSync(); - - $sync->addItem($question->id); - } - protected function handleQuestionPostPoint(QuestionModel $question) { if ($question->published != QuestionModel::PUBLISH_APPROVED) return; diff --git a/app/Http/Admin/Services/Topic.php b/app/Http/Admin/Services/Topic.php index 55c2b581..23195a4b 100644 --- a/app/Http/Admin/Services/Topic.php +++ b/app/Http/Admin/Services/Topic.php @@ -87,7 +87,6 @@ class Topic extends Service $data = []; $data['title'] = $validator->checkTitle($post['title']); - $data['summary'] = $validator->checkSummary($post['summary']); $topic = new TopicModel(); diff --git a/app/Http/Admin/Views/package/add.volt b/app/Http/Admin/Views/package/add.volt index d8d8cc16..7a0a4163 100644 --- a/app/Http/Admin/Views/package/add.volt +++ b/app/Http/Admin/Views/package/add.volt @@ -12,12 +12,6 @@ -
- -
- -
-
diff --git a/app/Http/Admin/Views/setting/sms.volt b/app/Http/Admin/Views/setting/sms.volt index 547d9626..f2d8b7a4 100644 --- a/app/Http/Admin/Views/setting/sms.volt +++ b/app/Http/Admin/Views/setting/sms.volt @@ -64,7 +64,7 @@ - + 复制 @@ -84,7 +84,7 @@ - + 复制 diff --git a/app/Http/Admin/Views/student/learning.volt b/app/Http/Admin/Views/student/learning.volt index 620b6a27..314ef2c2 100644 --- a/app/Http/Admin/Views/student/learning.volt +++ b/app/Http/Admin/Views/student/learning.volt @@ -32,6 +32,8 @@ {% for item in pager.items %} + {% set duration = item.duration > 0 ? item.duration|duration : 'N/A' %} + {% set active_time = item.active_time > 0 ? date('Y-m-d H:i:s',item.active_time) : 'N/A' %}

课程:{{ item.course.title }}

@@ -41,8 +43,8 @@

类型:{{ client_type_info(item.client_type) }}

地址:{{ item.client_ip }}

- {{ item.duration|duration }} - {{ date('Y-m-d H:i:s',item.active_time) }} + {{ duration }} + {{ active_time }} {% endfor %} diff --git a/app/Http/Admin/Views/topic/add.volt b/app/Http/Admin/Views/topic/add.volt index e470d1cb..573ba53a 100644 --- a/app/Http/Admin/Views/topic/add.volt +++ b/app/Http/Admin/Views/topic/add.volt @@ -12,12 +12,6 @@
-
- -
- -
-
diff --git a/app/Http/Admin/Views/trade/refund.volt b/app/Http/Admin/Views/trade/refund.volt index d5c54c7b..0af6fdae 100644 --- a/app/Http/Admin/Views/trade/refund.volt +++ b/app/Http/Admin/Views/trade/refund.volt @@ -71,11 +71,15 @@
-
- - - - +
+ +
+ + + + + +
diff --git a/app/Http/Home/Controllers/PublicController.php b/app/Http/Home/Controllers/PublicController.php index 9e3b3876..a79a0dc2 100644 --- a/app/Http/Home/Controllers/PublicController.php +++ b/app/Http/Home/Controllers/PublicController.php @@ -73,18 +73,19 @@ class PublicController extends \Phalcon\Mvc\Controller { $text = $this->request->getQuery('text', 'string'); $size = $this->request->getQuery('size', 'int', 320); + $margin = $this->request->getQuery('margin', 'int', 10); $text = urldecode($text); $qrCode = new QrCode($text); $qrCode->setSize($size); + $qrCode->setMargin($margin); - $qrCode->getContentType(); + $this->response->setContentType('image/png'); + $this->response->setContent($qrCode->writeString()); - echo $qrCode->writeString(); - - exit; + return $this->response; } /** diff --git a/app/Http/Home/Views/article/list.volt b/app/Http/Home/Views/article/list.volt index aced081e..11fe75e8 100644 --- a/app/Http/Home/Views/article/list.volt +++ b/app/Http/Home/Views/article/list.volt @@ -4,7 +4,7 @@ {% set sort_val = request.get('sort','trim','latest') %} {% set pager_url = url({'for':'home.article.pager'}, params) %} - {% set top_authors_url = url({'for':'home.widget.top_authors'}) %} + {% set top_authors_url = url({'for':'home.widget.top_authors'},{'limit':5}) %} {% set my_tags_url = url({'for':'home.widget.my_tags'},{'type':'article'}) %}