import { request } from '@shared/utils/request' ; import Taro from '@tarojs/taro' ; import _last from 'lodash/last' ; param 是否自动跳转 export async function checkTaroToken ( autoNav = true ) { try { await request . post ( '/player/sso/check' ) ; return true ; } catch ( err ) { if ( autoNav ) { const currentPages = Taro . getCurrentPages ( ) ; if ( currentPages . length === 1 ) { Taro . navigateTo ( { url : `/pages/login/index` , } ) ; } else { const lastPage = _last ( currentPages ) ; Taro . redirectTo ( { url : `/pages/login/index?next=${ lastPage ?. route ?? '' }` , } ) ; } return false ; } throw err ; } }