This commit is contained in:
2026-06-21 19:11:23 +02:00
parent 3fd2b8ade8
commit e9d77fbd05
11 changed files with 96 additions and 77 deletions
+5
View File
@@ -1,5 +1,6 @@
import {defineStore} from 'pinia'
import {useApi} from "@/composables/useApi";
import {useGatewayStore} from "@/stores/gateway.ts";
export interface User {
id: string
@@ -36,6 +37,10 @@ export const useAuthStore = defineStore('auth', {
if (response.ok) {
const data = await response.json()
this.user = data.user
// Initialisation du gateway
const gatewayStore = useGatewayStore()
await gatewayStore.connect()
} else {
this.logout()
}
+16 -2
View File
@@ -1,4 +1,6 @@
import {defineStore} from 'pinia';
import {useAppStore} from "@/stores/app.ts";
import {useAuthStore} from "@/stores/auth.ts";
type GatewayStatus = 'disconnected' | 'connecting' | 'connected' | 'error'
@@ -15,9 +17,21 @@ export const useGatewayStore = defineStore('gateway', {
return
}
this.status = 'connecting'
const appStore = useAppStore()
const authStore = useAuthStore()
const wsUrl = `ws://localhost:3000/ws`
this.status = 'connecting'
const token = authStore.token
if (!token) {
this.status = 'error'
return
}
const apiUri = appStore.baseurl ? new URL(appStore.baseurl) : new URL(window.location.href)
const wsProtocol = apiUri.protocol === 'https:' ? 'wss:' : 'ws:'
const wsUrl = `${wsProtocol}//${apiUri.host}/ws/gateway?token=${encodeURIComponent(token)}`
const socket = new WebSocket(wsUrl)
socket.onopen = () => {
+3 -1
View File
@@ -1,6 +1,8 @@
import {defineStore} from "pinia";
export const useServerStore = defineStore("server", {
state: () => ({}),
state: () => ({
servers: []
}),
actions: {}
});