function ($query) { $query->with(['subLinks' => function ($q) { $q->limit(12)->order('click_count', 'desc'); }]); }, 'links' => function ($query) { // 首页不按二级分组,直接展示该一级分类下的全部链接(含已归属二级的) $query->where('status', 1)->order('click_count', 'desc')->limit(10); }, ])->where('pid', 0)->where('status', 1)->order('sort', 'desc')->select(); $hotspot = LinksModel::where('is_hot', 1)->where('status', 1)->limit(18)->order('click_count', 'desc')->select(); $links = LinksModel::where('is_recommend', 1)->where('status', 1)->limit(10)->order('sort', 'desc')->select(); $this->view->assign('hotspot', $hotspot); $this->view->assign('data', $data); $this->view->assign('links', $links); $this->view->assign('config', $this->siteConfig()); $seo = $this->assignSeo(); $domain = $this->request->domain(); // 首页 JSON-LD:WebSite + SearchAction(搜索引擎站内搜索直达框) $this->view->assign('jsonld', json_encode([ '@context' => 'https://schema.org', '@type' => 'WebSite', 'name' => $seo['title'], 'description' => $seo['description'], 'url' => $domain . '/haonav/index.html', 'potentialAction' => [ '@type' => 'SearchAction', 'target' => $domain . '/haonav/search.html?q={search_term_string}', 'query-input' => 'required name=search_term_string', ], ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); $this->assignAds(); return $this->view->fetch(); } /** * 热门排行榜(按点击量) */ public function rank() { $list = LinksModel::where('status', 1) ->order('click_count', 'desc') ->limit(50) ->select(); $this->view->assign('list', $list); $this->view->assign('config', $this->siteConfig()); $this->assignSeo(); return $this->view->fetch('rank'); } }