This commit is contained in:
2026-02-22 18:35:59 +03:00
parent fd54fa75bd
commit 25750fee51
21 changed files with 400 additions and 222 deletions

29
src/stores/auth.ts Normal file
View File

@@ -0,0 +1,29 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useAuthStore = defineStore('auth', () => {
const token = ref(localStorage.getItem('token'))
async function login(email: string) {
try {
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: email }),
}
const res = await fetch('http://localhost:5173/login', options)
if (res.ok) {
const data: { accessToken: string; refreshToken: string } = await res.json()
token.value = data.accessToken
localStorage.setItem('token', token.value)
}
} catch (error) {
console.log(error)
}
}
return { token, login }
})

0
src/stores/chats.ts Normal file
View File

0
src/stores/messages.ts Normal file
View File

5
src/stores/sockets.ts Normal file
View File

@@ -0,0 +1,5 @@
import { defineStore } from 'pinia'
export const useSockets = defineStore('sockets', () => {
return {}
})

0
src/stores/users.ts Normal file
View File