mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
refactor: always use process.client instead of process.browser (#3910)
This commit is contained in:
parent
1c34651baa
commit
411bb1904e
@ -13,7 +13,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const Cookie = process.browser ? require('js-cookie') : undefined
|
||||
const Cookie = process.client ? require('js-cookie') : undefined
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
|
@ -15,7 +15,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const Cookie = process.browser ? require('js-cookie') : undefined
|
||||
const Cookie = process.client ? require('js-cookie') : undefined
|
||||
|
||||
export default {
|
||||
middleware: 'notAuthenticated',
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<script>
|
||||
let miniToastr
|
||||
if (process.browser) {
|
||||
if (process.client) {
|
||||
miniToastr = require('mini-toastr')
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ export default {
|
||||
worker.terminate()
|
||||
},
|
||||
createWorkers () {
|
||||
if (process.browser) {
|
||||
if (process.client) {
|
||||
for(let i = 0, len = navigator.hardwareConcurrency || 1; i < len; i++) {
|
||||
this.workers.push(this.$worker.createWorker())
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ async function createApp (ssrContext) {
|
||||
<% if (mode === 'universal') { %>
|
||||
// Fix SSR caveat https://github.com/nuxt/nuxt.js/issues/3757#issuecomment-414689141
|
||||
const registerModule = store.registerModule
|
||||
store.registerModule = (path, rawModule, options) => registerModule.call(store, path, rawModule, Object.assign({ preserveState: process.browser }, options))
|
||||
store.registerModule = (path, rawModule, options) => registerModule.call(store, path, rawModule, Object.assign({ preserveState: process.client }, options))
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
@ -151,7 +151,7 @@ async function createApp (ssrContext) {
|
||||
}
|
||||
|
||||
<% if (store) { %>
|
||||
if (process.browser) {
|
||||
if (process.client) {
|
||||
// Replace store state before plugins execution
|
||||
if (window.__NUXT__ && window.__NUXT__.state) {
|
||||
store.replaceState(window.__NUXT__.state)
|
||||
@ -163,7 +163,7 @@ async function createApp (ssrContext) {
|
||||
<% plugins.filter(p => p.ssr).forEach((plugin) => { %>
|
||||
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
||||
<% if (plugins.filter(p => !p.ssr).length) { %>
|
||||
if (process.browser) { <% plugins.filter((p) => !p.ssr).forEach((plugin) => { %>
|
||||
if (process.client) { <% plugins.filter((p) => !p.ssr).forEach((plugin) => { %>
|
||||
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
||||
}<% } %>
|
||||
|
||||
|
@ -4,7 +4,7 @@ const noopData = () => ({})
|
||||
|
||||
// window.onNuxtReady(() => console.log('Ready')) hook
|
||||
// Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
|
||||
if (process.browser) {
|
||||
if (process.client) {
|
||||
window._nuxtReadyCbs = []
|
||||
window.onNuxtReady = (cb) => {
|
||||
window._nuxtReadyCbs.push(cb)
|
||||
|
Loading…
Reference in New Issue
Block a user