Browse Source

feat(SelfCheck): add timeout check endpoint and integrate it into the SelfCheck component

Jacky 4 days ago
parent
commit
606ecbabef

+ 1 - 0
api/system/router.go

@@ -33,6 +33,7 @@ func InitSelfCheckRouter(r *gin.RouterGroup) {
 	g.POST("/:name/fix", middleware.Proxy(), SelfCheckFix)
 	g.GET("sse", middleware.Proxy(), CheckSSE)
 	g.GET("websocket", middleware.ProxyWs(), CheckWebSocket)
+	g.GET("timeout", middleware.Proxy(), TimeoutCheck)
 }
 
 func InitBackupRestoreRouter(r *gin.RouterGroup) {

+ 7 - 0
api/system/self_check.go

@@ -61,3 +61,10 @@ func CheckSSE(c *gin.Context) {
 		}
 	}
 }
+
+func TimeoutCheck(c *gin.Context) {
+	time.Sleep(time.Minute)
+	c.JSON(http.StatusOK, gin.H{
+		"message": "ok",
+	})
+}

+ 3 - 0
app/src/api/self_check.ts

@@ -30,6 +30,9 @@ const selfCheck = {
   websocket() {
     return ws('/api/self_check/websocket', false)
   },
+  timeoutCheck() {
+    return http.get('/self_check/timeout')
+  },
 }
 
 export default selfCheck

+ 3 - 0
app/src/components/SelfCheck/SelfCheck.vue

@@ -1,5 +1,6 @@
 <script setup lang="ts">
 import { CheckCircleOutlined, CloseCircleOutlined, WarningOutlined } from '@ant-design/icons-vue'
+import selfCheck from '@/api/self_check'
 import { useSelfCheckStore } from './store'
 
 const store = useSelfCheckStore()
@@ -8,6 +9,8 @@ const { data, loading, fixing } = storeToRefs(store)
 
 onMounted(() => {
   store.check()
+  // 调用 timeout check API,不等待返回
+  selfCheck.timeoutCheck().catch(console.error)
 })
 </script>