2016-11-07 01:34:58 +00:00
|
|
|
<template>
|
2016-12-24 16:58:52 +00:00
|
|
|
<div id="__nuxt">
|
2017-01-30 10:20:20 +00:00
|
|
|
<% if (loading) { %><nuxt-loading ref="loading"></nuxt-loading><% } %>
|
2017-08-10 10:37:23 +00:00
|
|
|
<component v-if="layout" :is="nuxt.err ? 'nuxt' : layout"></component>
|
2016-12-24 16:58:52 +00:00
|
|
|
</div>
|
2016-11-07 01:34:58 +00:00
|
|
|
</template>
|
2016-12-24 00:55:32 +00:00
|
|
|
|
|
|
|
<script>
|
2017-08-10 10:37:23 +00:00
|
|
|
import Vue from 'vue'
|
2017-01-30 10:20:20 +00:00
|
|
|
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
2017-05-05 14:10:12 +00:00
|
|
|
<% css.forEach(function (c) { %>
|
2017-07-21 23:40:38 +00:00
|
|
|
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
|
2017-05-05 14:10:12 +00:00
|
|
|
<% }) %>
|
2017-01-30 10:20:20 +00:00
|
|
|
|
2016-12-24 00:55:32 +00:00
|
|
|
let layouts = {
|
|
|
|
<%
|
|
|
|
var layoutsKeys = Object.keys(layouts);
|
|
|
|
layoutsKeys.forEach(function (key, i) { %>
|
2017-07-04 22:26:42 +00:00
|
|
|
"_<%= key %>": () => import('<%= layouts[key] %>' /* webpackChunkName: "layouts/<%= key %>" */).then(m => m.default || m)<%= (i + 1) < layoutsKeys.length ? ',' : '' %>
|
2016-12-24 00:55:32 +00:00
|
|
|
<% }) %>
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2016-12-24 16:58:52 +00:00
|
|
|
head: <%= JSON.stringify(head) %>,
|
2016-12-24 13:15:00 +00:00
|
|
|
data: () => ({
|
|
|
|
layout: null,
|
|
|
|
layoutName: ''
|
|
|
|
}),
|
2017-01-30 10:20:20 +00:00
|
|
|
<% if (loading) { %>
|
|
|
|
mounted () {
|
|
|
|
this.$loading = this.$refs.loading
|
|
|
|
this.$nuxt.$loading = this.$loading
|
|
|
|
},
|
|
|
|
<% } %>
|
2017-08-10 10:37:23 +00:00
|
|
|
beforeCreate () {
|
|
|
|
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
|
|
|
},
|
2016-12-24 00:55:32 +00:00
|
|
|
methods: {
|
|
|
|
setLayout (layout) {
|
|
|
|
if (!layout || !layouts['_' + layout]) layout = 'default'
|
2016-12-24 13:15:00 +00:00
|
|
|
this.layoutName = layout
|
2016-12-24 11:34:41 +00:00
|
|
|
let _layout = '_' + layout
|
|
|
|
this.layout = layouts[_layout]
|
2017-02-20 22:11:34 +00:00
|
|
|
return this.layout
|
2016-12-24 11:34:41 +00:00
|
|
|
},
|
2017-02-20 22:11:34 +00:00
|
|
|
loadLayout (layout) {
|
|
|
|
if (!layout || !layouts['_' + layout]) layout = 'default'
|
|
|
|
let _layout = '_' + layout
|
|
|
|
if (typeof layouts[_layout] !== 'function') {
|
|
|
|
return Promise.resolve(layouts[_layout])
|
|
|
|
}
|
2016-12-24 11:34:41 +00:00
|
|
|
return layouts[_layout]()
|
|
|
|
.then((Component) => {
|
|
|
|
layouts[_layout] = Component
|
2017-02-20 22:11:34 +00:00
|
|
|
return layouts[_layout]
|
2016-12-24 11:34:41 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
if (this.$nuxt) {
|
|
|
|
return this.$nuxt.error({ statusCode: 500, message: e.message })
|
|
|
|
}
|
|
|
|
})
|
2016-12-24 00:55:32 +00:00
|
|
|
}
|
2017-01-30 10:20:20 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
<%= (loading ? 'NuxtLoading' : '') %>
|
2016-12-24 00:55:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2016-12-24 16:58:52 +00:00
|
|
|
|