Authored by yyq

Merge remote-tracking branch 'origin/release/6.9.2' into feature/0430

@@ -46,7 +46,7 @@ export default { @@ -46,7 +46,7 @@ export default {
46 loadings: [], 46 loadings: [],
47 startOffset: 0, 47 startOffset: 0,
48 noMore: false, 48 noMore: false,
49 - thumbsList: this.thumbs, 49 + thumbsList: this.thumbs.map(item => item)
50 }; 50 };
51 }, 51 },
52 props: { 52 props: {
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 </div> 10 </div>
11 </div> 11 </div>
12 <div class="opts"> 12 <div class="opts">
13 - <WidgetFollow :class="invisibleClass" :share="share" :author-uid="data.authorUid" :authorType="data.authorType" :follow="data.hasAttention === 'Y'" @on-follow="onFollow" :pos-id="posId"></WidgetFollow> 13 + <WidgetFollow :class="invisibleClass" v-if="data.hasAttention" :share="share" :author-uid="data.authorUid" :authorType="data.authorType" :follow="data.hasAttention === 'Y'" @on-follow="onFollow" :pos-id="posId"></WidgetFollow>
14 <i class="iconfont icon-more1" @click="onMore"></i> 14 <i class="iconfont icon-more1" @click="onMore"></i>
15 </div> 15 </div>
16 </div> 16 </div>
1 module.exports = [ 1 module.exports = [
2 { 2 {
3 route: /grass\/article\/\d+$/, 3 route: /grass\/article\/\d+$/,
4 - cacheKey: '$url$yoho-protocol', 4 + query: {
  5 + columnType: Number
  6 + },
5 cacheTime: 900, 7 cacheTime: 900,
6 cache: true 8 cache: true
7 }, 9 },
8 { 10 {
9 route: /grass\/article\/\d+\/user/, 11 route: /grass\/article\/\d+\/user/,
10 - cacheKey: '$url$yoho-protocol',  
11 cache: false 12 cache: false
12 }, 13 },
13 { 14 {
14 route: /grass\/article\/share\/\d+/, 15 route: /grass\/article\/share\/\d+/,
15 - cacheKey: '$url$yoho-protocol',  
16 cacheTime: 900, 16 cacheTime: 900,
17 cache: true 17 cache: true
18 }, 18 },
19 { 19 {
20 route: /grass\/article\/detail\/\d+/, 20 route: /grass\/article\/detail\/\d+/,
21 - cacheKey: '$url$yoho-protocol',  
22 cacheTime: 900, 21 cacheTime: 900,
23 cache: true 22 cache: true
24 }, 23 },
25 { 24 {
26 route: /grass\/topic\/\d+\/(.*)/, 25 route: /grass\/topic\/\d+\/(.*)/,
27 - cacheKey: '$url$yoho-protocol',  
28 cacheTime: 900, 26 cacheTime: 900,
29 cache: true 27 cache: true
30 }, 28 },
31 { 29 {
32 route: /grass\/author\/\d+\/\d+/, 30 route: /grass\/author\/\d+\/\d+/,
33 - cacheKey: '$url$yoho-protocol',  
34 cacheTime: 900, 31 cacheTime: 900,
35 cache: true 32 cache: true
36 }, 33 },
37 { 34 {
38 route: /grass\/author\/mine/, 35 route: /grass\/author\/mine/,
39 - cacheKey: '$url$yoho-protocol',  
40 cacheTime: 900, 36 cacheTime: 900,
41 cache: true 37 cache: true
42 }, 38 },
43 { 39 {
44 route: /grass\/author\/follow\/\d+\/\d+/, 40 route: /grass\/author\/follow\/\d+\/\d+/,
45 - cacheKey: '$url$yoho-protocol',  
46 cacheTime: 900, 41 cacheTime: 900,
47 cache: true 42 cache: true
48 }, 43 },
49 { 44 {
50 route: /grass\/author\/fans\/\d+\/\d+/, 45 route: /grass\/author\/fans\/\d+\/\d+/,
51 - cacheKey: '$url$yoho-protocol',  
52 cacheTime: 900, 46 cacheTime: 900,
53 cache: true 47 cache: true
54 }, 48 },
55 { 49 {
56 route: /grass\/mine\/follow/, 50 route: /grass\/mine\/follow/,
57 - cacheKey: '$url$yoho-protocol',  
58 cacheTime: 900, 51 cacheTime: 900,
59 cache: true 52 cache: true
60 }, 53 },
61 { 54 {
62 route: /grass\/mine\/fans/, 55 route: /grass\/mine\/fans/,
63 - cacheKey: '$url$yoho-protocol',  
64 cacheTime: 900, 56 cacheTime: 900,
65 cache: true 57 cache: true
66 }, 58 },
@@ -82,16 +82,20 @@ const handlerError = (err = {}, req, res, next) => { @@ -82,16 +82,20 @@ const handlerError = (err = {}, req, res, next) => {
82 return next(err); 82 return next(err);
83 }; 83 };
84 84
85 -const getCacheKey = (req, cacheKey = '') => {  
86 - const isYohoProtocol = _.get(req.app.locals.wap, `webapp.${config.appName}-yoho-protocol`, false); 85 +const getCacheKey = (req, route) => {
87 const urlObj = url.parse(req.url); 86 const urlObj = url.parse(req.url);
88 const isIos = req.yoho.isiOS; 87 const isIos = req.yoho.isiOS;
89 - const yohoProtocol = (req.get('User-Agent').indexOf('yoho-protocol') >= 0 && isYohoProtocol) ? 'yoho-protocol' : ''; 88 + let ck = urlObj.pathname;
90 89
91 - return md5(cacheKey  
92 - .replace('$url', urlObj.pathname)  
93 - .replace('$params', urlObj.query || '')  
94 - .replace('$yoho-protocol', yohoProtocol) + (isIos ? 'ios' : 'android')); 90 + if (route.query) {
  91 + const qks = Object.keys(route.query);
  92 +
  93 + ck += `?${qks.map(qk => `${qk}=${req.query && req.query[qk] || ''}`).join('&')}`;
  94 + }
  95 +
  96 + ck += `|${isIos ? 'ios' : 'android'}`;
  97 +
  98 + return md5(ck);
95 }; 99 };
96 100
97 const render = (route) => { 101 const render = (route) => {
@@ -99,12 +103,11 @@ const render = (route) => { @@ -99,12 +103,11 @@ const render = (route) => {
99 try { 103 try {
100 res.setHeader('X-YOHO-Version', pkg.version); 104 res.setHeader('X-YOHO-Version', pkg.version);
101 const isDegrade = _.get(req.app.locals.wap, `webapp.${config.appName}-degrade`, false); 105 const isDegrade = _.get(req.app.locals.wap, `webapp.${config.appName}-degrade`, false);
102 - const isYohoProtocol = _.get(req.app.locals.wap, `webapp.${config.appName}-yoho-protocol`, false);  
103 106
104 if (isDegrade) { 107 if (isDegrade) {
105 return res.send(degradeHtml); 108 return res.send(degradeHtml);
106 } 109 }
107 - const ck = route.cacheKey ? getCacheKey(req, route.cacheKey) : void 0; 110 + const ck = getCacheKey(req, route);
108 111
109 if (config.useCache && route.cache && ck) { 112 if (config.useCache && route.cache && ck) {
110 const html = await redis.getAsync(ck); 113 const html = await redis.getAsync(ck);
@@ -136,23 +139,17 @@ const render = (route) => { @@ -136,23 +139,17 @@ const render = (route) => {
136 let resources = context.renderResourceHints(); 139 let resources = context.renderResourceHints();
137 const states = context.renderState(); 140 const states = context.renderState();
138 let asyncScripts; 141 let asyncScripts;
139 - let zk = {}; 142 + let zk = {
  143 + asyncJs: _.get(req.app.locals.wap, 'webapp.ios-async-js', true)
  144 + };
140 145
141 if (process.env.NODE_ENV === 'production') { 146 if (process.env.NODE_ENV === 'production') {
142 zk.webperf = _.get(req.app.locals.wap, 'open.webperf', false); 147 zk.webperf = _.get(req.app.locals.wap, 'open.webperf', false);
143 - zk.asyncJs = _.get(req.app.locals.wap, 'webapp.ios-async-js', true);  
144 } 148 }
145 149
146 if (req.yoho.isiOS && zk.asyncJs) { 150 if (req.yoho.isiOS && zk.asyncJs) {
147 asyncScripts = asyncLoadScripts(scripts); 151 asyncScripts = asyncLoadScripts(scripts);
148 } 152 }
149 - if (req.get('User-Agent').indexOf('yoho-protocol') >= 0 &&  
150 - route.cacheKey &&  
151 - route.cacheKey.indexOf('$yoho-protocol') >= 0 &&  
152 - isYohoProtocol) {  
153 - styles = styles.replace(/"\/\//g, '"yoho-protocol://');  
154 - resources = resources.replace(/<link rel="preload" href="[^"]+" as="style">/g, '');  
155 - }  
156 153
157 const result = template({ 154 const result = template({
158 html, 155 html,
@@ -179,7 +176,7 @@ const devRender = (route) => { @@ -179,7 +176,7 @@ const devRender = (route) => {
179 return async(req, res, next) => { 176 return async(req, res, next) => {
180 try { 177 try {
181 res.setHeader('X-YOHO-Version', pkg.version); 178 res.setHeader('X-YOHO-Version', pkg.version);
182 - const ck = route.cacheKey ? getCacheKey(req, route.cacheKey) : void 0; 179 + const ck = getCacheKey(req, route);
183 180
184 const isDegrade = _.get(req.app.locals.wap, `webapp.${config.appName}-degrade`, false); 181 const isDegrade = _.get(req.app.locals.wap, `webapp.${config.appName}-degrade`, false);
185 182
@@ -223,11 +220,6 @@ const devRender = (route) => { @@ -223,11 +220,6 @@ const devRender = (route) => {
223 } 220 }
224 let {styles, scripts, resources, states, html} = msg; 221 let {styles, scripts, resources, states, html} = msg;
225 222
226 - if (req.get('User-Agent').indexOf('yoho-protocol') >= 0 &&  
227 - route.cacheKey &&  
228 - route.cacheKey.indexOf('$yoho-protocol') >= 0) {  
229 - styles = styles.replace(/"\/\//g, '"yoho-protocol://');  
230 - }  
231 const result = template({ 223 const result = template({
232 html, 224 html,
233 styles, 225 styles,