
import { createPinia } from 'pinia'
import { usePermissionStore } from '@/stores/permission'
const pinia = createPinia()
const permissionStore = usePermissionStore(pinia)
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.get('token')) {
    sessionStorage.setItem('token', urlParams.get('token'))
    sessionStorage.setItem('system', urlParams.get('system'))
    sessionStorage.setItem('userInfo', urlParams.get('userInfo'))
    const token = sessionStorage.getItem('token')
    
    if (!token) {
        window.open(import.meta.env.VITE_HOME_URL, '_self');
    } else {
        permissionStore.generateRoutes()
    }
} else {
    if (sessionStorage.getItem('token')) {
        permissionStore.generateRoutes()

    } else {
        window.open(import.meta.env.VITE_HOME_URL, '_self');
    }
}