<template>
    <view></view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app'
import $store from '@/peach/store'
import peach from '@/peach'

const userStore = $store('user')

async function redirectFn() {
    // 判断是否登录
    if (!userStore.isLogin) {
        userStore.logOut()
        peach.$router.redirect('/pages/index/login')
    } else {
        await userStore.loginAfter()

        if (userStore.lastRoutePage) {
            peach.$router.redirect(userStore.lastRoutePage)
        } else {
            peach.$router.redirect('/pages/index/index')
        }
    }
}

onLoad(() => {
    redirectFn()
})
</script>
