Ver Fonte

fix: 登录成功后自动刷新当前页以更新登录状态

liaoxg há 1 semana atrás
pai
commit
a1ce1e48df
1 ficheiros alterados com 16 adições e 0 exclusões
  1. 16 0
      cfc-frontend/mixins/login-sheet.js

+ 16 - 0
cfc-frontend/mixins/login-sheet.js

@@ -93,6 +93,22 @@ export default {
           console.warn('loadData 调用失败', e)
         }
       }
+      // 登录成功后,尝试刷新当前页面,重置登录状态
+      try {
+        var pages = getCurrentPages()
+        if (pages.length) {
+          var curPage = pages[pages.length - 1]
+          if (curPage && typeof curPage.onLoad === 'function' && typeof curPage.onShow === 'function') {
+            var options = curPage.options || {}
+            curPage.onLoad(options)
+            curPage.onShow()
+          } else if (curPage && typeof curPage.onShow === 'function') {
+            curPage.onShow()
+          }
+        }
+      } catch (e) {
+        console.warn('刷新当前页失败', e)
+      }
     }
   }
 }