1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<template>
</template>
 
<script setup>
import { onShow } from '@dcloudio/uni-app'
import { getToken } from '@/utils/request.js'
import config from '@/config/index.js'
 
/**
 * 校验登录态:本地无 token 时重定向至登录页
 */
const _checkLoginStatus = () => {
    if (getToken()) return
    uni.reLaunch({ url: config.loginPage })
}
 
// 每次页面显示均校验登录态,避免退出登录后仍停留在首页
onShow(() => {
    _checkLoginStatus()
})
</script>
 
<style scoped lang="scss">
</style>