You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
479 B
18 lines
479 B
import { useLogin } from '@/hooks/useLogin'
|
|
import { getToken } from '@/utils/common'
|
|
import { getNeedLoginPages } from '@/utils/pages'
|
|
|
|
const loginBack = useLogin()
|
|
|
|
/**
|
|
* 检测是否需要登录
|
|
*/
|
|
export function checkNeedLogin(route: AnyObject) {
|
|
const pages = getNeedLoginPages()
|
|
|
|
if (pages.includes(route.path) && !getToken()) {
|
|
setTimeout(() => {
|
|
loginBack.setLoginBack({ url: route.path, param: route.query || {} })
|
|
}, 100)
|
|
}
|
|
}
|
|
|