接入前端登录权限底座
This commit is contained in:
@@ -6,13 +6,32 @@ import { VueQueryPlugin } from '@tanstack/vue-query'
|
||||
import 'primeicons/primeicons.css'
|
||||
|
||||
import App from './App.vue'
|
||||
import { setReservationHotelIdProvider } from './config/reservationConfig'
|
||||
import { i18n } from './i18n'
|
||||
import { router } from './router'
|
||||
import { setUnauthorizedHandler } from './services/httpClient'
|
||||
import { useAuthStore } from './stores/authStore'
|
||||
import './styles/main.css'
|
||||
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
const authStore = useAuthStore(pinia)
|
||||
|
||||
app.use(createPinia())
|
||||
setReservationHotelIdProvider(() => authStore.selectedHotelId)
|
||||
setUnauthorizedHandler(() => {
|
||||
const currentPath = router.currentRoute.value.fullPath
|
||||
authStore.clearAuth()
|
||||
if (!currentPath.startsWith('/login')) {
|
||||
void router.push({
|
||||
path: '/login',
|
||||
query: {
|
||||
redirect: currentPath,
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
app.use(i18n)
|
||||
app.use(VueQueryPlugin)
|
||||
|
||||
Reference in New Issue
Block a user