Procházet zdrojové kódy

Merge branch 'dev/v4.8.31_zxl' of qmx/jy into feature/v4.8.31

zhangxinlei1996 před 2 roky
rodič
revize
313f6003f0
3 změnil soubory, kde provedl 36 přidání a 23 odebrání
  1. 1 1
      src/config.json
  2. 30 3
      src/jfw/front/pcIndex.go
  3. 5 19
      src/web/templates/pc/index.html

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
src/config.json


+ 30 - 3
src/jfw/front/pcIndex.go

@@ -37,8 +37,18 @@ type PcIndex struct {
 	searchResult  xweb.Mapper `xweb:"/list/(\\w+)/(\\w+).html"` //剑鱼标讯分类 地区结果列表
 }
 
+var hotKeyArr = []string{}
+
 func init() {
 	xweb.AddAction(&PcIndex{})
+	// 每隔5分钟更新一次随机词
+	go func() {
+		hotKeyArr = GetIndexHotKey()
+		ticker := time.NewTicker(300 * time.Second)
+		for range ticker.C {
+			hotKeyArr = GetIndexHotKey()
+		}
+	}()
 }
 
 func (this PcIndex) BrandIndex() error {
@@ -107,11 +117,10 @@ func (m *PcIndex) NewSordfish(flag string) error {
 			m.T["recommend"] = ContentRecommendation()
 			//推荐标讯专区
 			m.T["recommendBeacon"] = RecommendationBeacon()
-			m.T["hasLogin"] = m.GetSession("userId") != ""
+			m.T["hasLogin"] = util.ObjToString(m.GetSession("userId")) != ""
 			m.T["includedInfo"] = GetIncludedInfo()
-			// m.T["hotKey"] = HotKey()
 			m.T["newbids"] = NewIndexbids(m.Session(), m.Request)
-
+			m.T["hotkey"] = hotKeyArr
 			return m.Render("/pc/index.html", &m.T)
 		}
 	}
@@ -616,3 +625,21 @@ func InSeoContent(arr *[]map[string]interface{}) {
 		}
 	}
 }
+
+func GetIndexHotKey() []string {
+	pcIndexHotKey := util.ObjArrToStringArr(config.Sysconfig["pcIndexHotKey"].([]interface{}))
+	pcIndexHotKeyLimit := util.Int64All(config.Sysconfig["pcIndexHotKeyLimit"])
+	// 定义一个函数,用于从数组words中随机取出几个词
+	m := map[string]bool{}
+	for _, v := range pcIndexHotKey {
+		m[v] = true
+	}
+	result := []string{}
+	for key, _ := range m {
+		result = append(result, key)
+		if len(result) == int(pcIndexHotKeyLimit) {
+			break
+		}
+	}
+	return result
+}

+ 5 - 19
src/web/templates/pc/index.html

@@ -61,25 +61,11 @@
         <div class="hot-search">
           <div class="left-tit">热门搜索</div>
           <div class="right-con">
-            <div class="a_box">
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=信息化&searchvalue=&selectType=title">信息化</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=软件&searchvalue=&selectType=title">软件</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=网络安全&searchvalue=&selectType=title">网络安全</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=监控&searchvalue=&selectType=title">监控</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=安防&searchvalue=&selectType=title">安防</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=服务器&searchvalue=&selectType=title">服务器</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=弱电&searchvalue=&selectType=title">弱电</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=智能化&searchvalue=&selectType=title">智能化</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=数据中心&searchvalue=&selectType=title">数据中心</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=大数据&searchvalue=&selectType=title">大数据</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=信息安全&searchvalue=&selectType=title">信息安全</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=计算机&searchvalue=&selectType=title">计算机</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=云计算&searchvalue=&selectType=title">云计算</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=物联网&searchvalue=&selectType=title">物联网</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=物业管理&searchvalue=&selectType=title">物业管理</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=视频监控&searchvalue=&selectType=title">视频监控</a>
-            <a href="{{if .T.hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords=物业服务&searchvalue=&selectType=title">物业服务</a>  
-            </div>
+            {{$hasLogin := .T.hasLogin}}
+            {{range $i,$v := .T.hotkey}}
+              <a href="{{if  $hasLogin}}/page_workDesktop/work-bench/page?link={{end}}/jylab/supsearch/index.html?keywords={{$v}}&searchvalue=&selectType=title">{{$v}}</a>
+            {{end}}
+
           </div>
         </div>
        </div>

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů