diff --git a/CHANGELOG.md b/CHANGELOG.md index 84517528..aa9b28a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -### [v1.5.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.7)(2022-08-28) +### [v1.5.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.8)(2022-08-28) + +- 整理migrations +- 更新自动安装脚本 +- 优化登录/注册/忘记密码页 +- 修复移动端首页课程缓存刷新 +- sitemap条目增加过滤条件 + +### [v1.5.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.7)(2022-08-18) - 清理群组残留 - 升级腾讯云存储SDK到v2.5.6 diff --git a/app/Console/Tasks/SitemapTask.php b/app/Console/Tasks/SitemapTask.php index 68ad4e29..a9e3324e 100644 --- a/app/Console/Tasks/SitemapTask.php +++ b/app/Console/Tasks/SitemapTask.php @@ -39,6 +39,8 @@ class SitemapTask extends Task $filename = tmp_path('sitemap.xml'); + echo '------ start sitemap task ------' . PHP_EOL; + $this->addIndex(); $this->addCourses(); $this->addArticles(); @@ -50,6 +52,8 @@ class SitemapTask extends Task $this->addOthers(); $this->sitemap->build($filename); + + echo '------ end sitemap task ------' . PHP_EOL; } protected function getSiteUrl() @@ -73,6 +77,7 @@ class SitemapTask extends Task */ $courses = CourseModel::query() ->where('published = 1') + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit(500) ->execute(); @@ -92,6 +97,7 @@ class SitemapTask extends Task */ $articles = ArticleModel::query() ->where('published = :published:', ['published' => ArticleModel::PUBLISH_APPROVED]) + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit(500) ->execute(); @@ -111,6 +117,7 @@ class SitemapTask extends Task */ $questions = QuestionModel::query() ->where('published = :published:', ['published' => QuestionModel::PUBLISH_APPROVED]) + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit(500) ->execute(); @@ -128,7 +135,10 @@ class SitemapTask extends Task /** * @var Resultset|UserModel[] $teachers */ - $teachers = UserModel::query()->where('edu_role = 2')->execute(); + $teachers = UserModel::query() + ->where('edu_role = :edu_role:', ['edu_role' => UserModel::EDU_ROLE_TEACHER]) + ->andWhere('deleted = 0') + ->execute(); if ($teachers->count() == 0) return; @@ -143,7 +153,10 @@ class SitemapTask extends Task /** * @var Resultset|TopicModel[] $topics */ - $topics = TopicModel::query()->where('published = 1')->execute(); + $topics = TopicModel::query() + ->where('published = 1') + ->andWhere('deleted = 0') + ->execute(); if ($topics->count() == 0) return; @@ -158,7 +171,10 @@ class SitemapTask extends Task /** * @var Resultset|PageModel[] $pages */ - $pages = PageModel::query()->where('published = 1')->execute(); + $pages = PageModel::query() + ->where('published = 1') + ->andWhere('deleted = 0') + ->execute(); if ($pages->count() == 0) return; @@ -173,7 +189,10 @@ class SitemapTask extends Task /** * @var Resultset|HelpModel[] $helps */ - $helps = HelpModel::query()->where('published = 1')->execute(); + $helps = HelpModel::query() + ->where('published = 1') + ->andWhere('deleted = 0') + ->execute(); if ($helps->count() == 0) return; diff --git a/app/Http/Home/Controllers/AccountController.php b/app/Http/Home/Controllers/AccountController.php index 4efc598a..819e6520 100644 --- a/app/Http/Home/Controllers/AccountController.php +++ b/app/Http/Home/Controllers/AccountController.php @@ -44,32 +44,13 @@ class AccountController extends Controller $captcha = $service->getSettings('captcha'); - $this->seo->prependTitle('注册'); + $this->seo->prependTitle('用户注册'); $this->view->setVar('return_url', $returnUrl); $this->view->setVar('local_oauth', $oauthProvider['local']); $this->view->setVar('captcha', $captcha); } - /** - * @Post("/register", name="home.account.do_register") - */ - public function doRegisterAction() - { - $service = new AccountService(); - - $service->register(); - - $returnUrl = $this->request->getPost('return_url', 'string'); - - $content = [ - 'location' => $returnUrl ?: '/', - 'msg' => '注册成功', - ]; - - return $this->jsonSuccess($content); - } - /** * @Get("/login", name="home.account.login") */ @@ -96,13 +77,69 @@ class AccountController extends Controller $returnUrl = $this->request->getHTTPReferer(); - $this->seo->prependTitle('登录'); + $this->seo->prependTitle('用户登录'); $this->view->setVar('oauth_provider', $oauthProvider); $this->view->setVar('return_url', $returnUrl); $this->view->setVar('captcha', $captcha); } + /** + * @Get("/logout", name="home.account.logout") + */ + public function logoutAction() + { + $service = new AccountService(); + + $service->logout(); + + return $this->response->redirect(['for' => 'home.index']); + } + + /** + * @Get("/forget", name="home.account.forget") + */ + public function forgetAction() + { + $service = new FullH5UrlService(); + + if ($service->isMobileBrowser() && $service->h5Enabled()) { + $location = $service->getAccountForgetUrl(); + return $this->response->redirect($location); + } + + if ($this->authUser->id > 0) { + return $this->response->redirect(['for' => 'home.index']); + } + + $service = new AccountService(); + + $captcha = $service->getSettings('captcha'); + + $this->seo->prependTitle('重置密码'); + + $this->view->setVar('captcha', $captcha); + } + + /** + * @Post("/register", name="home.account.do_register") + */ + public function doRegisterAction() + { + $service = new AccountService(); + + $service->register(); + + $returnUrl = $this->request->getPost('return_url', 'string'); + + $content = [ + 'location' => $returnUrl ?: '/', + 'msg' => '注册成功', + ]; + + return $this->jsonSuccess($content); + } + /** * @Post("/password/login", name="home.account.pwd_login") */ @@ -135,44 +172,6 @@ class AccountController extends Controller return $this->jsonSuccess(['location' => $location]); } - /** - * @Get("/logout", name="home.account.logout") - */ - public function logoutAction() - { - $service = new AccountService(); - - $service->logout(); - - return $this->response->redirect(['for' => 'home.index']); - } - - /** - * @Get("/password/forget", name="home.account.forget_pwd") - */ - public function forgetPasswordAction() - { - $service = new FullH5UrlService(); - - if ($service->isMobileBrowser() && $service->h5Enabled()) { - $location = $service->getAccountForgetUrl(); - return $this->response->redirect($location); - } - - if ($this->authUser->id > 0) { - return $this->response->redirect(['for' => 'home.index']); - } - - $service = new AccountService(); - - $captcha = $service->getSettings('captcha'); - - $this->seo->prependTitle('忘记密码'); - - $this->view->pick('account/forget_password'); - $this->view->setVar('captcha', $captcha); - } - /** * @Post("/password/reset", name="home.account.reset_pwd") */ diff --git a/app/Http/Home/Services/Account.php b/app/Http/Home/Services/Account.php index 0c3f0dfc..02e771db 100644 --- a/app/Http/Home/Services/Account.php +++ b/app/Http/Home/Services/Account.php @@ -47,6 +47,15 @@ class Account extends Service { $post = $this->request->getPost(); + /** + * 使用[account|phone|email]做账户名字段兼容 + */ + if (isset($post['phone'])) { + $post['account'] = $post['phone']; + } elseif (isset($post['email'])) { + $post['account'] = $post['email']; + } + $validator = new AccountValidator(); $user = $validator->checkUserLogin($post['account'], $post['password']); @@ -74,6 +83,15 @@ class Account extends Service { $post = $this->request->getPost(); + /** + * 使用[account|phone|email]做账户名字段兼容 + */ + if (isset($post['phone'])) { + $post['account'] = $post['phone']; + } elseif (isset($post['email'])) { + $post['account'] = $post['email']; + } + $validator = new AccountValidator(); $user = $validator->checkVerifyLogin($post['account'], $post['verify_code']); diff --git a/app/Http/Home/Views/account/forget.volt b/app/Http/Home/Views/account/forget.volt new file mode 100644 index 00000000..78c3b2eb --- /dev/null +++ b/app/Http/Home/Views/account/forget.volt @@ -0,0 +1,42 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + {% set action_url = url({'for':'home.account.reset_pwd'}) %} + + + +
+
+ +
+
+ {{ partial('account/forget_by_phone') }} +
+
+ {{ partial('account/forget_by_email') }} +
+
+
+ +
+ +{% endblock %} + +{% block include_js %} + + {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} + {{ js_include('home/js/captcha.verify.phone.js') }} + {{ js_include('home/js/captcha.verify.email.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/account/forget_by_email.volt b/app/Http/Home/Views/account/forget_by_email.volt new file mode 100644 index 00000000..c203d6bd --- /dev/null +++ b/app/Http/Home/Views/account/forget_by_email.volt @@ -0,0 +1,28 @@ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ +
+
+
+
+ + + + + +
+
+
\ No newline at end of file diff --git a/app/Http/Home/Views/account/forget_by_phone.volt b/app/Http/Home/Views/account/forget_by_phone.volt new file mode 100644 index 00000000..f70b6c69 --- /dev/null +++ b/app/Http/Home/Views/account/forget_by_phone.volt @@ -0,0 +1,28 @@ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ +
+
+
+
+ + + + + +
+
+
\ No newline at end of file diff --git a/app/Http/Home/Views/account/forget_password.volt b/app/Http/Home/Views/account/forget_password.volt deleted file mode 100644 index 39cbef41..00000000 --- a/app/Http/Home/Views/account/forget_password.volt +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'templates/main.volt' %} - -{% block content %} - - - -
-
-
- - -
-
- - -
-
-
- - -
-
- -
-
-
-
- - - - - -
-
-
-
- -{% endblock %} - -{% block include_js %} - - {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} - {{ js_include('home/js/captcha.verify.js') }} - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/account/login.volt b/app/Http/Home/Views/account/login.volt index 34641c28..5bbcc1f1 100644 --- a/app/Http/Home/Views/account/login.volt +++ b/app/Http/Home/Views/account/login.volt @@ -4,7 +4,7 @@
@@ -23,9 +23,9 @@
{% if oauth_provider.qq.enabled == 1 %} diff --git a/app/Http/Home/Views/account/register.volt b/app/Http/Home/Views/account/register.volt index 4d86fdb1..ab4329cc 100644 --- a/app/Http/Home/Views/account/register.volt +++ b/app/Http/Home/Views/account/register.volt @@ -4,54 +4,33 @@ {% set register_with_phone = local_oauth.register_with_phone == 1 %} {% set register_with_email = local_oauth.register_with_email == 1 %} + {% set action_url = url({'for':'home.account.do_register'}) %} -
-