diff --git a/desktop/src/App.vue b/desktop/src/App.vue index eb2e2d1..a330638 100644 --- a/desktop/src/App.vue +++ b/desktop/src/App.vue @@ -5,15 +5,29 @@ import LoginView from "./features/auth/LoginView.vue"; import Shell from "./shell/Shell.vue"; import type { UserInfo } from "./features/auth/api"; import { isDark, themeOverrides } from "./shared/theme"; +import { clearUnauthorized, setUnauthorizedHandler } from "./shared/http"; const user = ref(null); +const authNotice = ref(""); + +setUnauthorizedHandler(() => { + if (!user.value) return; + user.value = null; + authNotice.value = "登录已失效,请重新登录"; +}); + +function onSuccess(next: UserInfo) { + authNotice.value = ""; + clearUnauthorized(); + user.value = next; +}