tsurumure 5 сар өмнө
parent
commit
145e4b6f74

+ 10 - 0
src/main/java/com/backendsys/modules/cms/template/IndexViewController.java

@@ -3,13 +3,20 @@ package com.backendsys.modules.cms.template;
 import cn.hutool.core.convert.Convert;
 import com.backendsys.modules.common.aspect.Pages;
 import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 
+import java.util.Locale;
+
 @Controller
 public class IndexViewController {
 
+    @Autowired
+    private MessageSource messageSource;
+
     @Pages
     @GetMapping({"/"})
     public String index(Model model, HttpServletRequest request) {
@@ -34,6 +41,9 @@ public class IndexViewController {
 //        model.addAttribute("articleList2", list2);
 
         // -- Layout ---------------------------------------------
+        String titleTranslate = messageSource.getMessage("index.title", null, new Locale(lang));
+        model.addAttribute("title", titleTranslate);
+
         model.addAttribute("layout", "index");
         return "layout/layout";
     }

+ 1 - 0
src/main/resources/i18n/locale_en.properties

@@ -9,6 +9,7 @@ top.welcome = Welcome to consult, WeChat ID:
 index.section1.title = Newest
 index.section2.title = HOT REVIEWS
 
+index.title = Homepage
 article.title = Article
 articleDetail.title = Article Detail
 page.title = Page

+ 1 - 0
src/main/resources/i18n/locale_zh.properties

@@ -9,6 +9,7 @@ top.welcome = 欢迎咨询,微信号:
 index.section1.title = 最新评测
 index.section2.title = 热门评测
 
+index.title = 首页
 article.title = 资讯中心
 articleDetail.title = 资讯详情
 page.title = 内容中心

+ 1 - 1
src/main/resources/templates/article.html

@@ -62,7 +62,7 @@
             <ul id="category-bar">
               <li class="mb-4"><a href="/article/list" th:classappend="${parameters.category_id == null ? 'active' : ''}">全部</a></li>
               <li th:each="item, itemStat : ${articleCategoryList}">
-                <a th:href="@{'/article/list?category_id=' + ${item.article_category_id}}" th:text="${lang} == 'zh' ? ${item.category_name} : ${item.category_name_en}" th:data-category-id="${item.article_category_id}"
+                <a th:href="@{'/article/list?category_id=' + ${item.article_category_id}}" th:text="${item.category_name}" th:data-category-id="${item.article_category_id}"
                    th:classappend="(${item.article_category_id} == ${parameters.category_id} ? 'active' : '')"></a>
               </li>
             </ul>

+ 5 - 1
src/main/resources/templates/layout/layout-top.html

@@ -1,3 +1,7 @@
 <div th:fragment="layout-top" class="hjcl-layout-top">
-  top
+  <div class="wrapper">
+    <div class="text-xs">
+      <div th:replace="~{components/language::language}"></div>
+    </div>
+  </div>
 </div>