 <template>
    <div class="full-height column flex-center items-center" v-if="result && !result.isSuccess">
        <el-empty :image-size="200" :description="result.message" />
    </div>
</template>

<script setup lang="ts">
import { AutoLoginResult, useUserStore } from '@/store/user';
import { query } from '@/utils/common';
import { ElLoading } from 'element-plus';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();
const forword = decodeURIComponent(router.currentRoute.value.query.forword)
const param = query(forword)
const result = ref<AutoLoginResult|null>(null)

const userLoginHandler = async ()=>{
    const loading = ElLoading.service({
        fullscreen:true,
        lock:true
    })
    if(param.uid && param.uid!=''){
        
        const response = await useUserStore().setUserAutoLoginAsync(param.uid)
        //console.log(param)
        //if(response.isSuccess){
            if(param.model=='0') {
                router.push({
                    path: `/team_editor/${param.ConfigId}/${param.TempType}`
                })
            } else if(param.model == '448963') {
                router.push({
                    path: "/preview/"+param.tid
                })
            } else if(param.model == '3') {
                router.push({
                    path: "/team_preview/"+param.ConfigId+"/"+(param.w?param.w:'')
                })
            } else if(param.model == '2' || param.model=='1'){
                router.push({
                    path: "/space"
                })
            } else if(param.model == '1001' && param.redict&&param.redict!=''){
                // router.push({
                //     path: forword
                // })
                location.href= "https://ppt.oytour.com"+decodeURIComponent(param.redict)
            }
        //}
        result.value = response
    } else{
        result.value = { isSuccess:false, message:'无法获取到令牌信息'}
        loading.close() 
    }
       
} 
userLoginHandler()
</script>

<style lang="scss">

</style>