1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 20:52:44 +08:00

Merge branch 'koogua/v1.6.1' into demo

This commit is contained in:
xiaochong0302 2022-12-15 10:56:22 +08:00
commit 216f7aae10
24 changed files with 168 additions and 235 deletions

View File

@ -1,3 +1,15 @@
### [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
@ -56,6 +56,8 @@ class ServerMonitorTask extends Task
if ($load[1] > $cpuCount * 0.8) { if ($load[1] > $cpuCount * 0.8) {
return sprintf("cpu负载超过%s", $load[1]); return sprintf("cpu负载超过%s", $load[1]);
} }
return null;
} }
protected function checkMemory() protected function checkMemory()
@ -64,25 +66,27 @@ 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) { if ($left < 20) {
return sprintf("memory剩余不足%s%%", round($left)); return sprintf("memory剩余不足%s%%", round($left));
} }
return null;
} }
protected function checkDisk() protected function checkDisk()
@ -95,6 +99,8 @@ class ServerMonitorTask extends Task
if ($left < 20) { if ($left < 20) {
return sprintf("disk剩余不足%s%%", round($left)); return sprintf("disk剩余不足%s%%", round($left));
} }
return null;
} }
protected function checkMysql() protected function checkMysql()
@ -111,8 +117,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 +126,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 +147,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 +155,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 +169,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 +186,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 +215,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

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

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

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

@ -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.1';
public function __get($name) public function __get($name)
{ {

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

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

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

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

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

@ -29,8 +29,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: {

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;