This repository was archived by the owner on Dec 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import { RouteRecordRaw } from "vue-router" ;
2+
3+ export const ExtensionAuthRoute = {
4+ path : "/extension/auth" ,
5+ name : "ExtensionAuth" ,
6+ component : ( ) => import ( "@/views/ExtensionAuth.vue" ) ,
7+ } as RouteRecordRaw ;
Original file line number Diff line number Diff line change 11import { RouteRecordRaw , createRouter , createWebHistory } from "vue-router" ;
22import { AdminRoute } from "./admin.route" ;
3+ import { ExtensionAuthRoute } from "./auth.route" ;
34import { CallbackRoute } from "./callback.route" ;
45import { EmoteSetRoute } from "./emote-sets.route" ;
56import { EmotesRoute } from "./emotes.route" ;
@@ -19,6 +20,7 @@ const routes: Array<RouteRecordRaw> = [
1920 HelpRoute ,
2021 AdminRoute ,
2122 ...CallbackRoute ,
23+ ExtensionAuthRoute ,
2224 {
2325 path : "/:pathMatch(.*)*" ,
2426 name : "Not Found" ,
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" extension-auth-content" >
3+ <LoginButton v-if =" !actor.user" />
4+ </div >
5+ </template >
6+
7+ <script setup lang="ts">
8+ import { watch } from " vue" ;
9+ import { useActor } from " @/store/actor" ;
10+ import { useStore } from " @/store/main" ;
11+ import LoginButton from " @/components/utility/LoginButton.vue" ;
12+
13+ const store = useStore ();
14+ const actor = useActor ();
15+ window .addEventListener (" message" , function listener(e ) {
16+ if (e .origin !== " https://www.twitch.tv" ) return ;
17+ if (e .data !== " 7tv-token-request" ) return ;
18+
19+ window .removeEventListener (" message" , listener );
20+ watch (
21+ () => store .authToken ,
22+ (t ) => {
23+ if (! t ) return ;
24+ e .source ?.postMessage ({ type: " 7tv-token" , token: t }, { targetOrigin: " https://www.twitch.tv/*" });
25+ },
26+ { immediate: true },
27+ );
28+ });
29+ </script >
30+
31+ <style lang="scss">
32+ nav {
33+ display : none ;
34+ }
35+ .extension-auth-content {
36+ display : flex ;
37+ margin : auto ;
38+ justify-content : center ;
39+ }
40+ </style >
You can’t perform that action at this time.
0 commit comments