<script lang="ts" setup>
|
import { nextTick, onMounted, ref } from 'vue';
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { preferences } from '@vben/preferences';
|
import { useAccessStore } from '@vben/stores';
|
|
defineOptions({ name: 'SsoRedirect' });
|
|
const loading = ref(true);
|
const accessStore = useAccessStore();
|
|
function init() {
|
const route = useRoute();
|
const router = useRouter();
|
const token = route.query.token as string;
|
const redirect = route.query.redirect as string;
|
if (!token) return;
|
accessStore.setAccessToken(token);
|
nextTick(() => {
|
router.replace(redirect || preferences.app.defaultHomePath);
|
loading.value = false;
|
});
|
}
|
|
onMounted(() => {
|
init();
|
});
|
</script>
|
|
<template>
|
<div class="box" v-loading="loading"></div>
|
</template>
|
|
<style lang="scss" scoped>
|
.box {
|
position: relative;
|
width: 100%;
|
height: 100%;
|
}
|
</style>
|