forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: request health api for session keep-alive (halo-dev#4949)
#### What type of PR is this? /area console /kind improvement /milestone 2.11.0 #### What this PR does / why we need it: 在 Console 和 UC 轮询 /actuator/health 接口保持登录会话,目前是 5min 请求一次。 #### Which issue(s) this PR fixes: Fixes halo-dev#4947 #### Does this PR introduce a user-facing change? ```release-note 优化 Console 的登录会话保活机制。 ```
- Loading branch information
Showing
4 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useUserStore } from "@/stores/user"; | ||
import { useQuery } from "@tanstack/vue-query"; | ||
import { computed } from "vue"; | ||
|
||
export function useSessionKeepAlive() { | ||
const { isAnonymous } = useUserStore(); | ||
|
||
useQuery({ | ||
queryKey: ["health", "keep-session-alive"], | ||
queryFn: () => fetch("/actuator/health"), | ||
refetchInterval: 1000 * 60 * 5, // 5 minutes | ||
refetchOnWindowFocus: true, | ||
enabled: computed(() => !isAnonymous), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters