提交 6b32420a 编写于 作者: DCloud_JSON's avatar DCloud_JSON

修复 退出登录为完成就刚刚本地登录状态的问题

上级 2a20666c
...@@ -43,17 +43,20 @@ export const loginSuccess = (_ : UTSJSONObject) => { ...@@ -43,17 +43,20 @@ export const loginSuccess = (_ : UTSJSONObject) => {
} }
export const logout = () => { export const logout = async () => {
// console.log("logout"); // console.log("logout");
// 1. 已经过期就不需要调用服务端的注销接口 2.即使调用注销接口失败,不能阻塞客户端 // 1. 已经过期就不需要调用服务端的注销接口 2.即使调用注销接口失败,不能阻塞客户端
if (uniCloud.getCurrentUserInfo().tokenExpired > Date.now()) { if (uniCloud.getCurrentUserInfo().tokenExpired > Date.now()) {
const uniIdCo = uniCloud.importObject("uni-id-co", { customUI: false }) const uniIdCo = uniCloud.importObject("uni-id-co", { customUI: false })
uniIdCo.logout().finally(() => { try{
await uniIdCo.logout()
}catch(_){
//TODO handle the exception
}
// 调完注销接口 跳转至登录页面 // 调完注销接口 跳转至登录页面
uni.redirectTo({ uni.redirectTo({
url: "/uni_modules/uni-id-pages-x/pages/login/login" url: "/uni_modules/uni-id-pages-x/pages/login/login"
}) })
})
} }
uni.removeStorageSync('uni_id_token'); uni.removeStorageSync('uni_id_token');
uni.setStorageSync('uni_id_token_expired', 0) uni.setStorageSync('uni_id_token_expired', 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册