Ver código fonte

fix #6142: browser auto-close after 5min when operation complete

ethanfly 2 dias atrás
pai
commit
996585d5d7
1 arquivos alterados com 22 adições e 0 exclusões
  1. 22 0
      client/src/components/BrowserTab.vue

+ 22 - 0
client/src/components/BrowserTab.vue

@@ -307,6 +307,28 @@ const hasValidAccountInfo = computed(() => {
   return accountInfo.value.accountName && !defaultNames.includes(accountInfo.value.accountName);
 });
 
+// 操作完成则自动关闭(5分钟超时)
+let autoCloseTimer: ReturnType<typeof setTimeout> | null = null;
+watch(
+  () => [loginStatus.value, fetchingAccountInfo.value, hasValidAccountInfo.value],
+  ([status, fetching, valid]) => {
+    if (status === 'success' && !fetching && valid && !isAdminMode.value) {
+      // 操作完成,5分钟后自动关闭浏览器
+      if (autoCloseTimer) clearTimeout(autoCloseTimer);
+      autoCloseTimer = setTimeout(() => {
+        console.log('[BrowserTab] Operation complete, auto-closing browser');
+        tabsStore.closeTab(props.tab.id);
+      }, 5 * 60 * 1000);
+    } else {
+      // 操作未完成或失败,取消自动关闭
+      if (autoCloseTimer) {
+        clearTimeout(autoCloseTimer);
+        autoCloseTimer = null;
+      }
+    }
+  }
+);
+
 const initialUrl = computed(() => {
   // 对于百家号管理模式且有预设 Cookie,先跳转到登录页面设置 Cookie
   if (platform.value === 'baijiahao' &&