1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 03:50:56 +08:00
This commit is contained in:
xiaochong0302 2023-02-16 14:05:53 +08:00
commit d65e4cab43
81 changed files with 593 additions and 307 deletions

View File

@ -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) ### [v1.6.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.0)(2022-10-26)
- 播放器中间增加大号播放按钮 - 播放器中间增加大号播放按钮

View File

@ -60,7 +60,6 @@ class DeliverTask extends Task
break; break;
default: default:
$this->noMatchedHandler($order); $this->noMatchedHandler($order);
break;
} }
$order->status = OrderModel::STATUS_FINISHED; $order->status = OrderModel::STATUS_FINISHED;

View File

@ -10,7 +10,7 @@ namespace App\Console\Tasks;
use App\Library\Benchmark; use App\Library\Benchmark;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Services\Logic\Notice\External\DingTalk\ServerMonitor as ServerMonitorNotice; use App\Services\Logic\Notice\External\DingTalk\ServerMonitor as ServerMonitorNotice;
use App\Services\Search\UserSearcher; use App\Services\Search\CourseSearcher;
use GatewayClient\Gateway; use GatewayClient\Gateway;
class ServerMonitorTask extends Task class ServerMonitorTask extends Task
@ -53,9 +53,13 @@ class ServerMonitorTask extends Task
$load = sys_getloadavg(); $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 sprintf("cpu负载超过%s", $load[1]);
} }
return null;
} }
protected function checkMemory() protected function checkMemory()
@ -64,25 +68,29 @@ class ServerMonitorTask extends Task
$total = null; $total = null;
if (preg_match('/MemTotal\:\s+(\d+) kB/', $memInfo, $totalMatches)) { if (preg_match('/MemTotal:\s+(\d+) kB/', $memInfo, $totalMatches)) {
$total = $totalMatches[1]; $total = $totalMatches[1];
} }
if ($total === null) return; if ($total === null) return null;
$available = null; $available = null;
if (preg_match('/MemAvailable\:\s+(\d+) kB/', $memInfo, $avaMatches)) { if (preg_match('/MemAvailable:\s+(\d+) kB/', $memInfo, $avaMatches)) {
$available = $avaMatches[1]; $available = $avaMatches[1];
} }
if ($available === null) return; if ($available === null) return null;
$left = 100 * ($available / $total); $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 sprintf("memory剩余不足%s%%", round($left));
} }
return null;
} }
protected function checkDisk() protected function checkDisk()
@ -92,9 +100,13 @@ class ServerMonitorTask extends Task
$left = 100 * $free / $total; $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 sprintf("disk剩余不足%s%%", round($left));
} }
return null;
} }
protected function checkMysql() protected function checkMysql()
@ -111,8 +123,8 @@ class ServerMonitorTask extends Task
$elapsedTime = $benchmark->getElapsedTime(); $elapsedTime = $benchmark->getElapsedTime();
if ($user === false) { if (!$user) {
return sprintf("mysql查询失败"); return "mysql查询失败";
} }
if ($elapsedTime > 1) { if ($elapsedTime > 1) {
@ -120,8 +132,10 @@ class ServerMonitorTask extends Task
} }
} catch (\Exception $e) { } catch (\Exception $e) {
return sprintf("mysql可能存在异常"); return "mysql可能存在异常";
} }
return null;
} }
protected function checkRedis() protected function checkRedis()
@ -139,7 +153,7 @@ class ServerMonitorTask extends Task
$elapsedTime = $benchmark->getElapsedTime(); $elapsedTime = $benchmark->getElapsedTime();
if (empty($site)) { if (empty($site)) {
return sprintf("redis查询失败"); return "redis查询失败";
} }
if ($elapsedTime > 1) { if ($elapsedTime > 1) {
@ -147,8 +161,10 @@ class ServerMonitorTask extends Task
} }
} catch (\Exception $e) { } catch (\Exception $e) {
return sprintf("redis可能存在异常"); return "redis可能存在异常";
} }
return null;
} }
protected function checkXunsearch() protected function checkXunsearch()
@ -159,16 +175,16 @@ class ServerMonitorTask extends Task
$benchmark->start(); $benchmark->start();
$searcher = new UserSearcher(); $searcher = new CourseSearcher();
$user = $searcher->search('id:10000'); $user = $searcher->search('id:1');
$benchmark->stop(); $benchmark->stop();
$elapsedTime = $benchmark->getElapsedTime(); $elapsedTime = $benchmark->getElapsedTime();
if (empty($user)) { if (empty($user)) {
return sprintf("xunsearch搜索失败"); return "xunsearch搜索失败";
} }
if ($elapsedTime > 1) { if ($elapsedTime > 1) {
@ -176,8 +192,10 @@ class ServerMonitorTask extends Task
} }
} catch (\Exception $e) { } catch (\Exception $e) {
return sprintf("xunsearch可能存在异常"); return "xunsearch可能存在异常";
} }
return null;
} }
protected function checkWebsocket() protected function checkWebsocket()
@ -203,8 +221,10 @@ class ServerMonitorTask extends Task
} }
} catch (\Exception $e) { } catch (\Exception $e) {
return sprintf("websocket可能存在异常"); return "websocket可能存在异常";
} }
return null;
} }
protected function getCpuCount() protected function getCpuCount()

View File

@ -48,10 +48,12 @@ class SyncLearningTask extends Task
*/ */
protected function handleLearning($itemKey) protected function handleLearning($itemKey)
{ {
$cache = $this->getCache();
/** /**
* @var LearningModel $cacheLearning * @var LearningModel $cacheLearning
*/ */
$cacheLearning = $this->cache->get($itemKey); $cacheLearning = $cache->get($itemKey);
if (!$cacheLearning) return; if (!$cacheLearning) return;
@ -76,7 +78,7 @@ class SyncLearningTask extends Task
$this->updateChapterUser($dbLearning); $this->updateChapterUser($dbLearning);
} }
$this->cache->delete($itemKey); $cache->delete($itemKey);
} }
/** /**
@ -111,7 +113,12 @@ class SyncLearningTask extends Task
$progress = floor(100 * $chapterUser->duration / $duration); $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->progress = $progress < 100 ? $progress : 100;
$chapterUser->consumed = $chapterUser->duration > 0.3 * $duration ? 1 : 0; $chapterUser->consumed = $chapterUser->duration > 0.3 * $duration ? 1 : 0;

View File

@ -9,7 +9,6 @@ namespace App\Http\Admin\Services;
use App\Builders\ArticleList as ArticleListBuilder; use App\Builders\ArticleList as ArticleListBuilder;
use App\Builders\ReportList as ReportListBuilder; use App\Builders\ReportList as ReportListBuilder;
use App\Caches\Article as ArticleCache;
use App\Library\Paginator\Query as PagerQuery; use App\Library\Paginator\Query as PagerQuery;
use App\Library\Utils\Word as WordUtil; use App\Library\Utils\Word as WordUtil;
use App\Models\Article as ArticleModel; 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\ArticleApproved as ArticleApprovedNotice;
use App\Services\Logic\Notice\Internal\ArticleRejected as ArticleRejectedNotice; use App\Services\Logic\Notice\Internal\ArticleRejected as ArticleRejectedNotice;
use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory; use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory;
use App\Services\Sync\ArticleIndex as ArticleIndexSync;
use App\Validators\Article as ArticleValidator; use App\Validators\Article as ArticleValidator;
class Article extends Service class Article extends Service
@ -209,8 +207,6 @@ class Article extends Service
$this->saveDynamicAttrs($article); $this->saveDynamicAttrs($article);
$this->rebuildArticleIndex($article);
$owner = $this->findUser($article->owner_id); $owner = $this->findUser($article->owner_id);
$this->recountUserArticles($owner); $this->recountUserArticles($owner);
@ -230,8 +226,6 @@ class Article extends Service
$this->saveDynamicAttrs($article); $this->saveDynamicAttrs($article);
$this->rebuildArticleIndex($article);
$owner = $this->findUser($article->owner_id); $owner = $this->findUser($article->owner_id);
$this->recountUserArticles($owner); $this->recountUserArticles($owner);
@ -251,8 +245,6 @@ class Article extends Service
$this->saveDynamicAttrs($article); $this->saveDynamicAttrs($article);
$this->rebuildArticleIndex($article);
$owner = $this->findUser($article->owner_id); $owner = $this->findUser($article->owner_id);
$this->recountUserArticles($owner); $this->recountUserArticles($owner);
@ -292,7 +284,6 @@ class Article extends Service
if ($type == 'approve') { if ($type == 'approve') {
$this->rebuildArticleIndex($article);
$this->handleArticlePostPoint($article); $this->handleArticlePostPoint($article);
$this->handleArticleApprovedNotice($article, $sender); $this->handleArticleApprovedNotice($article, $sender);
@ -403,20 +394,6 @@ class Article extends Service
$user->update(); $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) protected function handleArticlePostPoint(ArticleModel $article)
{ {
if ($article->published != ArticleModel::PUBLISH_APPROVED) return; if ($article->published != ArticleModel::PUBLISH_APPROVED) return;

View File

@ -8,7 +8,6 @@
namespace App\Http\Admin\Services; namespace App\Http\Admin\Services;
use App\Builders\CourseList as CourseListBuilder; use App\Builders\CourseList as CourseListBuilder;
use App\Caches\Course as CourseCache;
use App\Caches\CourseCategoryList as CourseCategoryListCache; use App\Caches\CourseCategoryList as CourseCategoryListCache;
use App\Caches\CourseRelatedList as CourseRelatedListCache; use App\Caches\CourseRelatedList as CourseRelatedListCache;
use App\Caches\CourseTeacherList as CourseTeacherListCache; 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\CourseRelated as CourseRelatedRepo;
use App\Repos\CourseUser as CourseUserRepo; use App\Repos\CourseUser as CourseUserRepo;
use App\Repos\User as UserRepo; use App\Repos\User as UserRepo;
use App\Services\Sync\CourseIndex as CourseIndexSync;
use App\Validators\Course as CourseValidator; use App\Validators\Course as CourseValidator;
use App\Validators\CourseOffline as CourseOfflineValidator; use App\Validators\CourseOffline as CourseOfflineValidator;
@ -399,20 +397,6 @@ class Course extends Service
return $validator->checkCourse($id); 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) protected function saveTeachers(CourseModel $course, $teacherIds)
{ {
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();

View File

@ -101,7 +101,6 @@ class Package extends Service
$data = []; $data = [];
$data['title'] = $validator->checkTitle($post['title']); $data['title'] = $validator->checkTitle($post['title']);
$data['summary'] = $validator->checkSummary($post['summary']);
$package = new PackageModel(); $package = new PackageModel();

View File

@ -7,7 +7,6 @@
namespace App\Http\Admin\Services; namespace App\Http\Admin\Services;
use App\Caches\Page as PageCache;
use App\Library\Paginator\Query as PagerQuery; use App\Library\Paginator\Query as PagerQuery;
use App\Models\Page as PageModel; use App\Models\Page as PageModel;
use App\Repos\Page as PageRepo; use App\Repos\Page as PageRepo;
@ -53,8 +52,6 @@ class Page extends Service
$page->create($data); $page->create($data);
$this->rebuildPageCache($page);
return $page; return $page;
} }
@ -96,8 +93,6 @@ class Page extends Service
$page->update($data); $page->update($data);
$this->rebuildPageCache($page);
return $page; return $page;
} }
@ -109,8 +104,6 @@ class Page extends Service
$page->update(); $page->update();
$this->rebuildPageCache($page);
return $page; return $page;
} }
@ -122,18 +115,9 @@ class Page extends Service
$page->update(); $page->update();
$this->rebuildPageCache($page);
return $page; return $page;
} }
protected function rebuildPageCache(PageModel $page)
{
$cache = new PageCache();
$cache->rebuild($page->id);
}
protected function findOrFail($id) protected function findOrFail($id)
{ {
$validator = new PageValidator(); $validator = new PageValidator();

View File

@ -9,7 +9,6 @@ namespace App\Http\Admin\Services;
use App\Builders\QuestionList as QuestionListBuilder; use App\Builders\QuestionList as QuestionListBuilder;
use App\Builders\ReportList as ReportListBuilder; use App\Builders\ReportList as ReportListBuilder;
use App\Caches\Question as QuestionCache;
use App\Library\Paginator\Query as PagerQuery; use App\Library\Paginator\Query as PagerQuery;
use App\Models\Category as CategoryModel; use App\Models\Category as CategoryModel;
use App\Models\Question as QuestionModel; 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\QuestionDataTrait;
use App\Services\Logic\Question\QuestionInfo as QuestionInfoService; use App\Services\Logic\Question\QuestionInfo as QuestionInfoService;
use App\Services\Logic\Question\XmTagList as XmTagListService; use App\Services\Logic\Question\XmTagList as XmTagListService;
use App\Services\Sync\QuestionIndex as QuestionIndexSync;
use App\Validators\Question as QuestionValidator; use App\Validators\Question as QuestionValidator;
class Question extends Service class Question extends Service
@ -191,8 +189,6 @@ class Question extends Service
$this->saveDynamicAttrs($question); $this->saveDynamicAttrs($question);
$this->rebuildQuestionIndex($question);
$owner = $this->findUser($question->owner_id); $owner = $this->findUser($question->owner_id);
$this->recountUserQuestions($owner); $this->recountUserQuestions($owner);
@ -212,8 +208,6 @@ class Question extends Service
$this->saveDynamicAttrs($question); $this->saveDynamicAttrs($question);
$this->rebuildQuestionIndex($question);
$owner = $this->findUser($question->owner_id); $owner = $this->findUser($question->owner_id);
$this->recountUserQuestions($owner); $this->recountUserQuestions($owner);
@ -231,8 +225,6 @@ class Question extends Service
$question->update(); $question->update();
$this->rebuildQuestionIndex($question);
$owner = $this->findUser($question->owner_id); $owner = $this->findUser($question->owner_id);
$this->recountUserQuestions($owner); $this->recountUserQuestions($owner);
@ -268,7 +260,6 @@ class Question extends Service
if ($type == 'approve') { if ($type == 'approve') {
$this->rebuildQuestionIndex($question);
$this->handleQuestionPostPoint($question); $this->handleQuestionPostPoint($question);
$this->handleQuestionApprovedNotice($question, $sender); $this->handleQuestionApprovedNotice($question, $sender);
@ -379,20 +370,6 @@ class Question extends Service
$user->update(); $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) protected function handleQuestionPostPoint(QuestionModel $question)
{ {
if ($question->published != QuestionModel::PUBLISH_APPROVED) return; if ($question->published != QuestionModel::PUBLISH_APPROVED) return;

View File

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

View File

@ -12,12 +12,6 @@
<input class="layui-input" type="text" name="title" lay-verify="required"> <input class="layui-input" type="text" name="title" lay-verify="required">
</div> </div>
</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"> <div class="layui-form-item">
<label class="layui-form-label"></label> <label class="layui-form-label"></label>
<div class="layui-input-block"> <div class="layui-input-block">

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 %}> <input type="radio" name="template[order_finish][enabled]" value="0" title="否" {% if template.order_finish.enabled == "0" %}checked="checked"{% endif %}>
</td> </td>
<td><input class="layui-input" type="text" name="template[order_finish][id]" value="{{ template.order_finish.id }}" lay-verify="required"></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> <td><span class="kg-copy layui-btn" data-clipboard-target="#tc-order-finish">复制</span></td>
</tr> </tr>
<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 %}> <input type="radio" name="template[refund_finish][enabled]" value="0" title="否" {% if template.refund_finish.enabled == "0" %}checked="checked"{% endif %}>
</td> </td>
<td><input class="layui-input" type="text" name="template[refund_finish][id]" value="{{ template.refund_finish.id }}" lay-verify="required"></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> <td><span class="kg-copy layui-btn" data-clipboard-target="#tc-refund-finish">复制</span></td>
</tr> </tr>
<tr> <tr>

View File

@ -32,6 +32,8 @@
</thead> </thead>
<tbody> <tbody>
{% for item in pager.items %} {% 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' %}
<tr> <tr>
<td> <td>
<p class="layui-elip">课程:{{ item.course.title }}</p> <p class="layui-elip">课程:{{ item.course.title }}</p>
@ -41,8 +43,8 @@
<p>类型:{{ client_type_info(item.client_type) }}</p> <p>类型:{{ client_type_info(item.client_type) }}</p>
<p>地址:<a href="javascript:" class="kg-ip2region" title="查看位置" data-ip="{{ item.client_ip }}">{{ item.client_ip }}</a></p> <p>地址:<a href="javascript:" class="kg-ip2region" title="查看位置" data-ip="{{ item.client_ip }}">{{ item.client_ip }}</a></p>
</td> </td>
<td>{{ item.duration|duration }}</td> <td>{{ duration }}</td>
<td>{{ date('Y-m-d H:i:s',item.active_time) }}</td> <td>{{ active_time }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@ -12,12 +12,6 @@
<input class="layui-input" type="text" name="title" lay-verify="required"> <input class="layui-input" type="text" name="title" lay-verify="required">
</div> </div>
</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"> <div class="layui-form-item">
<label class="layui-form-label"></label> <label class="layui-form-label"></label>
<div class="layui-input-block"> <div class="layui-input-block">

View File

@ -71,11 +71,15 @@
<input class="layui-input" name="apply_note" lay-verify="required"> <input class="layui-input" name="apply_note" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item kg-center"> <div class="layui-form-item">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交申请</button> <label class="layui-form-label"></label>
<input type="hidden" name="trade_amount" value="{{ trade.amount }}"> <div class="layui-input-block">
<input type="hidden" name="refund_amount" value="{{ confirm.refund_amount }}"> <button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
<input type="hidden" name="service_fee" value="{{ confirm.service_fee }}"> <button type="reset" class="layui-btn layui-btn-primary">重置</button>
<input type="hidden" name="trade_amount" value="{{ trade.amount }}">
<input type="hidden" name="refund_amount" value="{{ confirm.refund_amount }}">
<input type="hidden" name="service_fee" value="{{ confirm.service_fee }}">
</div>
</div> </div>
</form> </form>

View File

@ -73,18 +73,19 @@ class PublicController extends \Phalcon\Mvc\Controller
{ {
$text = $this->request->getQuery('text', 'string'); $text = $this->request->getQuery('text', 'string');
$size = $this->request->getQuery('size', 'int', 320); $size = $this->request->getQuery('size', 'int', 320);
$margin = $this->request->getQuery('margin', 'int', 10);
$text = urldecode($text); $text = urldecode($text);
$qrCode = new QrCode($text); $qrCode = new QrCode($text);
$qrCode->setSize($size); $qrCode->setSize($size);
$qrCode->setMargin($margin);
$qrCode->getContentType(); $this->response->setContentType('image/png');
$this->response->setContent($qrCode->writeString());
echo $qrCode->writeString(); return $this->response;
exit;
} }
/** /**

View File

@ -4,7 +4,7 @@
{% set sort_val = request.get('sort','trim','latest') %} {% set sort_val = request.get('sort','trim','latest') %}
{% set pager_url = url({'for':'home.article.pager'}, params) %} {% 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'}) %} {% set my_tags_url = url({'for':'home.widget.my_tags'},{'type':'article'}) %}
<div class="breadcrumb"> <div class="breadcrumb">

View File

@ -1,23 +1,35 @@
{%- macro show_lesson_list(chapter) %}
<ul class="sidebar-lesson-list">
{% for lesson in chapter.children %}
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %}
{% set active = (chapter.id == lesson.id) ? 'active' : 'normal' %}
<li class="lesson-title layui-elip">
{% if lesson.me.owned == 1 %}
<a class="{{ active }}" href="{{ url }}" title="{{ lesson.title }}">{{ lesson.title }}</a>
{% else %}
<span class="deny" title="{{ lesson.title }}">{{ lesson.title }}</span>
{% endif %}
</li>
{% endfor %}
</ul>
{%- endmacro %}
<div class="layui-card sidebar-card sidebar-chapter"> <div class="layui-card sidebar-card sidebar-chapter">
<div class="layui-card-header">课程目录</div> <div class="layui-card-header">课程目录</div>
<div class="layui-card-body"> <div class="layui-card-body">
<div class="sidebar-chapter-list"> {% if catalog|length > 1 %}
{% for item in catalog %} <div class="sidebar-chapter-list">
<div class="chapter-title layui-elip">{{ item.title }}</div> {% for item in catalog %}
<ul class="sidebar-lesson-list"> <div class="chapter-title layui-elip">{{ item.title }}</div>
{% for lesson in item.children %} <div class="sidebar-lesson-list">
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %} {{ show_lesson_list(item) }}
{% set active = (chapter.id == lesson.id) ? 'active' : 'normal' %} </div>
<li class="lesson-title layui-elip"> {% endfor %}
{% if lesson.me.owned == 1 %} </div>
<a class="{{ active }}" href="{{ url }}" title="{{ lesson.title }}">{{ lesson.title }}</a> {% else %}
{% else %} <div class="sidebar-lesson-list">
<span class="deny" title="{{ lesson.title }}">{{ lesson.title }}</span> {{ show_lesson_list(catalog[0]) }}
{% endif %} </div>
</li> {% endif %}
{% endfor %}
</ul>
{% endfor %}
</div>
</div> </div>
</div> </div>

View File

@ -1,3 +1,19 @@
{%- macro show_lesson_list(chapter) %}
<ul class="lesson-list">
{% for lesson in chapter.children %}
{% if lesson.model == 1 %}
<li class="lesson-item">{{ vod_lesson_info(lesson) }}</li>
{% elseif lesson.model == 2 %}
<li class="lesson-item">{{ live_lesson_info(lesson) }}</li>
{% elseif lesson.model == 3 %}
<li class="lesson-item">{{ read_lesson_info(lesson) }}</li>
{% elseif lesson.model == 4 %}
<li class="lesson-item">{{ offline_lesson_info(lesson) }}</li>
{% endif %}
{% endfor %}
</ul>
{%- endmacro %}
{%- macro vod_lesson_info(lesson) %} {%- macro vod_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %} {% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %} {% set priv = lesson.me.owned ? 'allow' : 'deny' %}
@ -87,28 +103,20 @@
{% set show_all = course.lesson_count < 30 %} {% set show_all = course.lesson_count < 30 %}
{% if chapters %} {% if chapters|length > 0 %}
<div class="layui-collapse" lay-accordion="true"> {% if chapters|length > 1 %}
{% for chapter in chapters %} <div class="layui-collapse" lay-accordion="true">
{% set show_class = (show_all or loop.first) ? 'layui-show' : '' %} {% for chapter in chapters %}
<div class="layui-colla-item"> {% set show_class = (show_all or loop.first) ? 'layui-show' : '' %}
<h2 class="layui-colla-title">{{ chapter.title }}</h2> <div class="layui-colla-item">
<div class="layui-colla-content {{ show_class }}"> <h2 class="layui-colla-title">{{ chapter.title }}</h2>
<ul class="lesson-list"> <div class="layui-colla-content {{ show_class }}">
{% for lesson in chapter.children %} {{ show_lesson_list(chapter) }}
{% if lesson.model == 1 %} </div>
<li class="lesson-item">{{ vod_lesson_info(lesson) }}</li>
{% elseif lesson.model == 2 %}
<li class="lesson-item">{{ live_lesson_info(lesson) }}</li>
{% elseif lesson.model == 3 %}
<li class="lesson-item">{{ read_lesson_info(lesson) }}</li>
{% elseif lesson.model == 4 %}
<li class="lesson-item">{{ offline_lesson_info(lesson) }}</li>
{% endif %}
{% endfor %}
</ul>
</div> </div>
</div> {% endfor %}
{% endfor %} </div>
</div> {% else %}
{{ show_lesson_list(chapters[0]) }}
{% endif %}
{% endif %} {% endif %}

View File

@ -4,8 +4,8 @@
{% set sort_val = request.get('sort','trim','latest') %} {% set sort_val = request.get('sort','trim','latest') %}
{% set pager_url = url({'for':'home.question.pager'}, params) %} {% set pager_url = url({'for':'home.question.pager'}, params) %}
{% set hot_questions_url = url({'for':'home.widget.hot_questions'}) %} {% set hot_questions_url = url({'for':'home.widget.hot_questions'},{'limit':10}) %}
{% set top_answerers_url = url({'for':'home.widget.top_answerers'}) %} {% set top_answerers_url = url({'for':'home.widget.top_answerers'},{'limit':5}) %}
{% set my_tags_url = url({'for':'home.widget.my_tags'},{'type':'question'}) %} {% set my_tags_url = url({'for':'home.widget.my_tags'},{'type':'question'}) %}
<div class="breadcrumb"> <div class="breadcrumb">

View File

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

View File

@ -31,13 +31,13 @@ class ServerInfo
$total = 0; $total = 0;
if (preg_match('/MemTotal\:\s+(\d+) kB/', $mem, $totalMatches)) { if (preg_match('/MemTotal:\s+(\d+) kB/', $mem, $totalMatches)) {
$total = $totalMatches[1]; $total = $totalMatches[1];
} }
$free = 0; $free = 0;
if (preg_match('/MemFree\:\s+(\d+) kB/', $mem, $freeMatches)) { if (preg_match('/MemFree:\s+(\d+) kB/', $mem, $freeMatches)) {
$free = $freeMatches[1]; $free = $freeMatches[1];
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@ use Phalcon\Mvc\Model;
class ChapterLive extends Repository 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(); $builder = $this->modelsManager->createBuilder();
@ -44,6 +44,9 @@ class ChapterLive extends Repository
} }
switch ($sort) { switch ($sort) {
case 'latest':
$orderBy = 'cl.start_time DESC';
break;
default: default:
$orderBy = 'cl.start_time ASC'; $orderBy = 'cl.start_time ASC';
break; break;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,159 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services;
use App\Library\Utils\FileInfo;
use App\Models\Upload as UploadModel;
use App\Repos\Upload as UploadRepo;
use Phalcon\Text;
class EditorStorage extends Storage
{
public function handle($content)
{
$content = $this->handleBase64Image($content);
$content = $this->handleRemoteImage($content);
return trim($content);
}
protected function handleBase64Image($content)
{
$content = preg_replace("/data-ke-src=\"(.*?)\"/", '', $content);
preg_match_all('/src="(data:image\/(\S+);base64,(\S+))"/U', $content, $matches);
if (count($matches[3]) > 0) {
foreach ($matches[3] as $key => $value) {
$imageUrl = $this->uploadBase64Image($matches[3][$key], $matches[2][$key]);
$content = str_replace($matches[1][$key], $imageUrl, $content);
}
}
return $content;
}
protected function handleRemoteImage($content)
{
$baseUrl = $this->getBaseUrl();
preg_match_all('/<img src="(\S+)"/', $content, $matches);
if (count($matches[1]) > 0) {
foreach ($matches[1] as $key => $value) {
if (!Text::startsWith($value, $baseUrl)) {
$imageUrl = $this->uploadRemoteImage($value);
$content = str_replace($value, $imageUrl, $content);
}
}
}
return $content;
}
protected function uploadBase64Image($encodeContent, $extension)
{
$keyName = $this->generateFileName($extension, '/img/content/');
$content = base64_decode($encodeContent);
$md5 = md5($content);
$uploadRepo = new UploadRepo();
$upload = $uploadRepo->findByMd5($md5);
if (!$upload) {
$uploadPath = $this->putString($keyName, $content);
if ($uploadPath) {
$upload = new UploadModel();
$upload->type = UploadModel::TYPE_CONTENT_IMG;
$upload->mime = FileInfo::getMimeTypeByExt($extension);
$upload->name = pathinfo($uploadPath, PATHINFO_BASENAME);
$upload->size = strlen($content);
$upload->path = $uploadPath;
$upload->md5 = $md5;
$upload->create();
}
$imageUrl = $uploadPath ? $this->getImageUrl($uploadPath) : '';
} else {
$imageUrl = $this->getImageUrl($upload->path);
}
return $imageUrl;
}
protected function uploadRemoteImage($remoteUrl)
{
$extension = $this->getImageExtension($remoteUrl);
$content = file_get_contents($remoteUrl);
if ($content === false) return $remoteUrl;
$keyName = $this->generateFileName($extension, '/img/content/');
$md5 = md5($content);
$uploadRepo = new UploadRepo();
$upload = $uploadRepo->findByMd5($md5);
if (!$upload) {
$uploadPath = $this->putString($keyName, $content);
if ($uploadPath) {
$upload = new UploadModel();
$upload->type = UploadModel::TYPE_CONTENT_IMG;
$upload->mime = FileInfo::getMimeTypeByExt($extension);
$upload->name = pathinfo($uploadPath, PATHINFO_BASENAME);
$upload->size = strlen($content);
$upload->path = $uploadPath;
$upload->md5 = $md5;
$upload->create();
}
$imageUrl = $uploadPath ? $this->getImageUrl($uploadPath) : $remoteUrl;
} else {
$imageUrl = $this->getImageUrl($upload->path);
}
return $imageUrl;
}
/**
* 例如https://abc.com/123.jpg!large这类不规范地址需要特殊处理
*
* @param string $imageUrl
* @return string
*/
protected function getImageExtension($imageUrl)
{
$path = parse_url($imageUrl, PHP_URL_PATH);
preg_match('/(\S+)\.(png|gif|jpg|jpeg)/i', $path, $matches);
return $matches[2] ? strtolower($matches[2]) : 'jpg';
}
}

View File

@ -15,11 +15,17 @@ class TopAuthorList extends LogicService
public function handle() public function handle()
{ {
$limit = $this->request->getQuery('limit', 'int', 10);
$cache = new TopAuthorListCache(); $cache = new TopAuthorListCache();
$result = $cache->get(); $list = $cache->get();
return $result ?: []; if($limit < count($list)) {
$list = array_slice($list, $limit);
}
return $list;
} }
} }

View File

@ -34,10 +34,8 @@ class AccountLogin extends LogicService
$subscribe = $subscribeRepo->findByUserId($userId); $subscribe = $subscribeRepo->findByUserId($userId);
if ($subscribe) { if ($subscribe) {
$notice = new WeChatAccountLoginNotice(); $notice = new WeChatAccountLoginNotice();
$notice->handle($subscribe, $params);
return $notice->handle($subscribe, $params);
} }
} }

View File

@ -19,7 +19,7 @@ trait PointGiftTrait
return $validator->checkPointGift($id); return $validator->checkPointGift($id);
} }
public function checkFlashSaleCache($id) public function checkPointGiftCache($id)
{ {
$validator = new PointGiftValidator(); $validator = new PointGiftValidator();

View File

@ -15,11 +15,17 @@ class HotQuestionList extends LogicService
public function handle() public function handle()
{ {
$limit = $this->request->getQuery('limit', 'int', 10);
$cache = new HotQuestionListCache(); $cache = new HotQuestionListCache();
$result = $cache->get(); $list = $cache->get();
return $result ?: []; if($limit < count($list)) {
$list = array_slice($list, $limit);
}
return $list;
} }
} }

View File

@ -15,11 +15,17 @@ class TopAnswererList extends LogicService
public function handle() public function handle()
{ {
$limit = $this->request->getQuery('limit', 'int', 10);
$cache = new TopAnswererListCache(); $cache = new TopAnswererListCache();
$result = $cache->get(); $list = $cache->get();
return $result ?: []; if($limit < count($list)) {
$list = array_slice($list, $limit);
}
return $list;
} }
} }

View File

@ -17,6 +17,12 @@ class NotificationRead extends LogicService
{ {
$user = $this->getLoginUser(); $user = $this->getLoginUser();
if ($user->notice_count == 0) return;
$user->notice_count = 0;
$user->update();
$notifyRepo = new NotificationRepo(); $notifyRepo = new NotificationRepo();
$notifyRepo->markAllAsViewed($user->id); $notifyRepo->markAllAsViewed($user->id);

View File

@ -183,58 +183,6 @@ class MyStorage extends Storage
return $this->upload('/resource/', self::MIME_FILE, UploadModel::TYPE_RESOURCE); return $this->upload('/resource/', self::MIME_FILE, UploadModel::TYPE_RESOURCE);
} }
/**
* @param string $url
*
* @return UploadModel|bool
*/
public function uploadRemoteImage($url)
{
$path = parse_url($url, PHP_URL_PATH);
$extension = pathinfo($path, PATHINFO_EXTENSION);
$originalName = pathinfo($path, PATHINFO_BASENAME);
$fileName = $this->generateFileName($extension);
$filePath = tmp_path($fileName);
$contents = file_get_contents($url);
if (file_put_contents($filePath, $contents) === false) {
return false;
}
$keyName = "/img/content/{$fileName}";
$uploadPath = $this->putFile($keyName, $filePath);
if (!$uploadPath) return false;
$md5 = md5_file($filePath);
$uploadRepo = new UploadRepo();
$upload = $uploadRepo->findByMd5($md5);
if ($upload == false) {
$upload = new UploadModel();
$upload->name = $originalName;
$upload->mime = mime_content_type($filePath);
$upload->size = filesize($filePath);
$upload->type = UploadModel::TYPE_CONTENT_IMG;
$upload->path = $uploadPath;
$upload->md5 = $md5;
$upload->create();
}
unlink($filePath);
return $upload;
}
/** /**
* 上传文件 * 上传文件
* *
@ -256,7 +204,7 @@ class MyStorage extends Storage
foreach ($files as $file) { foreach ($files as $file) {
if ($this->checkFile($file->getRealType(), $mimeType) == false) { if (!$this->checkFile($file->getRealType(), $mimeType)) {
continue; continue;
} }
@ -264,7 +212,7 @@ class MyStorage extends Storage
$upload = $uploadRepo->findByMd5($md5); $upload = $uploadRepo->findByMd5($md5);
if ($upload == false) { if (!$upload) {
$name = $this->filter->sanitize($file->getName(), ['trim', 'string']); $name = $this->filter->sanitize($file->getName(), ['trim', 'string']);

View File

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

View File

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

View File

@ -172,29 +172,25 @@ class Vod extends Service
$expiredTime = base_convert(time() + $expiry, 10, 16); $expiredTime = base_convert(time() + $expiry, 10, 16);
$tryTime = 0; // 试看时间0不限制 $tryTime = 0; // 试看时间0不限制
$ipLimit = 0; // ip数量限制0不限制 $ipLimit = 9; // ip数量限制0不限制
$random = rand(100000, 999999); // 随机数 $random = uniqid(); // 随机数
/** /**
* 腾讯坑爹的参数类型和文档,先凑合吧 * 腾讯坑爹的参数类型和文档,先凑合吧
* 不限制试看 => 必须exper=0(不能设置为空) * 不限制试看 => 必须exper=0(不能设置为空)
* 不限制IP => 必须rlimit为空不能设置为0,暂不可用 * 不限制IP => 必须rlimit为空不能设置为0
*/ */
$myTryTime = $tryTime >= 0 ? $tryTime : 0; $myTryTime = $tryTime;
$myIpLimit = $ipLimit > 0 ? $ipLimit : ''; $myIpLimit = $ipLimit;
$sign = $key . $dirName . $expiredTime . $myTryTime . $myIpLimit . $random; $sign = $key . $dirName . $expiredTime . $myTryTime . $myIpLimit . $random;
$query = []; $query = [];
$query['t'] = $expiredTime; $query['t'] = $expiredTime;
if ($tryTime >= 0) { $query['exper'] = $myTryTime;
$query['exper'] = $tryTime;
}
if ($ipLimit > 0) { $query['rlimit'] = $myIpLimit;
$query['rlimit'] = $ipLimit;
}
$query['us'] = $random; $query['us'] = $random;

View File

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

View File

@ -15,6 +15,7 @@ use App\Models\Reason as ReasonModel;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Repos\Answer as AnswerRepo; use App\Repos\Answer as AnswerRepo;
use App\Repos\Question as QuestionRepo; use App\Repos\Question as QuestionRepo;
use App\Services\EditorStorage as EditorStorageService;
class Answer extends Validator class Answer extends Validator
{ {
@ -58,6 +59,10 @@ class Answer extends Validator
{ {
$value = $this->filter->sanitize($content, ['trim']); $value = $this->filter->sanitize($content, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length < 10) { if ($length < 10) {

View File

@ -14,6 +14,7 @@ use App\Library\Validators\Common as CommonValidator;
use App\Models\Article as ArticleModel; use App\Models\Article as ArticleModel;
use App\Models\Reason as ReasonModel; use App\Models\Reason as ReasonModel;
use App\Repos\Article as ArticleRepo; use App\Repos\Article as ArticleRepo;
use App\Services\EditorStorage as EditorStorageService;
class Article extends Validator class Article extends Validator
{ {
@ -94,6 +95,10 @@ class Article extends Validator
{ {
$value = $this->filter->sanitize($content, ['trim']); $value = $this->filter->sanitize($content, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length < 10) { if ($length < 10) {

View File

@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator; use App\Library\Validators\Common as CommonValidator;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Services\EditorStorage as EditorStorageService;
class Course extends Validator class Course extends Validator
{ {
@ -119,6 +120,10 @@ class Course extends Validator
{ {
$value = $this->filter->sanitize($details, ['trim']); $value = $this->filter->sanitize($details, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length > 30000) { if ($length > 30000) {

View File

@ -12,6 +12,7 @@ use App\Caches\MaxHelpId as MaxHelpIdCache;
use App\Exceptions\BadRequest as BadRequestException; use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Help as HelpModel; use App\Models\Help as HelpModel;
use App\Repos\Help as HelpRepo; use App\Repos\Help as HelpRepo;
use App\Services\EditorStorage as EditorStorageService;
class Help extends Validator class Help extends Validator
{ {
@ -90,6 +91,10 @@ class Help extends Validator
{ {
$value = $this->filter->sanitize($content, ['trim']); $value = $this->filter->sanitize($content, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length < 10) { if ($length < 10) {

View File

@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator; use App\Library\Validators\Common as CommonValidator;
use App\Models\Page as PageModel; use App\Models\Page as PageModel;
use App\Repos\Page as PageRepo; use App\Repos\Page as PageRepo;
use App\Services\EditorStorage as EditorStorageService;
class Page extends Validator class Page extends Validator
{ {
@ -124,6 +125,10 @@ class Page extends Validator
{ {
$value = $this->filter->sanitize($content, ['trim']); $value = $this->filter->sanitize($content, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length < 10) { if ($length < 10) {

View File

@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator; use App\Library\Validators\Common as CommonValidator;
use App\Models\PointGift as PointGiftModel; use App\Models\PointGift as PointGiftModel;
use App\Repos\PointGift as PointGiftRepo; use App\Repos\PointGift as PointGiftRepo;
use App\Services\EditorStorage as EditorStorageService;
class PointGift extends Validator class PointGift extends Validator
{ {
@ -86,6 +87,10 @@ class PointGift extends Validator
{ {
$value = $this->filter->sanitize($details, ['trim']); $value = $this->filter->sanitize($details, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length > 30000) { if ($length > 30000) {

View File

@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Question as QuestionModel; use App\Models\Question as QuestionModel;
use App\Models\Reason as ReasonModel; use App\Models\Reason as ReasonModel;
use App\Repos\Question as QuestionRepo; use App\Repos\Question as QuestionRepo;
use App\Services\EditorStorage as EditorStorageService;
class Question extends Validator class Question extends Validator
{ {
@ -106,6 +107,10 @@ class Question extends Validator
{ {
$value = $this->filter->sanitize($content, ['trim']); $value = $this->filter->sanitize($content, ['trim']);
$storage = new EditorStorageService();
$value = $storage->handle($value);
$length = kg_strlen($value); $length = kg_strlen($value);
if ($length > 30000) { if ($length > 30000) {

View File

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

60
composer.lock generated
View File

@ -2366,16 +2366,16 @@
}, },
{ {
"name": "qcloud/cos-sdk-v5", "name": "qcloud/cos-sdk-v5",
"version": "v2.5.6", "version": "v2.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tencentyun/cos-php-sdk-v5.git", "url": "https://github.com/tencentyun/cos-php-sdk-v5.git",
"reference": "607ee49d372a799964206b6ae0a9eb2816201c42" "reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/607ee49d372a799964206b6ae0a9eb2816201c42", "url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/d367ba8d0305b83364b64055594a0ac22b1cefd8",
"reference": "607ee49d372a799964206b6ae0a9eb2816201c42", "reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -2433,9 +2433,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/tencentyun/cos-php-sdk-v5/issues", "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", "name": "ralouphie/getallheaders",
@ -2489,16 +2489,16 @@
}, },
{ {
"name": "robmorgan/phinx", "name": "robmorgan/phinx",
"version": "0.12.12", "version": "0.12.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/cakephp/phinx.git", "url": "https://github.com/cakephp/phinx.git",
"reference": "9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115" "reference": "6eb0f295e140ed2804d93396755f0ce9ada4ec07"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/cakephp/phinx/zipball/9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115", "url": "https://api.github.com/repos/cakephp/phinx/zipball/6eb0f295e140ed2804d93396755f0ce9ada4ec07",
"reference": "9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115", "reference": "6eb0f295e140ed2804d93396755f0ce9ada4ec07",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -2575,9 +2575,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/cakephp/phinx/issues", "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", "name": "swiftmailer/swiftmailer",
@ -4910,16 +4910,16 @@
}, },
{ {
"name": "tencentcloud/tencentcloud-sdk-php", "name": "tencentcloud/tencentcloud-sdk-php",
"version": "3.0.731", "version": "3.0.824",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git", "url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
"reference": "a247a556c120dd7dd95db40035edcde7271fe40d" "reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/a247a556c120dd7dd95db40035edcde7271fe40d", "url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5",
"reference": "a247a556c120dd7dd95db40035edcde7271fe40d", "reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -4957,9 +4957,9 @@
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php", "homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": { "support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues", "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", "name": "webmozart/assert",
@ -5097,16 +5097,16 @@
}, },
{ {
"name": "workerman/gateway-worker", "name": "workerman/gateway-worker",
"version": "v3.0.25", "version": "v3.0.27",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/walkor/GatewayWorker.git", "url": "https://github.com/walkor/GatewayWorker.git",
"reference": "5b47eb9a90c6b2afc25327979e41de352cb3c286" "reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/5b47eb9a90c6b2afc25327979e41de352cb3c286", "url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2",
"reference": "5b47eb9a90c6b2afc25327979e41de352cb3c286", "reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -5116,7 +5116,7 @@
] ]
}, },
"require": { "require": {
"workerman/workerman": "^4.0.30" "workerman/workerman": "^4.0.0 || ^5.0.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -5135,7 +5135,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/walkor/GatewayWorker/issues", "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": [ "funding": [
{ {
@ -5147,7 +5147,7 @@
"type": "patreon" "type": "patreon"
} }
], ],
"time": "2022-09-19T09:59:56+00:00" "time": "2023-02-09T09:16:04+00:00"
}, },
{ {
"name": "workerman/gatewayclient", "name": "workerman/gatewayclient",
@ -5306,16 +5306,16 @@
}, },
{ {
"name": "yansongda/pay", "name": "yansongda/pay",
"version": "v2.10.4", "version": "v2.10.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/yansongda/pay.git", "url": "https://github.com/yansongda/pay.git",
"reference": "e378f43800f867d53ce35ee90aa17f0c3b7b5838" "reference": "f7d93ed784de4ca09d3386d28139c724ddd526fc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/yansongda/pay/zipball/e378f43800f867d53ce35ee90aa17f0c3b7b5838", "url": "https://api.github.com/repos/yansongda/pay/zipball/f7d93ed784de4ca09d3386d28139c724ddd526fc",
"reference": "e378f43800f867d53ce35ee90aa17f0c3b7b5838", "reference": "f7d93ed784de4ca09d3386d28139c724ddd526fc",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -5366,7 +5366,7 @@
"issues": "https://github.com/yansongda/pay/issues", "issues": "https://github.com/yansongda/pay/issues",
"source": "https://github.com/yansongda/pay" "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", "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'; $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; return $config;

View File

@ -49,14 +49,15 @@ layui.use(['jquery', 'form', 'element', 'layer', 'kgDropdown'], function () {
form.on('submit(go)', function (data) { form.on('submit(go)', function (data) {
var submit = $(this); var submit = $(this);
submit.attr('disabled', 'disabled').addClass('layui-btn-disabled'); var orgText = $(this).text();
submit.text('提交中···').attr('disabled', 'disabled').addClass('layui-btn-disabled');
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: data.form.action, url: data.form.action,
data: data.field, data: data.field,
success: function (res) { success: function (res) {
if (res.msg) { if (res.msg) {
layer.msg(res.msg, {icon: 1}); layer.msg(res.msg, {icon: 1, time: 1500});
} }
if (res.location) { if (res.location) {
var target = res.target || 'self'; var target = res.target || 'self';
@ -66,13 +67,14 @@ layui.use(['jquery', 'form', 'element', 'layer', 'kgDropdown'], function () {
} else { } else {
window.location.href = res.location; window.location.href = res.location;
} }
}, 1500); }, 1000);
} else {
submit.removeAttr('disabled').removeClass('layui-btn-disabled');
} }
setTimeout(function () {
submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
}, 1500);
}, },
error: function () { error: function () {
submit.removeAttr('disabled').removeClass('layui-btn-disabled'); submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
} }
}); });
return false; return false;

View File

@ -56,14 +56,17 @@ layui.use(['jquery', 'helper'], function () {
}); });
/** /**
* 播放器中央播放按钮点击事件 * 播放器中央播放按钮
*/ */
$('#play-mask').on('click', function () { var $playMask = $('#play-mask');
$playMask.on('click', function () {
$(this).hide(); $(this).hide();
player.toggle(); player.toggle();
}); });
function start() { function start() {
$playMask.hide();
if (interval != null) { if (interval != null) {
clearInterval(interval); clearInterval(interval);
interval = null; interval = null;
@ -72,6 +75,7 @@ layui.use(['jquery', 'helper'], function () {
} }
function stop() { function stop() {
$playMask.show();
if (interval != null) { if (interval != null) {
clearInterval(interval); clearInterval(interval);
interval = null; interval = null;

View File

@ -7,6 +7,7 @@ layui.use(['jquery', 'helper'], function () {
var intervalTime = 15000; var intervalTime = 15000;
var userId = window.user.id; var userId = window.user.id;
var requestId = helper.getRequestId(); var requestId = helper.getRequestId();
var chapterId = $('input[name="chapter.id"]').val();
var planId = $('input[name="chapter.plan_id"]').val(); var planId = $('input[name="chapter.plan_id"]').val();
var lastPosition = $('input[name="chapter.position"]').val(); var lastPosition = $('input[name="chapter.position"]').val();
var learningUrl = $('input[name="chapter.learning_url"]').val(); var learningUrl = $('input[name="chapter.learning_url"]').val();
@ -29,8 +30,6 @@ layui.use(['jquery', 'helper'], function () {
} }
}); });
console.log(quality)
var player = new DPlayer({ var player = new DPlayer({
container: document.getElementById('player'), container: document.getElementById('player'),
video: { video: {
@ -52,22 +51,39 @@ layui.use(['jquery', 'helper'], function () {
}); });
/** /**
* 播放器中央播放按钮点击事件 * 播放器中央播放按钮
*/ */
$('#play-mask').on('click', function () { var $playMask = $('#play-mask');
$playMask.on('click', function () {
$(this).hide(); $(this).hide();
player.toggle(); player.toggle();
}); });
var position = parseInt(lastPosition); var position = getLastPosition();
/** /**
* 过于接近结束位置当作已结束处理 * 上次播放位置
*/ */
if (position > 0 && player.video.duration - position > 10) { if (position > 0) {
player.seek(position); 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() { function clearLearningInterval() {
if (interval != null) { if (interval != null) {
clearInterval(interval); clearInterval(interval);
@ -80,20 +96,24 @@ layui.use(['jquery', 'helper'], function () {
} }
function play() { function play() {
$playMask.hide();
clearLearningInterval(); clearLearningInterval();
setLearningInterval(); setLearningInterval();
} }
function pause() { function pause() {
$playMask.show();
clearLearningInterval(); clearLearningInterval();
} }
function ended() { function ended() {
clearLearningInterval();
learning(); learning();
setLastPosition(0);
clearLearningInterval();
} }
function learning() { function learning() {
setLastPosition(player.video.currentTime);
if (userId !== '0' && planId !== '0') { if (userId !== '0' && planId !== '0') {
$.ajax({ $.ajax({
type: 'POST', type: 'POST',

View File

@ -68,14 +68,15 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () {
form.on('submit(go)', function (data) { form.on('submit(go)', function (data) {
var submit = $(this); var submit = $(this);
submit.attr('disabled', 'disabled').addClass('layui-btn-disabled'); var orgText = $(this).text();
submit.text('提交中···').attr('disabled', 'disabled').addClass('layui-btn-disabled');
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: data.form.action, url: data.form.action,
data: data.field, data: data.field,
success: function (res) { success: function (res) {
if (res.msg) { if (res.msg) {
layer.msg(res.msg, {icon: 1}); layer.msg(res.msg, {icon: 1, time: 1500});
} }
if (res.location) { if (res.location) {
var target = res.target || 'self'; var target = res.target || 'self';
@ -85,13 +86,14 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () {
} else { } else {
window.location.href = res.location; window.location.href = res.location;
} }
}, 1500); }, 1000);
} else {
submit.removeAttr('disabled').removeClass('layui-btn-disabled');
} }
setTimeout(function () {
submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
}, 1500);
}, },
error: function () { error: function () {
submit.removeAttr('disabled').removeClass('layui-btn-disabled'); submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
} }
}); });
return false; return false;