V0.28.1.250618_alpha:修复定期的认证状态检查会关闭标签页的问题
This commit is contained in:
parent
b5d163be94
commit
346b34ee40
Binary file not shown.
@ -273,7 +273,7 @@
|
|||||||
const contentArea = document.querySelector('content-area');
|
const contentArea = document.querySelector('content-area');
|
||||||
|
|
||||||
// 检查是否已登录
|
// 检查是否已登录
|
||||||
const checkAuth = async () => {
|
const checkAuth = async (isInterval = false) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/check-auth', {
|
const response = await fetch('/api/check-auth', {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
@ -281,12 +281,12 @@
|
|||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
// 先初始化主页面
|
if (!isInterval) {
|
||||||
|
// 只有首次加载或主动调用时才初始化主页面
|
||||||
initializeMainPage();
|
initializeMainPage();
|
||||||
|
}
|
||||||
authContainer.classList.remove('visible');
|
authContainer.classList.remove('visible');
|
||||||
mainContainer.classList.add('visible');
|
mainContainer.classList.add('visible');
|
||||||
|
|
||||||
// 触发一个自定义事件,通知其他组件登录成功
|
// 触发一个自定义事件,通知其他组件登录成功
|
||||||
const loginSuccessEvent = new CustomEvent('login-success', {
|
const loginSuccessEvent = new CustomEvent('login-success', {
|
||||||
detail: { user: result.user }
|
detail: { user: result.user }
|
||||||
@ -713,7 +713,7 @@
|
|||||||
|
|
||||||
// 每5分钟检查一次认证状态
|
// 每5分钟检查一次认证状态
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
checkAuth();
|
checkAuth(true); // 传true表示定时检查
|
||||||
}, 5 * 60 * 1000); // 5分钟
|
}, 5 * 60 * 1000); // 5分钟
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user