mirror of https://github.com/Kylart/KawAnime.git
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
|
import Vue from 'vue'
|
||
|
import App from './App.vue'
|
||
|
import Vuetify from 'vuetify'
|
||
|
import Components from 'components/_index'
|
||
|
|
||
|
import { createStore } from 'store/index'
|
||
|
import { createRouter } from 'router/index'
|
||
|
import { sync } from 'vuex-router-sync'
|
||
|
|
||
|
Vue.use(Vuetify)
|
||
|
|
||
|
Object.keys(Components).forEach(key => {
|
||
|
Vue.component(key, Components[key])
|
||
|
})
|
||
|
|
||
|
// Expose a factory function that creates a fresh set of store, router,
|
||
|
// app instances on each call (which is called for each SSR request)
|
||
|
export function createApp (ssrContext) {
|
||
|
// create store and router instances
|
||
|
const store = createStore()
|
||
|
const router = createRouter()
|
||
|
|
||
|
// App initialization
|
||
|
store.dispatch('init')
|
||
|
|
||
|
// sync the router with the vuex store.
|
||
|
// this registers `store.state.route`
|
||
|
sync(store, router)
|
||
|
|
||
|
// create the app instance.
|
||
|
// here we inject the router, store and ssr context to all child components,
|
||
|
// making them available everywhere as `this.$router` and `this.$store`.
|
||
|
const app = new Vue({
|
||
|
router,
|
||
|
store,
|
||
|
ssrContext,
|
||
|
render: h => h(App)
|
||
|
})
|
||
|
|
||
|
return { app, router, store }
|
||
|
}
|