...
|
...
|
@@ -83,15 +83,12 @@ const handlerError = (err = {}, req, res, next) => { |
|
|
};
|
|
|
|
|
|
const getCacheKey = (req, cacheKey = '') => {
|
|
|
const isYohoProtocol = _.get(req.app.locals.wap, `webapp.${config.appName}-yoho-protocol`, false);
|
|
|
const urlObj = url.parse(req.url);
|
|
|
const isIos = req.yoho.isiOS;
|
|
|
const yohoProtocol = (req.get('User-Agent').indexOf('yoho-protocol') >= 0 && isYohoProtocol) ? 'yoho-protocol' : '';
|
|
|
|
|
|
return md5(cacheKey
|
|
|
.replace('$url', urlObj.pathname)
|
|
|
.replace('$params', urlObj.query || '')
|
|
|
.replace('$yoho-protocol', yohoProtocol) + (isIos ? 'ios' : 'android'));
|
|
|
.replace('$params', urlObj.query || '') + (isIos ? 'ios' : 'android'));
|
|
|
};
|
|
|
|
|
|
const render = (route) => {
|
...
|
...
|
@@ -99,7 +96,6 @@ 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);
|
...
|
...
|
@@ -146,13 +142,6 @@ const render = (route) => { |
|
|
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,
|
...
|
...
|
@@ -223,11 +212,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,
|
...
|
...
|
|