refactor: clean up boilerplate
This commit is contained in:
@@ -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 }) => {
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user