From c859deec44d4b7be9241b54411b42d56e22d6e57 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Mon, 11 Dec 2023 12:38:47 +0800 Subject: [PATCH] vip.js -> vip.index.js --- .../Home/Controllers/WidgetController.php | 15 ++++++++++ app/Http/Home/Views/search/index.volt | 13 ++------- app/Http/Home/Views/search/sidebar.volt | 11 ++++++++ app/Http/Home/Views/vip/index.volt | 2 +- .../Home/Views/widget/featured_questions.volt | 4 +-- public/static/home/js/search.index.js | 28 +++++++++++++++++++ .../static/home/js/{vip.js => vip.index.js} | 0 7 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 public/static/home/js/search.index.js rename public/static/home/js/{vip.js => vip.index.js} (100%) diff --git a/app/Http/Home/Controllers/WidgetController.php b/app/Http/Home/Controllers/WidgetController.php index 1d558745..f7dd3843 100644 --- a/app/Http/Home/Controllers/WidgetController.php +++ b/app/Http/Home/Controllers/WidgetController.php @@ -9,6 +9,7 @@ namespace App\Http\Home\Controllers; use App\Caches\FeaturedArticleList as FeaturedArticleListCache; use App\Caches\FeaturedCourseList as FeaturedCourseListCache; +use App\Caches\FeaturedQuestionList as FeaturedQuestionListCache; use App\Services\Logic\Article\TopAuthorList as TopAuthorListService; use App\Services\Logic\Question\HotQuestionList as HotQuestionListService; use App\Services\Logic\Question\TopAnswererList as TopAnswererListService; @@ -63,6 +64,20 @@ class WidgetController extends Controller $this->view->setVar('articles', $articles); } + /** + * @Get("/featured/questions", name="home.widget.featured_questions") + */ + public function featuredQuestionsAction() + { + $cache = new FeaturedQuestionListCache(); + + $questions = $cache->get(); + + $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); + $this->view->pick('widget/featured_questions'); + $this->view->setVar('questions', $questions); + } + /** * @Get("/hot/questions", name="home.widget.hot_questions") */ diff --git a/app/Http/Home/Views/search/index.volt b/app/Http/Home/Views/search/index.volt index 0533bb49..7532e58c 100644 --- a/app/Http/Home/Views/search/index.volt +++ b/app/Http/Home/Views/search/index.volt @@ -57,17 +57,8 @@ {% endblock %} -{% block inline_js %} +{% block include_js %} - + {{ js_include('home/js/search.index.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/search/sidebar.volt b/app/Http/Home/Views/search/sidebar.volt index d5083cdb..9d23d64f 100644 --- a/app/Http/Home/Views/search/sidebar.volt +++ b/app/Http/Home/Views/search/sidebar.volt @@ -10,6 +10,17 @@ {% endif %} +{% if type == 'course' %} + {% set load_url = url({'for':'home.widget.featured_courses'}) %} + +{% elseif type == 'article' %} + {% set load_url = url({'for':'home.widget.featured_articles'}) %} +
+{% elseif type == 'question' %} + {% set load_url = url({'for':'home.widget.featured_questions'}) %} + +{% endif %} + {% if related_queries %}
相关搜索
diff --git a/app/Http/Home/Views/vip/index.volt b/app/Http/Home/Views/vip/index.volt index be178f65..e7fe11d7 100644 --- a/app/Http/Home/Views/vip/index.volt +++ b/app/Http/Home/Views/vip/index.volt @@ -55,6 +55,6 @@ {% block include_js %} - {{ js_include('home/js/vip.js') }} + {{ js_include('home/js/vip.index.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/widget/featured_questions.volt b/app/Http/Home/Views/widget/featured_questions.volt index 4aad80ce..ca4a2d0b 100644 --- a/app/Http/Home/Views/widget/featured_questions.volt +++ b/app/Http/Home/Views/widget/featured_questions.volt @@ -2,7 +2,7 @@
推荐问题
-