- {% for chapter in chapters %}
- {% set show_class = (show_all or loop.first) ? 'layui-show' : '' %}
-
+ {% else %}
+ {{ show_lesson_list(chapters[0]) }}
+ {% endif %}
{% endif %}
\ No newline at end of file
diff --git a/app/Http/Home/Views/question/list.volt b/app/Http/Home/Views/question/list.volt
index a6d0d3ab..d5455c69 100644
--- a/app/Http/Home/Views/question/list.volt
+++ b/app/Http/Home/Views/question/list.volt
@@ -4,8 +4,8 @@
{% set sort_val = request.get('sort','trim','latest') %}
{% set pager_url = url({'for':'home.question.pager'}, params) %}
- {% set hot_questions_url = url({'for':'home.widget.hot_questions'}) %}
- {% set top_answerers_url = url({'for':'home.widget.top_answerers'}) %}
+ {% set hot_questions_url = url({'for':'home.widget.hot_questions'},{'limit':10}) %}
+ {% set top_answerers_url = url({'for':'home.widget.top_answerers'},{'limit':5}) %}
{% set my_tags_url = url({'for':'home.widget.my_tags'},{'type':'question'}) %}
diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php
index 1ea13df1..70774c80 100644
--- a/app/Library/AppInfo.php
+++ b/app/Library/AppInfo.php
@@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://www.koogua.com';
- protected $version = '1.6.0';
+ protected $version = '1.6.2';
public function __get($name)
{
@@ -28,6 +28,8 @@ class AppInfo
if (isset($this->{$name})) {
return $this->{$name};
}
+
+ return null;
}
}
\ No newline at end of file
diff --git a/app/Library/Utils/ServerInfo.php b/app/Library/Utils/ServerInfo.php
index ea3603fa..4d8b6b4f 100644
--- a/app/Library/Utils/ServerInfo.php
+++ b/app/Library/Utils/ServerInfo.php
@@ -31,13 +31,13 @@ class ServerInfo
$total = 0;
- if (preg_match('/MemTotal\:\s+(\d+) kB/', $mem, $totalMatches)) {
+ if (preg_match('/MemTotal:\s+(\d+) kB/', $mem, $totalMatches)) {
$total = $totalMatches[1];
}
$free = 0;
- if (preg_match('/MemFree\:\s+(\d+) kB/', $mem, $freeMatches)) {
+ if (preg_match('/MemFree:\s+(\d+) kB/', $mem, $freeMatches)) {
$free = $freeMatches[1];
}
diff --git a/app/Repos/Answer.php b/app/Repos/Answer.php
index 0ce29044..0cb6f54a 100644
--- a/app/Repos/Answer.php
+++ b/app/Repos/Answer.php
@@ -61,6 +61,9 @@ class Answer extends Repository
case 'accepted':
$orderBy = 'accepted DESC, like_count DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Article.php b/app/Repos/Article.php
index edd513a7..56b58923 100644
--- a/app/Repos/Article.php
+++ b/app/Repos/Article.php
@@ -112,6 +112,9 @@ class Article extends Repository
case 'popular':
$orderBy = 'score DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/ArticleFavorite.php b/app/Repos/ArticleFavorite.php
index ec43be57..b6591218 100644
--- a/app/Repos/ArticleFavorite.php
+++ b/app/Repos/ArticleFavorite.php
@@ -35,6 +35,9 @@ class ArticleFavorite extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Audit.php b/app/Repos/Audit.php
index 7530db31..5d6fd238 100644
--- a/app/Repos/Audit.php
+++ b/app/Repos/Audit.php
@@ -51,6 +51,9 @@ class Audit extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Chapter.php b/app/Repos/Chapter.php
index e98fcc62..8f1e63e1 100644
--- a/app/Repos/Chapter.php
+++ b/app/Repos/Chapter.php
@@ -99,6 +99,9 @@ class Chapter extends Repository
*/
public function findByFileId($fileId)
{
+ /**
+ * @var ChapterVodModel $vod
+ */
$vod = ChapterVodModel::findFirst([
'conditions' => 'file_id = :file_id:',
'bind' => ['file_id' => $fileId],
diff --git a/app/Repos/ChapterLive.php b/app/Repos/ChapterLive.php
index a947274e..83eb5da8 100644
--- a/app/Repos/ChapterLive.php
+++ b/app/Repos/ChapterLive.php
@@ -15,7 +15,7 @@ use Phalcon\Mvc\Model;
class ChapterLive extends Repository
{
- public function paginate($where = [], $sort = 'latest', $page = 1, $limit = 15)
+ public function paginate($where = [], $sort = 'oldest', $page = 1, $limit = 15)
{
$builder = $this->modelsManager->createBuilder();
@@ -44,6 +44,9 @@ class ChapterLive extends Repository
}
switch ($sort) {
+ case 'latest':
+ $orderBy = 'cl.start_time DESC';
+ break;
default:
$orderBy = 'cl.start_time ASC';
break;
diff --git a/app/Repos/Comment.php b/app/Repos/Comment.php
index 92923892..d2431c02 100644
--- a/app/Repos/Comment.php
+++ b/app/Repos/Comment.php
@@ -68,6 +68,9 @@ class Comment extends Repository
case 'popular':
$orderBy = 'like_count DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Consult.php b/app/Repos/Consult.php
index a95dcfed..c1a87dda 100644
--- a/app/Repos/Consult.php
+++ b/app/Repos/Consult.php
@@ -65,6 +65,9 @@ class Consult extends Repository
case 'priority':
$orderBy = 'priority ASC, id DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Course.php b/app/Repos/Course.php
index 93693f75..2188992e 100644
--- a/app/Repos/Course.php
+++ b/app/Repos/Course.php
@@ -127,6 +127,9 @@ class Course extends Repository
case 'popular':
$orderBy = 'user_count DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/CourseFavorite.php b/app/Repos/CourseFavorite.php
index cfa69092..9915136f 100644
--- a/app/Repos/CourseFavorite.php
+++ b/app/Repos/CourseFavorite.php
@@ -35,6 +35,9 @@ class CourseFavorite extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/CourseTopic.php b/app/Repos/CourseTopic.php
index 4d6aa10b..32bf4b64 100644
--- a/app/Repos/CourseTopic.php
+++ b/app/Repos/CourseTopic.php
@@ -34,6 +34,9 @@ class CourseTopic extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/CourseUser.php b/app/Repos/CourseUser.php
index 3afa19bf..613d1b2f 100644
--- a/app/Repos/CourseUser.php
+++ b/app/Repos/CourseUser.php
@@ -45,6 +45,9 @@ class CourseUser extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Danmu.php b/app/Repos/Danmu.php
index 18c50f5b..d5b03c93 100644
--- a/app/Repos/Danmu.php
+++ b/app/Repos/Danmu.php
@@ -49,6 +49,9 @@ class Danmu extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/FlashSale.php b/app/Repos/FlashSale.php
index 639b718d..f17085ea 100644
--- a/app/Repos/FlashSale.php
+++ b/app/Repos/FlashSale.php
@@ -66,6 +66,9 @@ class FlashSale extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Learning.php b/app/Repos/Learning.php
index 1dd79739..b526a70d 100644
--- a/app/Repos/Learning.php
+++ b/app/Repos/Learning.php
@@ -39,6 +39,9 @@ class Learning extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Order.php b/app/Repos/Order.php
index ea2b0dbd..0e670e03 100644
--- a/app/Repos/Order.php
+++ b/app/Repos/Order.php
@@ -78,6 +78,9 @@ class Order extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Package.php b/app/Repos/Package.php
index cac9bf52..bf560860 100644
--- a/app/Repos/Package.php
+++ b/app/Repos/Package.php
@@ -43,6 +43,9 @@ class Package extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Page.php b/app/Repos/Page.php
index b5355bef..90d1c1ab 100644
--- a/app/Repos/Page.php
+++ b/app/Repos/Page.php
@@ -37,6 +37,9 @@ class Page extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/PointGift.php b/app/Repos/PointGift.php
index c0c75279..f57ad4f7 100644
--- a/app/Repos/PointGift.php
+++ b/app/Repos/PointGift.php
@@ -52,6 +52,9 @@ class PointGift extends Repository
case 'popular':
$orderBy = 'redeem_count DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/PointGiftRedeem.php b/app/Repos/PointGiftRedeem.php
index c73d5cb7..9aa39b33 100644
--- a/app/Repos/PointGiftRedeem.php
+++ b/app/Repos/PointGiftRedeem.php
@@ -39,6 +39,9 @@ class PointGiftRedeem extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/PointHistory.php b/app/Repos/PointHistory.php
index 8bb0f619..c5a54d14 100644
--- a/app/Repos/PointHistory.php
+++ b/app/Repos/PointHistory.php
@@ -41,6 +41,9 @@ class PointHistory extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Question.php b/app/Repos/Question.php
index 7b3d29ff..610a5899 100644
--- a/app/Repos/Question.php
+++ b/app/Repos/Question.php
@@ -105,6 +105,9 @@ class Question extends Repository
case 'score':
$orderBy = 'score DESC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/QuestionFavorite.php b/app/Repos/QuestionFavorite.php
index e0834171..f4d64f3d 100644
--- a/app/Repos/QuestionFavorite.php
+++ b/app/Repos/QuestionFavorite.php
@@ -35,6 +35,9 @@ class QuestionFavorite extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Refund.php b/app/Repos/Refund.php
index 3c1e0315..bc18f914 100644
--- a/app/Repos/Refund.php
+++ b/app/Repos/Refund.php
@@ -53,6 +53,9 @@ class Refund extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Report.php b/app/Repos/Report.php
index 3d11b26a..b0b9942c 100644
--- a/app/Repos/Report.php
+++ b/app/Repos/Report.php
@@ -49,6 +49,9 @@ class Report extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Review.php b/app/Repos/Review.php
index 6c76c05b..42b9424e 100644
--- a/app/Repos/Review.php
+++ b/app/Repos/Review.php
@@ -64,6 +64,9 @@ class Review extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Tag.php b/app/Repos/Tag.php
index 9d9b9b32..0d53979c 100644
--- a/app/Repos/Tag.php
+++ b/app/Repos/Tag.php
@@ -50,6 +50,9 @@ class Tag extends Repository
case 'priority':
$orderBy = 'priority ASC, id ASC';
break;
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/TagFollow.php b/app/Repos/TagFollow.php
index e572a82a..03ce2731 100644
--- a/app/Repos/TagFollow.php
+++ b/app/Repos/TagFollow.php
@@ -32,6 +32,9 @@ class TagFollow extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/TeacherConsult.php b/app/Repos/TeacherConsult.php
index a53fc888..cc9025e2 100644
--- a/app/Repos/TeacherConsult.php
+++ b/app/Repos/TeacherConsult.php
@@ -41,6 +41,9 @@ class TeacherConsult extends Repository
$builder->andWhere('c.deleted = 0');
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'c.id ASC';
+ break;
default:
$orderBy = 'c.id DESC';
break;
diff --git a/app/Repos/Topic.php b/app/Repos/Topic.php
index c6e80a91..3ab32d11 100644
--- a/app/Repos/Topic.php
+++ b/app/Repos/Topic.php
@@ -43,6 +43,9 @@ class Topic extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/Trade.php b/app/Repos/Trade.php
index 9debebc0..1dfd7470 100644
--- a/app/Repos/Trade.php
+++ b/app/Repos/Trade.php
@@ -69,6 +69,9 @@ class Trade extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Repos/User.php b/app/Repos/User.php
index 75cf7d0d..c2a3e908 100644
--- a/app/Repos/User.php
+++ b/app/Repos/User.php
@@ -69,6 +69,9 @@ class User extends Repository
}
switch ($sort) {
+ case 'oldest':
+ $orderBy = 'id ASC';
+ break;
default:
$orderBy = 'id DESC';
break;
diff --git a/app/Services/DingTalkNotice.php b/app/Services/DingTalkNotice.php
index 1fc06a4d..713f6115 100644
--- a/app/Services/DingTalkNotice.php
+++ b/app/Services/DingTalkNotice.php
@@ -170,7 +170,7 @@ class DingTalkNotice extends Service
$result = $content['errcode'] == 0;
- if ($result == false) {
+ if (!$result) {
$this->logger->error('Send Message Failed ' . kg_json_encode($content));
}
diff --git a/app/Services/EditorStorage.php b/app/Services/EditorStorage.php
new file mode 100644
index 00000000..10fb488d
--- /dev/null
+++ b/app/Services/EditorStorage.php
@@ -0,0 +1,159 @@
+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('/
)
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';
+ }
+
+}
\ No newline at end of file
diff --git a/app/Services/Logic/Article/TopAuthorList.php b/app/Services/Logic/Article/TopAuthorList.php
index 1f4733da..100fa864 100644
--- a/app/Services/Logic/Article/TopAuthorList.php
+++ b/app/Services/Logic/Article/TopAuthorList.php
@@ -15,11 +15,17 @@ class TopAuthorList extends LogicService
public function handle()
{
+ $limit = $this->request->getQuery('limit', 'int', 10);
+
$cache = new TopAuthorListCache();
- $result = $cache->get();
+ $list = $cache->get();
- return $result ?: [];
+ if($limit < count($list)) {
+ $list = array_slice($list, $limit);
+ }
+
+ return $list;
}
}
diff --git a/app/Services/Logic/Notice/External/AccountLogin.php b/app/Services/Logic/Notice/External/AccountLogin.php
index a98aa06d..3b146df7 100644
--- a/app/Services/Logic/Notice/External/AccountLogin.php
+++ b/app/Services/Logic/Notice/External/AccountLogin.php
@@ -34,10 +34,8 @@ class AccountLogin extends LogicService
$subscribe = $subscribeRepo->findByUserId($userId);
if ($subscribe) {
-
$notice = new WeChatAccountLoginNotice();
-
- return $notice->handle($subscribe, $params);
+ $notice->handle($subscribe, $params);
}
}
diff --git a/app/Services/Logic/PointGiftTrait.php b/app/Services/Logic/PointGiftTrait.php
index 8750b552..c81a577e 100644
--- a/app/Services/Logic/PointGiftTrait.php
+++ b/app/Services/Logic/PointGiftTrait.php
@@ -19,7 +19,7 @@ trait PointGiftTrait
return $validator->checkPointGift($id);
}
- public function checkFlashSaleCache($id)
+ public function checkPointGiftCache($id)
{
$validator = new PointGiftValidator();
diff --git a/app/Services/Logic/Question/HotQuestionList.php b/app/Services/Logic/Question/HotQuestionList.php
index b284d966..8dc4c67b 100644
--- a/app/Services/Logic/Question/HotQuestionList.php
+++ b/app/Services/Logic/Question/HotQuestionList.php
@@ -15,11 +15,17 @@ class HotQuestionList extends LogicService
public function handle()
{
+ $limit = $this->request->getQuery('limit', 'int', 10);
+
$cache = new HotQuestionListCache();
- $result = $cache->get();
+ $list = $cache->get();
- return $result ?: [];
+ if($limit < count($list)) {
+ $list = array_slice($list, $limit);
+ }
+
+ return $list;
}
}
diff --git a/app/Services/Logic/Question/TopAnswererList.php b/app/Services/Logic/Question/TopAnswererList.php
index 46949f00..e00fe03a 100644
--- a/app/Services/Logic/Question/TopAnswererList.php
+++ b/app/Services/Logic/Question/TopAnswererList.php
@@ -15,11 +15,17 @@ class TopAnswererList extends LogicService
public function handle()
{
+ $limit = $this->request->getQuery('limit', 'int', 10);
+
$cache = new TopAnswererListCache();
- $result = $cache->get();
+ $list = $cache->get();
- return $result ?: [];
+ if($limit < count($list)) {
+ $list = array_slice($list, $limit);
+ }
+
+ return $list;
}
}
diff --git a/app/Services/Logic/User/Console/NotificationRead.php b/app/Services/Logic/User/Console/NotificationRead.php
index d33c5f20..5389db2a 100644
--- a/app/Services/Logic/User/Console/NotificationRead.php
+++ b/app/Services/Logic/User/Console/NotificationRead.php
@@ -17,6 +17,12 @@ class NotificationRead extends LogicService
{
$user = $this->getLoginUser();
+ if ($user->notice_count == 0) return;
+
+ $user->notice_count = 0;
+
+ $user->update();
+
$notifyRepo = new NotificationRepo();
$notifyRepo->markAllAsViewed($user->id);
diff --git a/app/Services/MyStorage.php b/app/Services/MyStorage.php
index 34729ccc..2ddc1927 100644
--- a/app/Services/MyStorage.php
+++ b/app/Services/MyStorage.php
@@ -183,58 +183,6 @@ class MyStorage extends Storage
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) {
- if ($this->checkFile($file->getRealType(), $mimeType) == false) {
+ if (!$this->checkFile($file->getRealType(), $mimeType)) {
continue;
}
@@ -264,7 +212,7 @@ class MyStorage extends Storage
$upload = $uploadRepo->findByMd5($md5);
- if ($upload == false) {
+ if (!$upload) {
$name = $this->filter->sanitize($file->getName(), ['trim', 'string']);
diff --git a/app/Services/Smser.php b/app/Services/Smser.php
index 8d470a08..e13fb608 100644
--- a/app/Services/Smser.php
+++ b/app/Services/Smser.php
@@ -91,7 +91,7 @@ abstract class Smser extends Service
$result = $sendStatus->getCode() == 'Ok';
- if ($result == false) {
+ if (!$result) {
$this->logger->error('Send Message Failed ' . $response->toJsonString());
}
diff --git a/app/Services/Throttle.php b/app/Services/Throttle.php
index 63dd715c..77bc8cbc 100644
--- a/app/Services/Throttle.php
+++ b/app/Services/Throttle.php
@@ -14,7 +14,7 @@ class Throttle extends Service
{
$config = $this->getConfig();
- if ($config->path('throttle.enabled') == false) {
+ if (!$config->path('throttle.enabled')) {
return true;
}
diff --git a/app/Services/Vod.php b/app/Services/Vod.php
index 9e5af267..b48cc93f 100644
--- a/app/Services/Vod.php
+++ b/app/Services/Vod.php
@@ -172,29 +172,25 @@ class Vod extends Service
$expiredTime = base_convert(time() + $expiry, 10, 16);
$tryTime = 0; // 试看时间,0不限制
- $ipLimit = 0; // ip数量限制,0不限制
- $random = rand(100000, 999999); // 随机数
+ $ipLimit = 9; // ip数量限制,0不限制
+ $random = uniqid(); // 随机数
/**
* 腾讯坑爹的参数类型和文档,先凑合吧
* 不限制试看 => 必须exper=0(不能设置为空)
- * 不限制IP => 必须rlimit为空(不能设置为0),暂不可用
+ * 不限制IP => 必须rlimit为空(不能设置为0)
*/
- $myTryTime = $tryTime >= 0 ? $tryTime : 0;
- $myIpLimit = $ipLimit > 0 ? $ipLimit : '';
+ $myTryTime = $tryTime;
+ $myIpLimit = $ipLimit;
$sign = $key . $dirName . $expiredTime . $myTryTime . $myIpLimit . $random;
$query = [];
$query['t'] = $expiredTime;
- if ($tryTime >= 0) {
- $query['exper'] = $tryTime;
- }
+ $query['exper'] = $myTryTime;
- if ($ipLimit > 0) {
- $query['rlimit'] = $ipLimit;
- }
+ $query['rlimit'] = $myIpLimit;
$query['us'] = $random;
diff --git a/app/Services/WeChatNotice.php b/app/Services/WeChatNotice.php
index a6304ac3..7af1a140 100644
--- a/app/Services/WeChatNotice.php
+++ b/app/Services/WeChatNotice.php
@@ -70,7 +70,7 @@ abstract class WeChatNotice extends Service
$result = $response['errcode'] == 0;
- if ($result == false) {
+ if (!$result) {
$this->logger->error('Send Template Message Failed ' . kg_json_encode($response));
}
diff --git a/app/Validators/Answer.php b/app/Validators/Answer.php
index 32a3fbe7..bb1099a4 100644
--- a/app/Validators/Answer.php
+++ b/app/Validators/Answer.php
@@ -15,6 +15,7 @@ use App\Models\Reason as ReasonModel;
use App\Models\User as UserModel;
use App\Repos\Answer as AnswerRepo;
use App\Repos\Question as QuestionRepo;
+use App\Services\EditorStorage as EditorStorageService;
class Answer extends Validator
{
@@ -58,6 +59,10 @@ class Answer extends Validator
{
$value = $this->filter->sanitize($content, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length < 10) {
diff --git a/app/Validators/Article.php b/app/Validators/Article.php
index 9656b652..9987d097 100644
--- a/app/Validators/Article.php
+++ b/app/Validators/Article.php
@@ -14,6 +14,7 @@ use App\Library\Validators\Common as CommonValidator;
use App\Models\Article as ArticleModel;
use App\Models\Reason as ReasonModel;
use App\Repos\Article as ArticleRepo;
+use App\Services\EditorStorage as EditorStorageService;
class Article extends Validator
{
@@ -94,6 +95,10 @@ class Article extends Validator
{
$value = $this->filter->sanitize($content, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length < 10) {
diff --git a/app/Validators/Course.php b/app/Validators/Course.php
index eda4d6ff..b562d98f 100644
--- a/app/Validators/Course.php
+++ b/app/Validators/Course.php
@@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator;
use App\Models\Course as CourseModel;
use App\Repos\Course as CourseRepo;
+use App\Services\EditorStorage as EditorStorageService;
class Course extends Validator
{
@@ -119,6 +120,10 @@ class Course extends Validator
{
$value = $this->filter->sanitize($details, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length > 30000) {
diff --git a/app/Validators/Help.php b/app/Validators/Help.php
index 95d567ab..c5acab63 100644
--- a/app/Validators/Help.php
+++ b/app/Validators/Help.php
@@ -12,6 +12,7 @@ use App\Caches\MaxHelpId as MaxHelpIdCache;
use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Help as HelpModel;
use App\Repos\Help as HelpRepo;
+use App\Services\EditorStorage as EditorStorageService;
class Help extends Validator
{
@@ -90,6 +91,10 @@ class Help extends Validator
{
$value = $this->filter->sanitize($content, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length < 10) {
diff --git a/app/Validators/Page.php b/app/Validators/Page.php
index fa222509..2080d7a6 100644
--- a/app/Validators/Page.php
+++ b/app/Validators/Page.php
@@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator;
use App\Models\Page as PageModel;
use App\Repos\Page as PageRepo;
+use App\Services\EditorStorage as EditorStorageService;
class Page extends Validator
{
@@ -124,6 +125,10 @@ class Page extends Validator
{
$value = $this->filter->sanitize($content, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length < 10) {
diff --git a/app/Validators/PointGift.php b/app/Validators/PointGift.php
index 5c1460ca..4f7e30b1 100644
--- a/app/Validators/PointGift.php
+++ b/app/Validators/PointGift.php
@@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator;
use App\Models\PointGift as PointGiftModel;
use App\Repos\PointGift as PointGiftRepo;
+use App\Services\EditorStorage as EditorStorageService;
class PointGift extends Validator
{
@@ -86,6 +87,10 @@ class PointGift extends Validator
{
$value = $this->filter->sanitize($details, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length > 30000) {
diff --git a/app/Validators/Question.php b/app/Validators/Question.php
index 1481868c..84d1e98d 100644
--- a/app/Validators/Question.php
+++ b/app/Validators/Question.php
@@ -13,6 +13,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Question as QuestionModel;
use App\Models\Reason as ReasonModel;
use App\Repos\Question as QuestionRepo;
+use App\Services\EditorStorage as EditorStorageService;
class Question extends Validator
{
@@ -106,6 +107,10 @@ class Question extends Validator
{
$value = $this->filter->sanitize($content, ['trim']);
+ $storage = new EditorStorageService();
+
+ $value = $storage->handle($value);
+
$length = kg_strlen($value);
if ($length > 30000) {
diff --git a/app/Validators/Review.php b/app/Validators/Review.php
index 56a7f096..b5faf25f 100644
--- a/app/Validators/Review.php
+++ b/app/Validators/Review.php
@@ -54,7 +54,7 @@ class Review extends Validator
public function checkRating($rating)
{
- if (!in_array($rating, [1, 2, 3, 4, 5])) {
+ if ($rating < 1 || $rating > 5) {
throw new BadRequestException('review.invalid_rating');
}
diff --git a/composer.lock b/composer.lock
index cc68e67a..2fffa2d1 100644
--- a/composer.lock
+++ b/composer.lock
@@ -2366,16 +2366,16 @@
},
{
"name": "qcloud/cos-sdk-v5",
- "version": "v2.5.6",
+ "version": "v2.6.1",
"source": {
"type": "git",
"url": "https://github.com/tencentyun/cos-php-sdk-v5.git",
- "reference": "607ee49d372a799964206b6ae0a9eb2816201c42"
+ "reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/607ee49d372a799964206b6ae0a9eb2816201c42",
- "reference": "607ee49d372a799964206b6ae0a9eb2816201c42",
+ "url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/d367ba8d0305b83364b64055594a0ac22b1cefd8",
+ "reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8",
"shasum": "",
"mirrors": [
{
@@ -2433,9 +2433,9 @@
],
"support": {
"issues": "https://github.com/tencentyun/cos-php-sdk-v5/issues",
- "source": "https://github.com/tencentyun/cos-php-sdk-v5/tree/v2.5.6"
+ "source": "https://github.com/tencentyun/cos-php-sdk-v5/tree/v2.6.1"
},
- "time": "2022-06-07T14:49:19+00:00"
+ "time": "2023-02-07T09:49:12+00:00"
},
{
"name": "ralouphie/getallheaders",
@@ -2489,16 +2489,16 @@
},
{
"name": "robmorgan/phinx",
- "version": "0.12.12",
+ "version": "0.12.13",
"source": {
"type": "git",
"url": "https://github.com/cakephp/phinx.git",
- "reference": "9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115"
+ "reference": "6eb0f295e140ed2804d93396755f0ce9ada4ec07"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/cakephp/phinx/zipball/9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115",
- "reference": "9a6ce1e7fdf0fa4e602ba5875b5bc9442ccaa115",
+ "url": "https://api.github.com/repos/cakephp/phinx/zipball/6eb0f295e140ed2804d93396755f0ce9ada4ec07",
+ "reference": "6eb0f295e140ed2804d93396755f0ce9ada4ec07",
"shasum": "",
"mirrors": [
{
@@ -2575,9 +2575,9 @@
],
"support": {
"issues": "https://github.com/cakephp/phinx/issues",
- "source": "https://github.com/cakephp/phinx/tree/0.12.12"
+ "source": "https://github.com/cakephp/phinx/tree/0.12.13"
},
- "time": "2022-07-09T18:53:51+00:00"
+ "time": "2022-10-03T04:57:40+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@@ -4910,16 +4910,16 @@
},
{
"name": "tencentcloud/tencentcloud-sdk-php",
- "version": "3.0.731",
+ "version": "3.0.824",
"source": {
"type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
- "reference": "a247a556c120dd7dd95db40035edcde7271fe40d"
+ "reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/a247a556c120dd7dd95db40035edcde7271fe40d",
- "reference": "a247a556c120dd7dd95db40035edcde7271fe40d",
+ "url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5",
+ "reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5",
"shasum": "",
"mirrors": [
{
@@ -4957,9 +4957,9 @@
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
- "source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.731"
+ "source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.824"
},
- "time": "2022-09-21T00:09:54+00:00"
+ "time": "2023-02-15T00:03:58+00:00"
},
{
"name": "webmozart/assert",
@@ -5097,16 +5097,16 @@
},
{
"name": "workerman/gateway-worker",
- "version": "v3.0.25",
+ "version": "v3.0.27",
"source": {
"type": "git",
"url": "https://github.com/walkor/GatewayWorker.git",
- "reference": "5b47eb9a90c6b2afc25327979e41de352cb3c286"
+ "reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/5b47eb9a90c6b2afc25327979e41de352cb3c286",
- "reference": "5b47eb9a90c6b2afc25327979e41de352cb3c286",
+ "url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2",
+ "reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2",
"shasum": "",
"mirrors": [
{
@@ -5116,7 +5116,7 @@
]
},
"require": {
- "workerman/workerman": "^4.0.30"
+ "workerman/workerman": "^4.0.0 || ^5.0.0"
},
"type": "library",
"autoload": {
@@ -5135,7 +5135,7 @@
],
"support": {
"issues": "https://github.com/walkor/GatewayWorker/issues",
- "source": "https://github.com/walkor/GatewayWorker/tree/v3.0.25"
+ "source": "https://github.com/walkor/GatewayWorker/tree/v3.0.27"
},
"funding": [
{
@@ -5147,7 +5147,7 @@
"type": "patreon"
}
],
- "time": "2022-09-19T09:59:56+00:00"
+ "time": "2023-02-09T09:16:04+00:00"
},
{
"name": "workerman/gatewayclient",
@@ -5306,16 +5306,16 @@
},
{
"name": "yansongda/pay",
- "version": "v2.10.4",
+ "version": "v2.10.5",
"source": {
"type": "git",
"url": "https://github.com/yansongda/pay.git",
- "reference": "e378f43800f867d53ce35ee90aa17f0c3b7b5838"
+ "reference": "f7d93ed784de4ca09d3386d28139c724ddd526fc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/yansongda/pay/zipball/e378f43800f867d53ce35ee90aa17f0c3b7b5838",
- "reference": "e378f43800f867d53ce35ee90aa17f0c3b7b5838",
+ "url": "https://api.github.com/repos/yansongda/pay/zipball/f7d93ed784de4ca09d3386d28139c724ddd526fc",
+ "reference": "f7d93ed784de4ca09d3386d28139c724ddd526fc",
"shasum": "",
"mirrors": [
{
@@ -5366,7 +5366,7 @@
"issues": "https://github.com/yansongda/pay/issues",
"source": "https://github.com/yansongda/pay"
},
- "time": "2022-03-10T01:27:10+00:00"
+ "time": "2022-12-03T13:44:53+00:00"
},
{
"name": "yansongda/supports",
diff --git a/config/config.default.php b/config/config.default.php
index 41836295..2ee61586 100644
--- a/config/config.default.php
+++ b/config/config.default.php
@@ -172,4 +172,19 @@ $config['websocket']['connect_address'] = 'your_domain.com:8282';
*/
$config['websocket']['register_address'] = '127.0.0.1:1238';
+/**
+ * 资源监控: CPU负载(0.1-1.0)
+ */
+$config['server_monitor']['cpu'] = 0.8;
+
+/**
+ * 资源监控: 内存剩余占比(10-100)%
+ */
+$config['server_monitor']['memory'] = 10;
+
+/**
+ * 资源监控: 磁盘剩余占比(10-100)%
+ */
+$config['server_monitor']['disk'] = 20;
+
return $config;
diff --git a/public/static/admin/js/common.js b/public/static/admin/js/common.js
index 08a7acc6..4f4f9451 100644
--- a/public/static/admin/js/common.js
+++ b/public/static/admin/js/common.js
@@ -49,14 +49,15 @@ layui.use(['jquery', 'form', 'element', 'layer', 'kgDropdown'], function () {
form.on('submit(go)', function (data) {
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({
type: 'POST',
url: data.form.action,
data: data.field,
success: function (res) {
if (res.msg) {
- layer.msg(res.msg, {icon: 1});
+ layer.msg(res.msg, {icon: 1, time: 1500});
}
if (res.location) {
var target = res.target || 'self';
@@ -66,13 +67,14 @@ layui.use(['jquery', 'form', 'element', 'layer', 'kgDropdown'], function () {
} else {
window.location.href = res.location;
}
- }, 1500);
- } else {
- submit.removeAttr('disabled').removeClass('layui-btn-disabled');
+ }, 1000);
}
+ setTimeout(function () {
+ submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
+ }, 1500);
},
error: function () {
- submit.removeAttr('disabled').removeClass('layui-btn-disabled');
+ submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
}
});
return false;
diff --git a/public/static/home/js/chapter.live.player.js b/public/static/home/js/chapter.live.player.js
index 4a0b7487..7c0285e8 100644
--- a/public/static/home/js/chapter.live.player.js
+++ b/public/static/home/js/chapter.live.player.js
@@ -56,14 +56,17 @@ layui.use(['jquery', 'helper'], function () {
});
/**
- * 播放器中央播放按钮点击事件
+ * 播放器中央播放按钮
*/
- $('#play-mask').on('click', function () {
+ var $playMask = $('#play-mask');
+
+ $playMask.on('click', function () {
$(this).hide();
player.toggle();
});
function start() {
+ $playMask.hide();
if (interval != null) {
clearInterval(interval);
interval = null;
@@ -72,6 +75,7 @@ layui.use(['jquery', 'helper'], function () {
}
function stop() {
+ $playMask.show();
if (interval != null) {
clearInterval(interval);
interval = null;
diff --git a/public/static/home/js/chapter.vod.player.js b/public/static/home/js/chapter.vod.player.js
index c072658f..0af43dbc 100644
--- a/public/static/home/js/chapter.vod.player.js
+++ b/public/static/home/js/chapter.vod.player.js
@@ -7,6 +7,7 @@ layui.use(['jquery', 'helper'], function () {
var intervalTime = 15000;
var userId = window.user.id;
var requestId = helper.getRequestId();
+ var chapterId = $('input[name="chapter.id"]').val();
var planId = $('input[name="chapter.plan_id"]').val();
var lastPosition = $('input[name="chapter.position"]').val();
var learningUrl = $('input[name="chapter.learning_url"]').val();
@@ -29,8 +30,6 @@ layui.use(['jquery', 'helper'], function () {
}
});
- console.log(quality)
-
var player = new DPlayer({
container: document.getElementById('player'),
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();
player.toggle();
});
- var position = parseInt(lastPosition);
+ var position = getLastPosition();
/**
- * 过于接近结束位置当作已结束处理
+ * 上次播放位置
*/
- if (position > 0 && player.video.duration - position > 10) {
+ if (position > 0) {
player.seek(position);
}
+ function getPositionKey() {
+ return 'chapter:' + chapterId + ':position';
+ }
+
+ function getLastPosition() {
+ var key = getPositionKey();
+ var value = localStorage.getItem(key);
+ return value != null ? parseInt(value) : lastPosition;
+ }
+
+ function setLastPosition(value) {
+ var key = getPositionKey();
+ localStorage.setItem(key, value);
+ }
+
function clearLearningInterval() {
if (interval != null) {
clearInterval(interval);
@@ -80,20 +96,24 @@ layui.use(['jquery', 'helper'], function () {
}
function play() {
+ $playMask.hide();
clearLearningInterval();
setLearningInterval();
}
function pause() {
+ $playMask.show();
clearLearningInterval();
}
function ended() {
- clearLearningInterval();
learning();
+ setLastPosition(0);
+ clearLearningInterval();
}
function learning() {
+ setLastPosition(player.video.currentTime);
if (userId !== '0' && planId !== '0') {
$.ajax({
type: 'POST',
diff --git a/public/static/home/js/common.js b/public/static/home/js/common.js
index 67d84753..dff6dd3d 100644
--- a/public/static/home/js/common.js
+++ b/public/static/home/js/common.js
@@ -68,14 +68,15 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () {
form.on('submit(go)', function (data) {
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({
type: 'POST',
url: data.form.action,
data: data.field,
success: function (res) {
if (res.msg) {
- layer.msg(res.msg, {icon: 1});
+ layer.msg(res.msg, {icon: 1, time: 1500});
}
if (res.location) {
var target = res.target || 'self';
@@ -85,13 +86,14 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () {
} else {
window.location.href = res.location;
}
- }, 1500);
- } else {
- submit.removeAttr('disabled').removeClass('layui-btn-disabled');
+ }, 1000);
}
+ setTimeout(function () {
+ submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
+ }, 1500);
},
error: function () {
- submit.removeAttr('disabled').removeClass('layui-btn-disabled');
+ submit.text(orgText).removeAttr('disabled').removeClass('layui-btn-disabled');
}
});
return false;