Explorar el Código

首页导航调整

hsun hace 2 años
padre
commit
d4db516c46
Se han modificado 2 ficheros con 11 adiciones y 15 borrados
  1. 3 13
      controllers/home.go
  2. 8 2
      models/config.go

+ 3 - 13
controllers/home.go

@@ -2,7 +2,6 @@ package controllers
 
 import (
 	"encoding/json"
-	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -596,24 +595,15 @@ func (this *HomeController) HeaderTab() {
 		return
 	}
 
-	list := make([]*models.HomeHeaderTab, 0)
+	list := new(models.HomeHeaderTabList)
 	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
 		return
 	}
-	// 搜索页
-	resp := make([]*models.HomeHeaderTab, 0)
+	resp := list.Home
 	if searchPage == 1 {
-		for i := range list {
-			if list[i].Name == "最新" {
-				continue
-			}
-			list[i].Name = fmt.Sprint("搜", list[i].Name)
-			resp = append(resp, list[i])
-		}
-	} else {
-		resp = list
+		resp = list.SearchPage
 	}
 
 	br.Ret = 200

+ 8 - 2
models/config.go

@@ -69,7 +69,13 @@ func GetHotSearch() (permission string, err error) {
 	return
 }
 
+type HomeHeaderTabList struct {
+	Home       []*HomeHeaderTab `json:"home" description:"首页"`
+	SearchPage []*HomeHeaderTab `json:"search_page" description:"搜索页"`
+}
+
 type HomeHeaderTab struct {
-	Id   int    `description:"导航ID"`
-	Name string `description:"导航名称"`
+	Id     int    `json:"id" description:"导航ID"`
+	Name   string `json:"name" description:"导航名称"`
+	IsShow bool   `json:"is_show" description:"是否展示"`
 }