refactor: use modernMode instead of isModernBrowser for more semantic

This commit is contained in:
Clark Du 2018-11-07 23:48:22 +00:00
parent 2a36dbad22
commit 64839313a9
3 changed files with 5 additions and 5 deletions

View File

@ -13,10 +13,10 @@ const isModernBrowser = (ua) => {
export default function (req, res, next) {
const { socket = {}, headers } = req
if (socket.isModernBrowser === undefined) {
if (socket.modernMode === undefined) {
const ua = headers && headers['user-agent']
socket.isModernBrowser = isModernBrowser(ua)
socket.modernMode = isModernBrowser(ua)
}
req.isModernBrowser = socket.isModernBrowser
req.modernMode = socket.modernMode
next()
}

View File

@ -78,7 +78,7 @@ export default class Server {
// Add webpack middleware support only for development
if (this.options.dev) {
this.useMiddleware(async (req, res, next) => {
const name = req.isModernBrowser ? 'modern' : 'client'
const name = req.modernMode ? 'modern' : 'client'
if (this.devMiddleware[name]) {
await this.devMiddleware[name](req, res)
}

View File

@ -269,7 +269,7 @@ export default class VueRenderer {
let APP
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
if (req && req.isModernBrowser) {
if (req && req.modernMode) {
APP = await this.renderer.modern.renderToString(context)
} else {
APP = await this.renderer.ssr.renderToString(context)