Authored by yyq
Committed by shuaiguo

clienttype

... ... @@ -38,15 +38,16 @@ module.exports = (req, res, next) => {
req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
// 判断请求是否来自app
let userAgent = req.get('User-Agent');
let userAgent = req.get('User-Agent') || '';
// 判断请求是否来自app
req.yoho.isAliApp = /AliApp/i.test(userAgent || '');
req.yoho.isMiniApp = /miniProgram/i.test(userAgent || '') ||
req.yoho.isAliApp = /AliApp/i.test(userAgent);
req.yoho.isMiniApp = /miniProgram/i.test(userAgent) ||
req.query.client_type === 'miniapp';
req.yoho.isNowApp = /yohonow/i.test(userAgent || '');
req.yoho.isMarsApp = /yohomars/i.test(userAgent || '');
req.yoho.isYohoApp = /YohoBuy/i.test(userAgent || '');
req.yoho.isNowApp = /yohonow/i.test(userAgent);
req.yoho.isMarsApp = /yohomars/i.test(userAgent);
req.yoho.isYohoApp = /YohoBuy/i.test(userAgent);
req.yoho.isApp = req.yoho.isMiniApp ||
req.yoho.isNowApp ||
req.yoho.isMarsApp ||
... ... @@ -54,6 +55,27 @@ module.exports = (req, res, next) => {
req.yoho.isiOS = /(iPhone|iPad|iPod|iOS)/i.test(userAgent);
req.yoho.isAndroid = /Android/i.test(userAgent);
let clientType = '';
if (req.yoho.isAliApp) {
clientType = 'AliApp_';
} else if (req.yoho.isApp) {
clientType = 'YohoApp_';
} else {
clientType = 'Web_';
}
if (req.yoho.isiOS) {
clientType += 'iOS';
} else if (req.yoho.isAndroid) {
clientType += 'Android';
} else {
clientType += 'unknown';
}
req.yoho.clientType = clientType
// client ip
req.yoho.clientIp = _getClientIp(req);
... ...
... ... @@ -142,6 +142,7 @@ const render = (route) => {
path: req.url,
uid: req.user.uid,
udid: req.cookies.udid || '',
clientType: req.yoho.clientType || '',
ua: req.get('user-agent'),
time: new Date()
}));
... ...