feat: vite-ssg (#24)

This commit is contained in:
Anthony Fu authored and GitHub committed 2020-12-21 17:07:07 +08:00
1 parent d090ba51b4
commit 9978e5e5a1
9 files changed
+258 -1287

No files matched your search

+1 -1
View File
@@ -18,6 +18,6 @@ export const isDark = computed({
watch(
isDark,
v => document.documentElement.classList.toggle('dark', v),
v => typeof document !== 'undefined' && document.documentElement.classList.toggle('dark', v),
{ immediate: true },
)
+16 -7
View File
@@ -1,12 +1,21 @@
import './main.postcss'
import { createApp } from 'vue'
// import routes generated by Voie
import routes from 'voie-pages'
// progress bar
import NProgress from 'nprogress'
import { ViteSSG } from 'vite-ssg'
import installPlugins from './plugins'
import App from './App.vue'
const app = createApp(App)
export const createApp = ViteSSG(
App,
{ routes },
({ app, router, isClient }) => {
installPlugins(app)
installPlugins(app)
// true for hydrate
app.mount('#app', true)
if (isClient) {
router.beforeEach(() => { NProgress.start() })
router.afterEach(() => { NProgress.done() })
}
}
)
-2
View File
@@ -1,9 +1,7 @@
import { App } from 'vue'
import installRouter from './router'
import installI18n from './i18n'
import './icons'
export default (app: App) => {
installRouter(app)
installI18n(app)
}
-18
View File
@@ -1,18 +0,0 @@
import { App } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
// import routes generated by Voie
import routes from 'voie-pages'
// progress bar
import NProgress from 'nprogress'
export default (app: App) => {
const router = createRouter({
history: createWebHistory(),
routes,
})
router.beforeEach(() => { NProgress.start() })
router.afterEach(() => { NProgress.done() })
app.use(router)
}