export default function ({ store, req, redirect, route }) { // If nuxt generate, pass this middleware if (process.server && !req) return if (!store.state.option.user.logged) { let ua = store.state.option.userAgent.toLowerCase() if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger' && req.url.indexOf('?code') === -1) { // 判断是微信浏览器,且不存在code return redirect(`/mobile/wechat/toggle?url=${route.path}`) } else if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger' && req.url.indexOf('?code') > -1) { // 判断是微信浏览器,且存在code return redirect(`/mobile/wechat?url=${route.path}`) } else { return redirect(`/auth/login?returnUrl=${'http://' + req.headers.host + route.fullPath}`) } } }