Blame view

doraemon/middleware/update.js 545 Bytes
zhangxiaoru authored
1 2 3 4 5
/**
 * app版本判断
 * @date: 2017/5/10
 */
'use strict';
毕凯 authored
6
const semver = require('semver');
zhangxiaoru authored
7
毕凯 authored
8 9 10 11
module.exports = (version) => {
    return (req, res, next) => {
        if (req.yoho.isApp && req.query.app_version) {
            let appVersion = req.query.app_version.split('.');
zhangxiaoru authored
12
毕凯 authored
13
            appVersion = `${appVersion[0]}.${appVersion[1]}.${appVersion[2]}`;
zhangxiaoru authored
14
毕凯 authored
15 16 17
            if (semver.lt(appVersion, version)) {
                return res.redirect('http://m.yohobuy.com/passport/update');
            }
zhangxiaoru authored
18 19
        }
毕凯 authored
20 21
        return next();
    };
zhangxiaoru authored
22
};