mirror of
https://github.com/1f349/mail.1f349.com.git
synced 2024-11-13 23:21:40 +00:00
Add websocket connection
This commit is contained in:
parent
17186d1752
commit
b50ef54f8f
@ -1,6 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {loginStore} from "./stores/login";
|
import {getBearer, loginStore} from "./stores/login";
|
||||||
import {openLoginPopup} from "./utils/login-popup";
|
import {openLoginPopup} from "./utils/login-popup";
|
||||||
|
|
||||||
|
let mainWS: WebSocket;
|
||||||
|
$: window.mainWS = mainWS;
|
||||||
|
|
||||||
|
function connectWS() {
|
||||||
|
mainWS = new WebSocket("https://api.1f349.com/v1/lotus/imap");
|
||||||
|
mainWS.addEventListener("open", () => {
|
||||||
|
mainWS.send(JSON.stringify({token: getBearer().slice(7)}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeLoginSession() {
|
||||||
|
$loginStore = null;
|
||||||
|
localStorage.removeItem("login-session");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
@ -19,14 +34,7 @@
|
|||||||
<div class="user-view">
|
<div class="user-view">
|
||||||
<img class="user-avatar" src={$loginStore.userinfo.picture} alt="{$loginStore.userinfo.name}'s profile picture" />
|
<img class="user-avatar" src={$loginStore.userinfo.picture} alt="{$loginStore.userinfo.name}'s profile picture" />
|
||||||
<div class="user-display-name">{$loginStore.userinfo.name}</div>
|
<div class="user-display-name">{$loginStore.userinfo.name}</div>
|
||||||
<button
|
<button on:click={() => removeLoginSession()}>Logout</button>
|
||||||
on:click={() => {
|
|
||||||
$loginStore = null;
|
|
||||||
localStorage.removeItem("login-session");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Logout
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</header>
|
</header>
|
||||||
|
Loading…
Reference in New Issue
Block a user