소스 검색

fix(tabbar): 优化登录后 `tabbar` 索引设置逻辑

ljt990218 7 달 전
부모
커밋
2d1d32218d
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      src/tabbar/store.ts

+ 4 - 3
src/tabbar/store.ts

@@ -3,7 +3,7 @@ import { reactive } from 'vue'
 
 import { isNeedLoginMode } from '@/router/config'
 import { FG_LOG_ENABLE, judgeIsExcludePath } from '@/router/interceptor'
-
+import { useTokenStore } from '@/store/token'
 import { tabbarList as _tabbarList, customTabbarEnable } from './config'
 
 // TODO 1/2: 中间的鼓包tabbarItem的开关
@@ -38,8 +38,9 @@ const tabbarStore = reactive({
   curIdx: uni.getStorageSync('app-tabbar-index') || 0,
   prevIdx: uni.getStorageSync('app-tabbar-index') || 0,
   setCurIdx(idx: number) {
-    // url 需要登录 && 不在白名单 || 不需要登录 && 不在黑名单 (关于 白名单|黑名单 逻辑: src/router/interceptor.ts)
-    if ((isNeedLoginMode && judgeIsExcludePath(tabbarList[idx].pagePath)) || (!isNeedLoginMode && !judgeIsExcludePath(tabbarList[idx].pagePath))) {
+    const tokenStore = useTokenStore()
+    // 已登录 或 (url 需要登录 && 在白名单 || 不需要登录 && 不在黑名单) (关于 白名单|黑名单 逻辑: src/router/interceptor.ts)
+    if (tokenStore.hasLogin || (isNeedLoginMode && judgeIsExcludePath(tabbarList[idx].pagePath)) || (!isNeedLoginMode && !judgeIsExcludePath(tabbarList[idx].pagePath))) {
       this.curIdx = idx
       uni.setStorageSync('app-tabbar-index', idx)
     }