вложения, канальчики, бим-бим + бам-бам

This commit is contained in:
2026-04-25 00:51:12 +06:00
parent 0b75148a3f
commit ad477ee813
61 changed files with 14636 additions and 375 deletions

View File

@@ -16,7 +16,7 @@ export const useAuth = createGlobalState(() => {
async function login(username: string, password: string): Promise<void> {
try {
const result = await chadApi<Me>('/login', {
const result = await chadApi<Me>('/auth/login', {
method: 'POST',
body: {
username,
@@ -33,7 +33,7 @@ export const useAuth = createGlobalState(() => {
async function register(username: string, password: string): Promise<void> {
try {
const result = await chadApi<Me>('/register', {
const result = await chadApi<Me>('/auth/register', {
method: 'POST',
body: {
username,
@@ -50,7 +50,7 @@ export const useAuth = createGlobalState(() => {
async function logout(): Promise<void> {
try {
await chadApi('/logout', { method: 'POST' })
await chadApi('/auth/logout', { method: 'POST' })
setMe(undefined)

View File

@@ -1,22 +1,25 @@
import chadApi from '#shared/chad-api'
import { createGlobalState } from '@vueuse/core'
export interface ChatClientMessage {
text: string
replyTo?: {
messageId: string
}
// replyTo?: {
// messageId: string
// }
}
export interface ChatMessage {
id: string
sender: string
senderId: string
text: string
createdAt: string
replyTo?: {
messageId: string
sender: string
text: string
}
updatedAt: string
attachments: string[]
// replyTo?: {
// messageId: string
// sender: string
// text: string
// }
}
export const useChat = createGlobalState(() => {
@@ -41,16 +44,16 @@ export const useChat = createGlobalState(() => {
})
}, { immediate: true, flush: 'sync' })
function sendMessage(message: ChatClientMessage) {
if (!signaling.connected.value)
return
async function sendMessage(message: ChatClientMessage) {
message.text = message.text.trim()
if (!message.text.length)
return
signaling.socket.value!.emit('chat:message', message)
await chadApi<ChatMessage>('/chat/send', {
method: 'POST',
body: message,
})
}
return {

View File

@@ -42,7 +42,7 @@ export const usePreferences = createGlobalState(() => {
async ([toggleInputHotkey, toggleOutputHotkey]) => {
try {
await chadApi(
'/preferences',
'/user/preferences',
{
method: 'PATCH',
body: {