refactor: clean up boilerplate

This commit is contained in:
liyasthomas
2021-12-01 23:15:14 +05:30
parent 190a4c43ef
commit 63005c01ce
15 changed files with 169 additions and 127 deletions

View File

@@ -6,12 +6,12 @@ import { UserModule } from "~/types"
//
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
const messages = Object.fromEntries(
Object.entries(
import.meta.globEager("../../locales/*.y(a)?ml"))
.map(([key, value]) => {
Object.entries(import.meta.globEager("../../locales/*.y(a)?ml")).map(
([key, value]) => {
const yaml = key.endsWith(".yaml")
return [key.slice(14, yaml ? -5 : -4), value.default]
}),
},
),
)
export const install: UserModule = ({ app }) => {

View File

@@ -3,7 +3,11 @@ import { UserModule } from "~/types"
export const install: UserModule = ({ isClient, router }) => {
if (isClient) {
router.beforeEach(() => { NProgress.start() })
router.afterEach(() => { NProgress.done() })
router.beforeEach(() => {
NProgress.start()
})
router.afterEach(() => {
NProgress.done()
})
}
}

View File

@@ -9,9 +9,6 @@ export const install: UserModule = ({ isClient, initialState, app }) => {
// Refer to
// https://github.com/antfu/vite-ssg/blob/main/README.md#state-serialization
// for other serialization strategies.
if (isClient)
pinia.state.value = (initialState.pinia) || {}
else
initialState.pinia = pinia.state.value
if (isClient) pinia.state.value = initialState.pinia || {}
else initialState.pinia = pinia.state.value
}

View File

@@ -2,8 +2,7 @@ import { UserModule } from "~/types"
// https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
export const install: UserModule = ({ isClient, router }) => {
if (!isClient)
return
if (!isClient) return
router.isReady().then(async() => {
const { registerSW } = await import("virtual:pwa-register")