29 lines
751 B
TypeScript
29 lines
751 B
TypeScript
import { useAuth } from '@shared/composables/use-auth'
|
|
import { createApp } from 'vue'
|
|
import App from '../App.vue'
|
|
import routerPlugin, { router } from '../plugins/router'
|
|
import tanstackQueryPlugin from '../plugins/tanstack-query'
|
|
|
|
const mountPoint = '#app'
|
|
|
|
export default async function () {
|
|
const { authorized } = useAuth()
|
|
const app = createApp(App)
|
|
|
|
app.use(routerPlugin)
|
|
|
|
await router.isReady()
|
|
|
|
if (!authorized.value && router.currentRoute.value.meta.auth === undefined) {
|
|
await router.push({ name: '/auth/login', replace: true })
|
|
}
|
|
|
|
if (authorized.value && router.currentRoute.value.meta.auth === 'guest') {
|
|
await router.push({ name: '/', replace: true })
|
|
}
|
|
|
|
app.use(tanstackQueryPlugin)
|
|
|
|
app.mount(mountPoint)
|
|
}
|