feat(web): add logout button for web mode

This commit is contained in:
lxk955 authored and GitHub committed 2026-10-04 02:03:56 +08:00
1 parent 7aa69a0e5e
commit e3ea4740c0
19 files changed
+405 -3

No files matched your search

+22 -1
View File
@@ -3,7 +3,7 @@ import { blockingDesktopAiRunsForUpdate } from "@/lib/ai/desktopAiRunRegistry";
import { setupUpdatePreparation, prepareUpdateWithDraftRecovery, isUpdatePreparationActive } from "@/lib/app/updatePreparation";
import { ref, computed, watch, onMounted, onUnmounted, nextTick, defineAsyncComponent, provide } from "vue";
import "vue-virtual-scroller/dist/vue-virtual-scroller.css";
import { checkStartupAuthentication, type StartupAuthentication } from "@/lib/startup/startupAuthentication";
import { checkStartupAuthentication, logoutWeb, type StartupAuthentication } from "@/lib/startup/startupAuthentication";
import { markStartupPhase } from "@/lib/startup/startupTiming";
import { clearStartupPreloadRetry } from "@/lib/startup/startupPreloadRecovery";
import { useI18n } from "vue-i18n";
@@ -4031,6 +4031,24 @@ function onLoginSuccess() {
void initApp();
}
async function handleWebLogout() {
if (!window.confirm(t("auth.logoutConfirm"))) return;
try {
await logoutWeb();
} catch (error) {
console.error("Failed to log out:", error);
} finally {
authenticated.value = false;
needsAuth.value = true;
const target = webPath("/login");
if (window.location.pathname === target) {
window.location.reload();
} else {
window.location.href = target;
}
}
}
async function initApp() {
const t0 = performance.now();
console.log("[STARTUP] initApp begin");
@@ -4356,6 +4374,7 @@ onUnmounted(() => {
:has-connections="connectionStore.connections.length > 0"
:can-new-query="canCreateNewQuery"
:has-sql-file-connections="hasSqlFileConnections"
:show-logout="!isDesktop && needsAuth"
@new-connection="showConnectionDialog = true"
@expand-sidebar="setSidebarOpen(true)"
@new-query="newQuery"
@@ -4375,6 +4394,7 @@ onUnmounted(() => {
@open-data-compare="dialogs.showDataCompareDialog.value = true"
@open-backups="openSettings('backups')"
@open-mcp-settings="openSettings('mcp')"
@logout="handleWebLogout"
/>
<div :class="isDetachedWindowContext ? 'flex-1 flex min-h-0' : isClassicLayout ? 'app-layout-classic flex-1 flex min-h-0' : 'app-panel-gutter flex-1 flex min-h-0 gap-1 p-1'">
@@ -4469,6 +4489,7 @@ onUnmounted(() => {
"
@open-mcp-settings="openSettings('mcp')"
@ai-config-deep-link-handled="settingsAiConfigDraft = null"
@logout="handleWebLogout"
/>
</AppTabBar>
<DetachedTabHeader