|
@@ -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
|
|
|
+}
|