Authored by yyq

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

... ... @@ -46,7 +46,7 @@ export default {
loadings: [],
startOffset: 0,
noMore: false,
thumbsList: this.thumbs,
thumbsList: this.thumbs.map(item => item)
};
},
props: {
... ...
... ... @@ -10,7 +10,7 @@
</div>
</div>
<div class="opts">
<WidgetFollow :class="invisibleClass" :share="share" :author-uid="data.authorUid" :authorType="data.authorType" :follow="data.hasAttention === 'Y'" @on-follow="onFollow" :pos-id="posId"></WidgetFollow>
<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>
<i class="iconfont icon-more1" @click="onMore"></i>
</div>
</div>
... ...
module.exports = [
{
route: /grass\/article\/\d+$/,
cacheKey: '$url$yoho-protocol',
query: {
columnType: Number
},
cacheTime: 900,
cache: true
},
{
route: /grass\/article\/\d+\/user/,
cacheKey: '$url$yoho-protocol',
cache: false
},
{
route: /grass\/article\/share\/\d+/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/article\/detail\/\d+/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/topic\/\d+\/(.*)/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/author\/\d+\/\d+/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/author\/mine/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/author\/follow\/\d+\/\d+/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/author\/fans\/\d+\/\d+/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/mine\/follow/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
{
route: /grass\/mine\/fans/,
cacheKey: '$url$yoho-protocol',
cacheTime: 900,
cache: true
},
... ...
... ... @@ -82,16 +82,20 @@ const handlerError = (err = {}, req, res, next) => {
return next(err);
};
const getCacheKey = (req, cacheKey = '') => {
const isYohoProtocol = _.get(req.app.locals.wap, `webapp.${config.appName}-yoho-protocol`, false);
const getCacheKey = (req, route) => {
const urlObj = url.parse(req.url);
const isIos = req.yoho.isiOS;
const yohoProtocol = (req.get('User-Agent').indexOf('yoho-protocol') >= 0 && isYohoProtocol) ? 'yoho-protocol' : '';
let ck = urlObj.pathname;
return md5(cacheKey
.replace('$url', urlObj.pathname)
.replace('$params', urlObj.query || '')
.replace('$yoho-protocol', yohoProtocol) + (isIos ? 'ios' : 'android'));
if (route.query) {
const qks = Object.keys(route.query);
ck += `?${qks.map(qk => `${qk}=${req.query && req.query[qk] || ''}`).join('&')}`;
}
ck += `|${isIos ? 'ios' : 'android'}`;
return md5(ck);
};
const render = (route) => {
... ... @@ -99,12 +103,11 @@ const render = (route) => {
try {
res.setHeader('X-YOHO-Version', pkg.version);
const isDegrade = _.get(req.app.locals.wap, `webapp.${config.appName}-degrade`, false);
const isYohoProtocol = _.get(req.app.locals.wap, `webapp.${config.appName}-yoho-protocol`, false);
if (isDegrade) {
return res.send(degradeHtml);
}
const ck = route.cacheKey ? getCacheKey(req, route.cacheKey) : void 0;
const ck = getCacheKey(req, route);
if (config.useCache && route.cache && ck) {
const html = await redis.getAsync(ck);
... ... @@ -136,23 +139,17 @@ const render = (route) => {
let resources = context.renderResourceHints();
const states = context.renderState();
let asyncScripts;
let zk = {};
let zk = {
asyncJs: _.get(req.app.locals.wap, 'webapp.ios-async-js', true)
};
if (process.env.NODE_ENV === 'production') {
zk.webperf = _.get(req.app.locals.wap, 'open.webperf', false);
zk.asyncJs = _.get(req.app.locals.wap, 'webapp.ios-async-js', true);
}
if (req.yoho.isiOS && zk.asyncJs) {
asyncScripts = asyncLoadScripts(scripts);
}
if (req.get('User-Agent').indexOf('yoho-protocol') >= 0 &&
route.cacheKey &&
route.cacheKey.indexOf('$yoho-protocol') >= 0 &&
isYohoProtocol) {
styles = styles.replace(/"\/\//g, '"yoho-protocol://');
resources = resources.replace(/<link rel="preload" href="[^"]+" as="style">/g, '');
}
const result = template({
html,
... ... @@ -179,7 +176,7 @@ const devRender = (route) => {
return async(req, res, next) => {
try {
res.setHeader('X-YOHO-Version', pkg.version);
const ck = route.cacheKey ? getCacheKey(req, route.cacheKey) : void 0;
const ck = getCacheKey(req, route);
const isDegrade = _.get(req.app.locals.wap, `webapp.${config.appName}-degrade`, false);
... ... @@ -223,11 +220,6 @@ const devRender = (route) => {
}
let {styles, scripts, resources, states, html} = msg;
if (req.get('User-Agent').indexOf('yoho-protocol') >= 0 &&
route.cacheKey &&
route.cacheKey.indexOf('$yoho-protocol') >= 0) {
styles = styles.replace(/"\/\//g, '"yoho-protocol://');
}
const result = template({
html,
styles,
... ...