Explorar el Código

1.添加token失效页面跳转登录页

王鹏鹏 hace 2 años
padre
commit
04aa757c45

+ 1 - 0
.idea/misc.xml

@@ -570,6 +570,7 @@
         <entry key="..\:/workspace/hcp-pads/livebroadcast/src/main/res/layout/item_live_broadcast.xml" value="0.6" />
         <entry key="..\:/workspace/hcp-pads/login/src/main/res/drawable/bg_login.xml" value="0.151" />
         <entry key="..\:/workspace/hcp-pads/login/src/main/res/layout/activity_login.xml" value="0.4421768707482993" />
+        <entry key="..\:/workspace/hcp-pads/mmse/src/main/res/layout/activity_questions.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pads/mmse/src/main/res/layout/fragment_count.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pads/mmse/src/main/res/layout/fragment_memory_words.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pads/mmse/src/main/res/layout/fragment_multiple_choice.xml" value="0.23697916666666666" />

+ 15 - 5
baselib/src/main/java/com/yingyangfly/baselib/net/BaseResp.kt

@@ -1,5 +1,9 @@
 package com.yingyangfly.baselib.net
 
+import com.alibaba.android.arouter.launcher.ARouter
+import com.yingyangfly.baselib.router.RouterUrlCommon
+import com.yingyangfly.baselib.utils.JumpUtil
+
 /**
  * @author gold
  * @date 2022/9/2 下午12:24
@@ -19,11 +23,17 @@ open class BaseResp<T>(
      * 网络数据请求成功
      */
     inline fun y(func: (data: T?) -> Unit) {
-        if (this.code == ResponseCode.SUCCESS) {
-            func(data)
-        } else {
-            n {
-                this.message
+        when (this.code) {
+            ResponseCode.SUCCESS -> {
+                func(data)
+            }
+            ResponseCode.TOKENLOSEEFFICACY -> {
+                JumpUtil.jumpActivity(RouterUrlCommon.login)
+            }
+            else -> {
+                n {
+                    this.message
+                }
             }
         }
     }

+ 1 - 0
baselib/src/main/java/com/yingyangfly/baselib/net/ResponseCode.kt

@@ -2,4 +2,5 @@ package com.yingyangfly.baselib.net
 
 object ResponseCode {
     const val SUCCESS = 200
+    const val TOKENLOSEEFFICACY = 403
 }