Skip to content

Commit 606ecba

Browse files
committed
feat(SelfCheck): add timeout check endpoint and integrate it into the SelfCheck component
1 parent 3058ec1 commit 606ecba

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

api/system/router.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func InitSelfCheckRouter(r *gin.RouterGroup) {
3333
g.POST("/:name/fix", middleware.Proxy(), SelfCheckFix)
3434
g.GET("sse", middleware.Proxy(), CheckSSE)
3535
g.GET("websocket", middleware.ProxyWs(), CheckWebSocket)
36+
g.GET("timeout", middleware.Proxy(), TimeoutCheck)
3637
}
3738

3839
func InitBackupRestoreRouter(r *gin.RouterGroup) {

api/system/self_check.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ func CheckSSE(c *gin.Context) {
6161
}
6262
}
6363
}
64+
65+
func TimeoutCheck(c *gin.Context) {
66+
time.Sleep(time.Minute)
67+
c.JSON(http.StatusOK, gin.H{
68+
"message": "ok",
69+
})
70+
}

app/src/api/self_check.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const selfCheck = {
3030
websocket() {
3131
return ws('/api/self_check/websocket', false)
3232
},
33+
timeoutCheck() {
34+
return http.get('/self_check/timeout')
35+
},
3336
}
3437

3538
export default selfCheck

app/src/components/SelfCheck/SelfCheck.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { CheckCircleOutlined, CloseCircleOutlined, WarningOutlined } from '@ant-design/icons-vue'
3+
import selfCheck from '@/api/self_check'
34
import { useSelfCheckStore } from './store'
45
56
const store = useSelfCheckStore()
@@ -8,6 +9,8 @@ const { data, loading, fixing } = storeToRefs(store)
89
910
onMounted(() => {
1011
store.check()
12+
// 调用 timeout check API,不等待返回
13+
selfCheck.timeoutCheck().catch(console.error)
1114
})
1215
</script>
1316

0 commit comments

Comments
 (0)