Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57493f4
commit 0a11483
Showing
12 changed files
with
166 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
import Vue from 'vue'; | ||
import AppLayout from './theme/AppLayout.vue'; | ||
import router from './router'; | ||
import store from './vuex-state'; | ||
// import router from './router'; | ||
import { createRouter } from './router'; | ||
// import store from './vuex-state'; | ||
import { createStore } from './vuex-state'; | ||
import './styles/index.scss'; | ||
|
||
// Vue.config.productionTip = false; | ||
|
||
Vue.config.devtools = true; | ||
if (typeof window !== 'undefined') { | ||
Vue.config.devtools = true; | ||
} | ||
|
||
const app = new Vue({ | ||
store, | ||
router, | ||
// render: (h) => h(AppLayout), | ||
...AppLayout | ||
}); | ||
// const app = new Vue({ | ||
// store, | ||
// router, | ||
// // render: (h) => h(AppLayout), | ||
// ...AppLayout | ||
// }); | ||
|
||
export { app, router, store }; | ||
// export { app, router, store }; | ||
|
||
const createApp = () => { | ||
const router = createRouter(); | ||
|
||
const store = createStore(); | ||
|
||
const app = new Vue({ | ||
store, | ||
router, | ||
// render: (h) => h(AppLayout), | ||
...AppLayout | ||
}); | ||
return { app, router, store }; | ||
}; | ||
|
||
// export function createApp() { | ||
// const app = new Vue({ | ||
// store, | ||
// router, | ||
// // render: (h) => h(AppLayout), | ||
// ...AppLayout | ||
// }); | ||
// return { app, router, store }; | ||
// } | ||
export { createApp }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
import { app, router } from './app'; | ||
// import { app, router, store } from './app'; | ||
import { createApp } from './app'; | ||
|
||
const { app, router, store } = createApp(); | ||
|
||
if (window.__INITIAL_STATE__) { | ||
// We initialize the store state with the data injected from the server | ||
// console.log(store); | ||
// store.replaceState(window.__INITIAL_STATE__); | ||
store.replaceState(window.__INITIAL_STATE__); | ||
|
||
delete window.__INITIAL_STATE__; | ||
|
||
console.log(store); | ||
} | ||
|
||
router.onReady(() => { | ||
app.$mount('#app'); | ||
app.$mount('#app', true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,52 @@ | ||
import { app, router, store } from './app'; | ||
// import { app, router, store } from './app'; | ||
|
||
// export default context => { | ||
// console.log(context); | ||
// router.push(context.url); | ||
// return new Promise((resolve, reject) => { | ||
// // set server-side router's location | ||
|
||
// // wait until router has resolved possible async components and hooks | ||
// router.onReady(() => { | ||
// const matchedComponents = router.getMatchedComponents(); | ||
// // console.log(matchedComponents); | ||
// // no matched routes, reject with 404 | ||
// if (!matchedComponents.length) { | ||
// return reject({ code: 404 }); | ||
// } | ||
|
||
// matchedComponents.map(component => { | ||
// if (component.asyncData) { | ||
// return component.asyncData(store, router.currentRoute).then(() => { | ||
// context.initialState = store.state; | ||
// console.log(context.initialState.postsModule.posts); | ||
// resolve(app); | ||
// }); | ||
// } | ||
// resolve(app); | ||
// }); | ||
|
||
// // the Promise should resolve to the app instance so it can be rendered | ||
// }, reject); | ||
// }); | ||
// // return app; | ||
// }; | ||
|
||
import { createApp } from './app'; | ||
|
||
export default context => { | ||
router.push(context.url); | ||
const { app, router, store } = createApp(); | ||
// console.log(context); | ||
return new Promise((resolve, reject) => { | ||
// set server-side router's location | ||
router.push(context.url); | ||
|
||
// wait until router has resolved possible async components and hooks | ||
router.onReady(() => { | ||
const matchedComponents = router.getMatchedComponents(); | ||
// no matched routes, reject with 404 | ||
if (!matchedComponents.length) { | ||
return reject({ code: 404 }); | ||
} | ||
context.rendered = () => { | ||
context.state = store.state; | ||
console.log(context.state); | ||
}; | ||
|
||
// the Promise should resolve to the app instance so it can be rendered | ||
resolve(app); | ||
}, reject); | ||
}); | ||
// return app; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters