File tree Expand file tree Collapse file tree
src/apps/core/switchserver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { MessageBox } from "$ts/util/dialog";
55import { Store } from "$ts/writable" ;
66import type { App , AppProcessData } from "$types/app" ;
77import type { ServerOption } from "$types/server" ;
8-
8+ import Cookies from "js-cookie" ;
99export class SwitchServerRuntime extends AppProcess {
1010 servers = Store < ServerOption [ ] > ( [ ] ) ;
1111 selected = Store < string > ( ) ;
@@ -45,11 +45,22 @@ export class SwitchServerRuntime extends AppProcess {
4545 this . loading . set ( true ) ;
4646 this . connectionError . set ( false ) ;
4747
48+ const currentServer = Server . url ;
49+
4850 const result = await Server . switchServer ( server . url ) ;
4951
5052 this . loading . set ( false ) ;
51- if ( ! result ) this . connectionError . set ( true ) ;
52- else location . reload ( ) ;
53+ if ( ! result ) {
54+ this . connectionError . set ( true ) ;
55+ } else {
56+ if ( currentServer !== server . url ) {
57+ Cookies . remove ( "arcToken" ) ;
58+ Cookies . remove ( "arcUsername" ) ;
59+ localStorage . removeItem ( "arcLoginPersistence" ) ;
60+ }
61+
62+ location . reload ( ) ;
63+ }
5364 }
5465
5566 async removeServer ( server : ServerOption ) {
You can’t perform that action at this time.
0 commit comments