UNPKG

@opengis/vite-page

Version:

Vite SSR Multi Page plugin

33 lines (24 loc) 1.08 kB
import { createApp } from '/src/main.js'; import { createPinia } from 'pinia'; import createRouter from '/src/router.js'; const app = createApp(); const router = createRouter(); if (window.ctx?.template && router.getRoutes()?.find?.(el => el.path == '/' + window.ctx?.template)) { router.addRoute({ path: window.ctx?.path, component: router.getRoutes().find(el => el.path == '/' + window.ctx?.template)?.components?.default, }); } app.use(router); const pinia = createPinia(); app.use(pinia); router.isReady().then(() => { pinia.state.value = window.__pinia; app.config.globalProperties.$settings = app.config.globalProperties.$settings || window.ctx?.settings || {}; app.config.globalProperties.$user = app.config.globalProperties.$user || window.ctx?.user || {}; app.config.globalProperties.$originalUrl = window.ctx?.originalUrl; app.config.globalProperties.$url = window.ctx?.url; app.config.globalProperties.$query = window.ctx?.query; app.config.globalProperties.$path = window.ctx?.path; app.mount('#app'); })