@@ -23,13 +23,20 @@ import axios from 'axios'
2323import {
2424 useRouter , useRoute
2525} from ' vue-router'
26+ const route = useRoute ()
27+ const apiWithToken = axios .create ({
28+ baseURL: ' https://gaas-magician-backend.azurewebsites.net/' ,
29+ headers: {
30+ ' Content-Type' : ' application/json' ,
31+ Authorization: ' Bearer ' + route .query .token ,
32+ },
33+ })
2634const api = axios .create ({
2735 baseURL: ' https://gaas-magician-backend.azurewebsites.net/' ,
2836 headers: {
2937 ' Content-Type' : ' application/json' ,
3038 },
3139})
32- const route = useRoute ()
3340const router = useRouter ()
3441const gameStore = useGameStore ()
3542const socket = ref (null )
@@ -39,6 +46,15 @@ const playerId = ref('Leave3310')
3946const playerIds = [ ' Leave3310' , ' Momo' , ' Yock' , ' Tux' , ' Teds' ]
4047const showHint1 = ref (false )
4148const showHintStart = ref (false )
49+
50+ console .log (route, ' route' )
51+ console .log (' gameId: ' , route .params .gameId )
52+ console .log (' user token: ' , route .query .token )
53+ apiWithToken .get (' /me' ).then ((res ) => {
54+ console .log (res .data , ' me' )
55+ playerId .value = res .data .player_id
56+ })
57+
4258const gameOver = computed (() => gameStore .gameOver )
4359const handleConnect = () => {
4460 socket .value = io (import .meta.env.VITE_SOCKET_IO_URL, {
@@ -109,8 +125,9 @@ const showWarehouse = computed(() => {
109125 return gameStore .hoverMagic === 4
110126})
111127const getGameStatus = async () => {
112- const gameRoomID = route .query .gameRoomID
113- const player_id = route .query .playerId || playerId .value
128+ // const gameRoomID = route.query.gameRoomID
129+ const gameRoomID = route .params .gameId
130+ const player_id = playerId .value
114131 const params = {
115132 gameRoomID,
116133 player_id,
@@ -159,9 +176,11 @@ watch(
159176)
160177onMounted (() => {
161178 if (route .query .gameRoomID && route .query .playerId ) {
162- playerId .value = route .query .playerId
163- handleConnect ()
179+ // playerId.value = route.query.playerId
180+ // handleConnect()
164181 }
182+ handleConnect ()
183+
165184 console .log (' mounted' )
166185 console .log (import .meta.env.VITE_SOCKET_IO_URL)
167186})
0 commit comments