diff --git a/src/apps/core/switchserver/runtime.ts b/src/apps/core/switchserver/runtime.ts index 469b4185..53218086 100644 --- a/src/apps/core/switchserver/runtime.ts +++ b/src/apps/core/switchserver/runtime.ts @@ -5,7 +5,7 @@ import { MessageBox } from "$ts/util/dialog"; import { Store } from "$ts/writable"; import type { App, AppProcessData } from "$types/app"; import type { ServerOption } from "$types/server"; - +import Cookies from "js-cookie"; export class SwitchServerRuntime extends AppProcess { servers = Store([]); selected = Store(); @@ -45,11 +45,22 @@ export class SwitchServerRuntime extends AppProcess { this.loading.set(true); this.connectionError.set(false); + const currentServer = Server.url; + const result = await Server.switchServer(server.url); this.loading.set(false); - if (!result) this.connectionError.set(true); - else location.reload(); + if (!result) { + this.connectionError.set(true); + } else { + if (currentServer !== server.url) { + Cookies.remove("arcToken"); + Cookies.remove("arcUsername"); + localStorage.removeItem("arcLoginPersistence"); + } + + location.reload(); + } } async removeServer(server: ServerOption) {