1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 05:11:39 +08:00

Merge branch 'koogua/v1.6.2' into demo

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
koogua 2023-02-15 20:36:27 +08:00
commit 7aa622ac71
48 changed files with 210 additions and 60 deletions

View File

@ -1,3 +1,15 @@
### [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)
- 富文本编辑器增加粘贴图片和远程图片本地化

View File

@ -53,7 +53,9 @@ 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]);
}
@ -82,7 +84,9 @@ class ServerMonitorTask extends Task
$left = 100 * ($available / $total);
if ($left < 20) {
$limit = $this->getConfig()->path('server_monitor.memory', 10);
if ($left < $limit) {
return sprintf("memory剩余不足%s%%", round($left));
}
@ -96,7 +100,9 @@ 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));
}

View File

@ -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;

View File

@ -87,7 +87,6 @@ class Topic extends Service
$data = [];
$data['title'] = $validator->checkTitle($post['title']);
$data['summary'] = $validator->checkSummary($post['summary']);
$topic = new TopicModel();

View File

@ -64,7 +64,7 @@
<input type="radio" name="template[order_finish][enabled]" value="0" title="否" {% if template.order_finish.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[order_finish][id]" value="{{ template.order_finish.id }}" lay-verify="required"></td>
<td><input id="tc-order-finish" class="layui-input" type="text" value="下单成功,商品名称:{1},订单序号:{2},订单金额:{3}" readonly="readonly"></td>
<td><input id="tc-order-finish" class="layui-input" type="text" value="下单成功,商品名称:{1},订单序号:{2},订单金额:{3}" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-order-finish">复制</span></td>
</tr>
<tr>
@ -84,7 +84,7 @@
<input type="radio" name="template[refund_finish][enabled]" value="0" title="否" {% if template.refund_finish.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[refund_finish][id]" value="{{ template.refund_finish.id }}" lay-verify="required"></td>
<td><input id="tc-refund-finish" class="layui-input" type="text" value="退款成功,商品名称:{1},退款序号:{2},退款金额:{3}" readonly="readonly"></td>
<td><input id="tc-refund-finish" class="layui-input" type="text" value="退款成功,商品名称:{1},退款序号:{2},退款金额:{3}" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-refund-finish">复制</span></td>
</tr>
<tr>

View File

@ -12,12 +12,6 @@
<input class="layui-input" type="text" name="title" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">简介</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="summary"></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-block">

View File

@ -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;
}
/**

View File

@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://www.koogua.com';
protected $version = '1.6.1';
protected $version = '1.6.2';
public function __get($name)
{
@ -28,6 +28,8 @@ class AppInfo
if (isset($this->{$name})) {
return $this->{$name};
}
return null;
}
}

View File

@ -61,6 +61,9 @@ class Answer extends Repository
case 'accepted':
$orderBy = 'accepted DESC, like_count DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -112,6 +112,9 @@ class Article extends Repository
case 'popular':
$orderBy = 'score DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -35,6 +35,9 @@ class ArticleFavorite extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -51,6 +51,9 @@ class Audit extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -99,6 +99,9 @@ class Chapter extends Repository
*/
public function findByFileId($fileId)
{
/**
* @var ChapterVodModel $vod
*/
$vod = ChapterVodModel::findFirst([
'conditions' => 'file_id = :file_id:',
'bind' => ['file_id' => $fileId],

View File

@ -15,7 +15,7 @@ use Phalcon\Mvc\Model;
class ChapterLive extends Repository
{
public function paginate($where = [], $sort = 'latest', $page = 1, $limit = 15)
public function paginate($where = [], $sort = 'oldest', $page = 1, $limit = 15)
{
$builder = $this->modelsManager->createBuilder();
@ -44,6 +44,9 @@ class ChapterLive extends Repository
}
switch ($sort) {
case 'latest':
$orderBy = 'cl.start_time DESC';
break;
default:
$orderBy = 'cl.start_time ASC';
break;

View File

@ -68,6 +68,9 @@ class Comment extends Repository
case 'popular':
$orderBy = 'like_count DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -65,6 +65,9 @@ class Consult extends Repository
case 'priority':
$orderBy = 'priority ASC, id DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -127,6 +127,9 @@ class Course extends Repository
case 'popular':
$orderBy = 'user_count DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -35,6 +35,9 @@ class CourseFavorite extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -34,6 +34,9 @@ class CourseTopic extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -45,6 +45,9 @@ class CourseUser extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -49,6 +49,9 @@ class Danmu extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -66,6 +66,9 @@ class FlashSale extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -39,6 +39,9 @@ class Learning extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -78,6 +78,9 @@ class Order extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -43,6 +43,9 @@ class Package extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -37,6 +37,9 @@ class Page extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -52,6 +52,9 @@ class PointGift extends Repository
case 'popular':
$orderBy = 'redeem_count DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -39,6 +39,9 @@ class PointGiftRedeem extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -41,6 +41,9 @@ class PointHistory extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -105,6 +105,9 @@ class Question extends Repository
case 'score':
$orderBy = 'score DESC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -35,6 +35,9 @@ class QuestionFavorite extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -53,6 +53,9 @@ class Refund extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -49,6 +49,9 @@ class Report extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -64,6 +64,9 @@ class Review extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -50,6 +50,9 @@ class Tag extends Repository
case 'priority':
$orderBy = 'priority ASC, id ASC';
break;
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -32,6 +32,9 @@ class TagFollow extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -41,6 +41,9 @@ class TeacherConsult extends Repository
$builder->andWhere('c.deleted = 0');
switch ($sort) {
case 'oldest':
$orderBy = 'c.id ASC';
break;
default:
$orderBy = 'c.id DESC';
break;

View File

@ -43,6 +43,9 @@ class Topic extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -69,6 +69,9 @@ class Trade extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -69,6 +69,9 @@ class User extends Repository
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';
break;
default:
$orderBy = 'id DESC';
break;

View File

@ -170,7 +170,7 @@ class DingTalkNotice extends Service
$result = $content['errcode'] == 0;
if ($result == false) {
if (!$result) {
$this->logger->error('Send Message Failed ' . kg_json_encode($content));
}

View File

@ -91,7 +91,7 @@ abstract class Smser extends Service
$result = $sendStatus->getCode() == 'Ok';
if ($result == false) {
if (!$result) {
$this->logger->error('Send Message Failed ' . $response->toJsonString());
}

View File

@ -14,7 +14,7 @@ class Throttle extends Service
{
$config = $this->getConfig();
if ($config->path('throttle.enabled') == false) {
if (!$config->path('throttle.enabled')) {
return true;
}

View File

@ -70,7 +70,7 @@ abstract class WeChatNotice extends Service
$result = $response['errcode'] == 0;
if ($result == false) {
if (!$result) {
$this->logger->error('Send Template Message Failed ' . kg_json_encode($response));
}

View File

@ -54,7 +54,7 @@ class Review extends Validator
public function checkRating($rating)
{
if (!in_array($rating, [1, 2, 3, 4, 5])) {
if ($rating < 1 || $rating > 5) {
throw new BadRequestException('review.invalid_rating');
}

60
composer.lock generated
View File

@ -2366,16 +2366,16 @@
},
{
"name": "qcloud/cos-sdk-v5",
"version": "v2.5.6",
"version": "v2.6.1",
"source": {
"type": "git",
"url": "https://github.com/tencentyun/cos-php-sdk-v5.git",
"reference": "607ee49d372a799964206b6ae0a9eb2816201c42"
"reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/607ee49d372a799964206b6ae0a9eb2816201c42",
"reference": "607ee49d372a799964206b6ae0a9eb2816201c42",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/d367ba8d0305b83364b64055594a0ac22b1cefd8",
"reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8",
"shasum": "",
"mirrors": [
{
@ -2433,9 +2433,9 @@
],
"support": {
"issues": "https://github.com/tencentyun/cos-php-sdk-v5/issues",
"source": "https://github.com/tencentyun/cos-php-sdk-v5/tree/v2.5.6"
"source": "https://github.com/tencentyun/cos-php-sdk-v5/tree/v2.6.1"
},
"time": "2022-06-07T14:49:19+00:00"
"time": "2023-02-07T09:49:12+00:00"
},
{
"name": "ralouphie/getallheaders",
@ -2489,16 +2489,16 @@
},
{
"name": "robmorgan/phinx",
"version": "0.12.12",
"version": "0.12.13",
"source": {
"type": "git",
"url": "https://github.com/cakephp/phinx.git",
"reference": "9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115"
"reference": "6eb0f295e140ed2804d93396755f0ce9ada4ec07"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/phinx/zipball/9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115",
"reference": "9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115",
"url": "https://api.github.com/repos/cakephp/phinx/zipball/6eb0f295e140ed2804d93396755f0ce9ada4ec07",
"reference": "6eb0f295e140ed2804d93396755f0ce9ada4ec07",
"shasum": "",
"mirrors": [
{
@ -2575,9 +2575,9 @@
],
"support": {
"issues": "https://github.com/cakephp/phinx/issues",
"source": "https://github.com/cakephp/phinx/tree/0.12.12"
"source": "https://github.com/cakephp/phinx/tree/0.12.13"
},
"time": "2022-07-09T18:53:51+00:00"
"time": "2022-10-03T04:57:40+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -4910,16 +4910,16 @@
},
{
"name": "tencentcloud/tencentcloud-sdk-php",
"version": "3.0.731",
"version": "3.0.824",
"source": {
"type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
"reference": "a247a556c120dd7dd95db40035edcde7271fe40d"
"reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/a247a556c120dd7dd95db40035edcde7271fe40d",
"reference": "a247a556c120dd7dd95db40035edcde7271fe40d",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5",
"reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5",
"shasum": "",
"mirrors": [
{
@ -4957,9 +4957,9 @@
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.731"
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.824"
},
"time": "2022-09-21T00:09:54+00:00"
"time": "2023-02-15T00:03:58+00:00"
},
{
"name": "webmozart/assert",
@ -5097,16 +5097,16 @@
},
{
"name": "workerman/gateway-worker",
"version": "v3.0.25",
"version": "v3.0.27",
"source": {
"type": "git",
"url": "https://github.com/walkor/GatewayWorker.git",
"reference": "5b47eb9a90c6b2afc25327979e41de352cb3c286"
"reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/5b47eb9a90c6b2afc25327979e41de352cb3c286",
"reference": "5b47eb9a90c6b2afc25327979e41de352cb3c286",
"url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2",
"reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2",
"shasum": "",
"mirrors": [
{
@ -5116,7 +5116,7 @@
]
},
"require": {
"workerman/workerman": "^4.0.30"
"workerman/workerman": "^4.0.0 || ^5.0.0"
},
"type": "library",
"autoload": {
@ -5135,7 +5135,7 @@
],
"support": {
"issues": "https://github.com/walkor/GatewayWorker/issues",
"source": "https://github.com/walkor/GatewayWorker/tree/v3.0.25"
"source": "https://github.com/walkor/GatewayWorker/tree/v3.0.27"
},
"funding": [
{
@ -5147,7 +5147,7 @@
"type": "patreon"
}
],
"time": "2022-09-19T09:59:56+00:00"
"time": "2023-02-09T09:16:04+00:00"
},
{
"name": "workerman/gatewayclient",
@ -5306,16 +5306,16 @@
},
{
"name": "yansongda/pay",
"version": "v2.10.4",
"version": "v2.10.5",
"source": {
"type": "git",
"url": "https://github.com/yansongda/pay.git",
"reference": "e378f43800f867d53ce35ee90aa17f0c3b7b5838"
"reference": "f7d93ed784de4ca09d3386d28139c724ddd526fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yansongda/pay/zipball/e378f43800f867d53ce35ee90aa17f0c3b7b5838",
"reference": "e378f43800f867d53ce35ee90aa17f0c3b7b5838",
"url": "https://api.github.com/repos/yansongda/pay/zipball/f7d93ed784de4ca09d3386d28139c724ddd526fc",
"reference": "f7d93ed784de4ca09d3386d28139c724ddd526fc",
"shasum": "",
"mirrors": [
{
@ -5366,7 +5366,7 @@
"issues": "https://github.com/yansongda/pay/issues",
"source": "https://github.com/yansongda/pay"
},
"time": "2022-03-10T01:27:10+00:00"
"time": "2022-12-03T13:44:53+00:00"
},
{
"name": "yansongda/supports",

View File

@ -172,4 +172,19 @@ $config['websocket']['connect_address'] = 'your_domain.com:8282';
*/
$config['websocket']['register_address'] = '127.0.0.1:1238';
/**
* 资源监控: CPU负载0.1-1.0
*/
$config['server_monitor']['cpu'] = 0.8;
/**
* 资源监控: 内存剩余占比10-100%
*/
$config['server_monitor']['memory'] = 10;
/**
* 资源监控: 磁盘剩余占比10-100%
*/
$config['server_monitor']['disk'] = 20;
return $config;

View File

@ -7,6 +7,7 @@ layui.use(['jquery', 'helper'], function () {
var intervalTime = 15000;
var userId = window.user.id;
var requestId = helper.getRequestId();
var chapterId = $('input[name="chapter.id"]').val();
var planId = $('input[name="chapter.plan_id"]').val();
var lastPosition = $('input[name="chapter.position"]').val();
var learningUrl = $('input[name="chapter.learning_url"]').val();
@ -59,15 +60,30 @@ layui.use(['jquery', 'helper'], function () {
player.toggle();
});
var position = parseInt(lastPosition);
var position = getLastPosition();
/**
* 过于接近结束位置当作已结束处理
* 上次播放位置
*/
if (position > 0 && player.video.duration - position > 10) {
if (position > 0) {
player.seek(position);
}
function getPositionKey() {
return 'chapter:' + chapterId + ':position';
}
function getLastPosition() {
var key = getPositionKey();
var value = localStorage.getItem(key);
return value != null ? parseInt(value) : lastPosition;
}
function setLastPosition(value) {
var key = getPositionKey();
localStorage.setItem(key, value);
}
function clearLearningInterval() {
if (interval != null) {
clearInterval(interval);
@ -91,11 +107,13 @@ layui.use(['jquery', 'helper'], function () {
}
function ended() {
clearLearningInterval();
learning();
setLastPosition(0);
clearLearningInterval();
}
function learning() {
setLastPosition(player.video.currentTime);
if (userId !== '0' && planId !== '0') {
$.ajax({
type: 'POST',