Authored by 周少峰

Merge branch 'gray'

@@ -37,19 +37,19 @@ const getStaticUrls = (currentStatics) => { @@ -37,19 +37,19 @@ const getStaticUrls = (currentStatics) => {
37 }; 37 };
38 38
39 // 关键词页面 39 // 关键词页面
40 -const keywordsPage = () => {  
41 - return redis.getAsync('golobal:yoho:seo:keywords:allIds').then(function(res) {  
42 - let page = []; 40 +const keywordsPage = (page) => {
  41 + return redis.getAsync(`global:yoho:seo:keywords:allIds:page:${page}`).then(function(res) {
  42 + let pages = [];
43 43
44 _.forEach(JSON.parse(res), val => { 44 _.forEach(JSON.parse(res), val => {
45 - page.push({ 45 + pages.push({
46 url: `https://www.yohobuy.com/chanpin/${val}.html`, 46 url: `https://www.yohobuy.com/chanpin/${val}.html`,
47 changefreq: 'daily', 47 changefreq: 'daily',
48 priority: 0.5 48 priority: 0.5
49 }); 49 });
50 }); 50 });
51 51
52 - return page; 52 + return pages;
53 }).catch(()=>{ 53 }).catch(()=>{
54 return {}; 54 return {};
55 }); 55 });
@@ -74,10 +74,16 @@ const getArticleUrls = () => { @@ -74,10 +74,16 @@ const getArticleUrls = () => {
74 }; 74 };
75 75
76 // www 地图数据 76 // www 地图数据
77 -const wwwXmlData = () => {// eslint-disable-line  
78 - return Promise.all([keywordsPage(), getStaticUrls(_.get(staticUrls, 'www')), getArticleUrls()]).then(result => {  
79 - return _.concat(result[1], result[0], result[2]);  
80 - }); 77 +const wwwXmlData = (page) => {// eslint-disable-line
  78 + if (page > 1) {
  79 + return keywordsPage(page);
  80 + } else {
  81 + return Promise.all([keywordsPage(page),
  82 + getStaticUrls(_.get(staticUrls, 'www')),
  83 + getArticleUrls()]).then(result => {
  84 + return _.concat(result[1], result[0], result[2]);
  85 + });
  86 + }
81 }; 87 };
82 88
83 // list 地图数据 89 // list 地图数据
@@ -133,7 +139,9 @@ const siteMap = (req, res, next) => { @@ -133,7 +139,9 @@ const siteMap = (req, res, next) => {
133 return; 139 return;
134 } 140 }
135 141
136 - eval(subdomain + 'XmlData')().then(urls => {// eslint-disable-line 142 + let page = req.params[0] || 1;
  143 +
  144 + eval(subdomain + 'XmlData')(page).then(urls => {// eslint-disable-line
137 sm.createSitemap({ 145 sm.createSitemap({
138 hostname: `https://${subdomain}.yohobuy.com`, 146 hostname: `https://${subdomain}.yohobuy.com`,
139 xmlNs: ' ', 147 xmlNs: ' ',
@@ -30,6 +30,6 @@ router.post('/common/getNewArrival', channelController.getNewArrival); @@ -30,6 +30,6 @@ router.post('/common/getNewArrival', channelController.getNewArrival);
30 router.get('/guide', channelController.getIndexGuide); 30 router.get('/guide', channelController.getIndexGuide);
31 31
32 // www站点地图 32 // www站点地图
33 -router.get('/sitemap.xml', sitemap.siteMap); 33 +router.get(/\/sitemap(\d*)\.xml/, sitemap.siteMap);
34 34
35 module.exports = router; 35 module.exports = router;
@@ -160,7 +160,7 @@ const getLikeAsync = (skn, limit) => { @@ -160,7 +160,7 @@ const getLikeAsync = (skn, limit) => {
160 160
161 // 根据small_sort从redis获取分类下的关键词 161 // 根据small_sort从redis获取分类下的关键词
162 const getRecommendKeywords = (smallSort) => { 162 const getRecommendKeywords = (smallSort) => {
163 - return redis.all([['get', `golobal:yoho:seo:keywords:sortId:${smallSort}`]]).then(res => { 163 + return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page:1`]]).then(res => {
164 return res[0]; 164 return res[0];
165 }); 165 });
166 }; 166 };
@@ -415,7 +415,7 @@ exports.getSearchKeywordDataById = (id, params, channel) => { @@ -415,7 +415,7 @@ exports.getSearchKeywordDataById = (id, params, channel) => {
415 415
416 return co(function * () { 416 return co(function * () {
417 let redisData = yield redis.all([ 417 let redisData = yield redis.all([
418 - ['get', `golobal:yoho:seo:keywords:id:${id}`] 418 + ['get', `global:yoho:seo:keywords:id:${id}`]
419 ]); 419 ]);
420 420
421 if (!redisData[0]) { 421 if (!redisData[0]) {
@@ -78,6 +78,54 @@ module.exports = [ @@ -78,6 +78,54 @@ module.exports = [
78 target: (req, match, p1) => `/product/search/keyword/${p1}` 78 target: (req, match, p1) => `/product/search/keyword/${p1}`
79 }, 79 },
80 80
  81 + // TODO
  82 + // {
  83 + // type: TYPE.redirect,
  84 + // origin: /^\/so\/(.*)\.html(.*)/,
  85 + // target: (req, match, p1) => {
  86 + // let urls = {
  87 + // '4175746F426F74E6898BE69CBAE9858DE4BBB6E794B7': 57517,
  88 + // E6BBA1E58DB0E4BABAE5AD97E68B96: 11877,
  89 + // E6BDAEE6ACBEE5A4AAE79CBCE9959C: 43319,
  90 + // E6B3A2E782B9E995BFE8A296E8A1ACE8A1A3: 5709,
  91 + // E688B7E5A496E58C85E9858D: 27481,
  92 + // E993B6E98791E889B2: 12279,
  93 + // E697B6E5B09AE68ABDE7BBB3E79FADE8A3A4: 84593,
  94 + // '4C554E414C494D49544544E99288E7BB87E5A5B3': 36255,
  95 + // '4B4F594F': 10297,
  96 + // E99288E7BB87E8A5BFE8A385: 72093,
  97 + // E8838CE5BF83E995BFE8A399: 81419,
  98 + // E9929FE8A1A8E5A5B3: 71361,
  99 + // '424142414D41E79AAEE5B8A6': 47883,
  100 + // E5BEBDE7ABA0E58DABE8A1A3: 75023,
  101 + // E9BB91E799BDE6A0BC: 20095,
  102 + // E7949CE7BE8EE7BAAFE889B2E79FADE8A3A4: 10309,
  103 + // E58DB0E88AB1E995BFE6ACBEE7BEBDE7BB92E69C8D: 62085,
  104 + // E68B89E993BEE5BC80E8A59F: 43223,
  105 + // E7BBBFE889B2E7AE80E7BAA6E4BC91E997B2E8A3A4: 7781,
  106 + // E79CBCE5BDB1E5A5B3: 39279,
  107 + // E7BAAFE889B2E6A392E79083E5B8BD: 2021,
  108 + // E5A191E69699E590B8E7AEA1E69DAF: 1956427,
  109 + // E59BB4E5859C20E794B7: 71493,
  110 + // E59BB4E5859C20E5A5B3: 65257,
  111 + // E68BBCE889B2E6898BE993BE: 48821,
  112 + // '5452494E49544573747564696FE8A1ACE8A1AB': 53871,
  113 + // E799BDE889B2E9A490E585B7: 36291,
  114 + // E8939DE889B2E79CBCE9959C: 6287,
  115 + // E7AB96E69DA1E7BAB9E8BF9EE8A1A3E8A399: 40513,
  116 + // E7899BE4BB94E8939DE794B7E5A3ABE995BFE8A3A4: 2297,
  117 + // E58DB0E88AB1E4BC91E997B2E5A4B9E5858B: 26725,
  118 + // E8BF90E58AA8E8939DE78999E880B3E69CBA: 46837,
  119 + // E7BAAFE889B2E6B299E6BBA9E8A3A4: 8709,
  120 + // E7BAAFE889B2E8B4B4E6A087: 28027
  121 + // };
  122 + //
  123 + // return urls[p1] ?
  124 + // helpers.urlFormat(`/chanpin/${urls[p1]}.html`, null, 'www') :
  125 + // helpers.urlFormat('/', null, 'www');
  126 + // }
  127 + // },
  128 +
81 // 推荐词id列表页 129 // 推荐词id列表页
82 { 130 {
83 type: TYPE.rewrite, 131 type: TYPE.rewrite,
@@ -59,6 +59,8 @@ module.exports = () => { @@ -59,6 +59,8 @@ module.exports = () => {
59 } 59 }
60 } else if (proRegNew.test(url)) { 60 } else if (proRegNew.test(url)) {
61 data.mobileRefer = url.replace(proRegNew, `//${domain}/product/pro_$1_1/1.html$2`); 61 data.mobileRefer = url.replace(proRegNew, `//${domain}/product/pro_$1_1/1.html$2`);
  62 + } else {
  63 + data.mobileRefer = `//${domain}${req.originalUrl}`;
62 } 64 }
63 65
64 if (!_.isEmpty(req.query) && !qsReg.test(data.mobileRefer)) { 66 if (!_.isEmpty(req.query) && !qsReg.test(data.mobileRefer)) {
@@ -23,7 +23,7 @@ try { @@ -23,7 +23,7 @@ try {
23 } 23 }
24 24
25 return client.multi.call(client, args).execAsync().timeout(timeout).catch(()=>{ 25 return client.multi.call(client, args).execAsync().timeout(timeout).catch(()=>{
26 - logger.err('redis exe time out'); 26 + logger.error('redis exe time out');
27 return false; 27 return false;
28 }); 28 });
29 }; 29 };
@@ -11,6 +11,11 @@ @@ -11,6 +11,11 @@
11 <meta name="apple-mobile-web-app-status-bar-style" content="black" /> 11 <meta name="apple-mobile-web-app-status-bar-style" content="black" />
12 <meta content="telephone=no" name="format-detection" /> 12 <meta content="telephone=no" name="format-detection" />
13 <meta content="email=no" name="format-detection" /> 13 <meta content="email=no" name="format-detection" />
  14 + <meta name="applicable-device"content="pc">
  15 + {{#if mobileRefer}}
  16 + <link rel="alternate" media="only screen and(max-width: 640px)" href="{{mobileRefer}}">
  17 + <meta name="mobile-agent" content="format=html5;url={{mobileRefer}}">
  18 + {{/if}}
14 {{#dnsPrefetch.hosts}} 19 {{#dnsPrefetch.hosts}}
15 <link rel="dns-prefetch" href="{{this}}"> 20 <link rel="dns-prefetch" href="{{this}}">
16 {{/dnsPrefetch.hosts}} 21 {{/dnsPrefetch.hosts}}