From 27ab4c870dd4f4b3bec5eb92c5f181ac00c17c55 Mon Sep 17 00:00:00 2001 From: adb-sh Date: Wed, 19 Oct 2022 10:52:30 +0200 Subject: [PATCH] implement embed mode; add MePage --- src/Api.ts | 19 ++++- src/App.vue | 5 +- src/components/CurrentlyPlayingCompact.vue | 25 ++++++ src/components/PromiseResolver.vue | 1 + src/router/index.ts | 14 +++- src/views/AuthCallbackPage.vue | 1 - src/views/MePage.vue | 39 +++++++++ src/views/UserPage.vue | 97 +++++++++++++--------- 8 files changed, 157 insertions(+), 44 deletions(-) create mode 100644 src/components/CurrentlyPlayingCompact.vue create mode 100644 src/views/MePage.vue diff --git a/src/Api.ts b/src/Api.ts index fb021e5..1c38917 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -21,7 +21,11 @@ export class Api { this.baseURL = baseURL; this.authBaseURL = authBaseURL; this.publicBaseURL = publicBaseURL; - this.accessToken = accessToken ?? localStorage.getItem("access-token"); + try{ + this.accessToken = accessToken ?? localStorage?.getItem("access-token"); + } catch (e) { + this.accessToken = null; + } this.axios = axios.create({ baseURL }); this.axios.interceptors.request.use(({ headers = {}, ...config }) => ({ ...config, @@ -63,11 +67,20 @@ export class Api { return (await this.axiosPublic.get(`/users/${userId}/info`))?.data; } + async getSession() { + return (await this.axios.get(`/session`))?.data; + } + async createSession() { + return (await this.axios.post(`/session`))?.data; + } + async deleteSession() { + return (await this.axios.delete(`/session`))?.data; + } async joinSession(hostId: string) { return (await this.axios.post(`/session/join`, { hostId }))?.data; } - async leaveSession(hostId: string) { - return (await this.axios.post(`/session/session`, { hostId }))?.data; + async leaveSession() { + return (await this.axios.post(`/session/leave`))?.data; } } diff --git a/src/App.vue b/src/App.vue index a7a3ad8..beadaf7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,8 @@