From 908eb5583d5818cb6b4fdcee6f5ec2ba24557243 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E5=AD=90=E9=BB=98?= <925456043@qq.com>
Date: Mon, 27 Jul 2026 19:41:48 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=85=E7=90=86=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E5=BC=82=E6=AD=A5=E8=AF=B7=E6=B1=82=E7=94=9F=E5=91=BD=E5=91=A8?=
=?UTF-8?q?=E6=9C=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 页面卸载和弹窗关闭时终止 SSE
- 为版本检查增加超时、中止与重复请求保护
---
.../app/src/components/chat/chat.vue | 3 +
.../pages/setting/PromptChoreChatModal.vue | 32 ++++++++++-
.../app/src/views/ai/chat/index.vue | 3 +
.../widgets/check-updates/check-updates.vue | 56 ++++++++++++++-----
.../app/src/components/chat/sender.vue | 8 ++-
.../widgets/check-updates/check-updates.vue | 53 ++++++++++++++----
6 files changed, 125 insertions(+), 30 deletions(-)
diff --git a/easyflow-ui-admin/app/src/components/chat/chat.vue b/easyflow-ui-admin/app/src/components/chat/chat.vue
index 6ab8e74b..a8dca141 100644
--- a/easyflow-ui-admin/app/src/components/chat/chat.vue
+++ b/easyflow-ui-admin/app/src/components/chat/chat.vue
@@ -578,6 +578,9 @@ watch(
{ flush: 'post' },
);
onBeforeUnmount(() => {
+ if (sending.value) {
+ stopSse();
+ }
if (bubbleListScrollElement.value) {
bubbleListScrollElement.value.removeEventListener(
'scroll',
diff --git a/easyflow-ui-admin/app/src/views/ai/bots/pages/setting/PromptChoreChatModal.vue b/easyflow-ui-admin/app/src/views/ai/bots/pages/setting/PromptChoreChatModal.vue
index 8944942f..6b8ec329 100644
--- a/easyflow-ui-admin/app/src/views/ai/bots/pages/setting/PromptChoreChatModal.vue
+++ b/easyflow-ui-admin/app/src/views/ai/bots/pages/setting/PromptChoreChatModal.vue
@@ -1,5 +1,5 @@
diff --git a/easyflow-ui-usercenter/packages/effects/layouts/src/widgets/check-updates/check-updates.vue b/easyflow-ui-usercenter/packages/effects/layouts/src/widgets/check-updates/check-updates.vue
index 939e2682..c893e2b8 100644
--- a/easyflow-ui-usercenter/packages/effects/layouts/src/widgets/check-updates/check-updates.vue
+++ b/easyflow-ui-usercenter/packages/effects/layouts/src/widgets/check-updates/check-updates.vue
@@ -20,6 +20,8 @@ const props = withDefaults(defineProps(), {
});
let isCheckingUpdates = false;
+let versionCheckController: AbortController | null = null;
+const VERSION_CHECK_TIMEOUT_MS = 10_000;
const currentVersionTag = ref('');
const lastVersionTag = ref('');
const timer = ref>();
@@ -36,6 +38,12 @@ const [UpdateNoticeModal, modalApi] = useEasyFlowModal({
});
async function getVersionTag() {
+ const controller = new AbortController();
+ versionCheckController = controller;
+ const timeout = setTimeout(
+ () => controller.abort(),
+ VERSION_CHECK_TIMEOUT_MS,
+ );
try {
if (
location.hostname === 'localhost' ||
@@ -47,14 +55,22 @@ async function getVersionTag() {
cache: 'no-cache',
method: 'HEAD',
redirect: 'manual',
+ signal: controller.signal,
});
return (
response.headers.get('etag') || response.headers.get('last-modified')
);
- } catch {
- console.error('Failed to fetch version tag');
+ } catch (error) {
+ if (!controller.signal.aborted) {
+ console.error('Failed to fetch version tag', error);
+ }
return null;
+ } finally {
+ clearTimeout(timeout);
+ if (versionCheckController === controller) {
+ versionCheckController = null;
+ }
}
}
@@ -71,23 +87,35 @@ async function checkForUpdates() {
}
if (lastVersionTag.value !== versionTag && versionTag) {
- clearInterval(timer.value);
+ stop();
handleNotice(versionTag);
}
}
+
+async function runUpdateCheck() {
+ if (isCheckingUpdates) return;
+ isCheckingUpdates = true;
+ try {
+ await checkForUpdates();
+ } finally {
+ isCheckingUpdates = false;
+ }
+}
+
function handleNotice(versionTag: string) {
currentVersionTag.value = versionTag;
modalApi.open();
}
function start() {
+ stop();
if (props.checkUpdatesInterval <= 0) {
return;
}
// 每 checkUpdatesInterval(默认值为1) 分钟检查一次
timer.value = setInterval(
- checkForUpdates,
+ () => void runUpdateCheck(),
props.checkUpdatesInterval * 60 * 1000,
);
}
@@ -96,18 +124,21 @@ function handleVisibilitychange() {
if (document.hidden) {
stop();
} else {
- if (!isCheckingUpdates) {
- isCheckingUpdates = true;
- checkForUpdates().finally(() => {
- isCheckingUpdates = false;
+ runUpdateCheck().finally(() => {
+ if (!document.hidden) {
start();
- });
- }
+ }
+ });
}
}
function stop() {
- clearInterval(timer.value);
+ if (timer.value !== undefined) {
+ clearInterval(timer.value);
+ timer.value = undefined;
+ }
+ versionCheckController?.abort();
+ versionCheckController = null;
}
onMounted(() => {