ваше сообщение коммита
This commit is contained in:
@@ -554,31 +554,35 @@ router.post('/link-identity', async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Проверка статуса аутентификации
|
// Проверка статуса аутентификации
|
||||||
router.get('/check', (req, res) => {
|
router.get('/check', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
console.log('Сессия при проверке:', req.session);
|
console.log('Сессия при проверке:', req.session);
|
||||||
|
|
||||||
const authenticated = req.session.authenticated || req.session.isAuthenticated || false;
|
// Если пользователь не аутентифицирован, возвращаем базовую информацию
|
||||||
const userId = req.session.userId;
|
if (!req.session.authenticated) {
|
||||||
const authType = req.session.authType;
|
return res.json({
|
||||||
const address = req.session.address;
|
authenticated: false,
|
||||||
const telegramId = req.session.telegramId;
|
userId: null,
|
||||||
const email = req.session.email;
|
authType: null,
|
||||||
|
address: null,
|
||||||
// Проверяем, является ли пользователь администратором
|
telegramId: null,
|
||||||
const isAdmin = req.session.userRole === 'admin';
|
email: null,
|
||||||
|
isAdmin: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Возвращаем полную информацию об аутентифицированном пользователе
|
||||||
res.json({
|
res.json({
|
||||||
authenticated,
|
authenticated: true,
|
||||||
userId,
|
userId: req.session.userId,
|
||||||
isAdmin,
|
authType: req.session.authType,
|
||||||
authType,
|
address: req.session.address,
|
||||||
address,
|
telegramId: req.session.telegramId,
|
||||||
telegramId,
|
email: req.session.email,
|
||||||
email
|
isAdmin: req.session.isAdmin || false
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error checking auth:', error);
|
console.error('Error checking auth status:', error);
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,19 +44,29 @@ async function processGuestMessages(userId, guestId) {
|
|||||||
for (const guestMessage of guestMessages) {
|
for (const guestMessage of guestMessages) {
|
||||||
console.log(`Processing guest message ID ${guestMessage.id}: ${guestMessage.content}`);
|
console.log(`Processing guest message ID ${guestMessage.id}: ${guestMessage.content}`);
|
||||||
|
|
||||||
|
// Проверяем существование гостевого сообщения перед созданием связанного сообщения
|
||||||
|
const checkGuestMessage = await db.query(
|
||||||
|
'SELECT id FROM guest_messages WHERE id = $1',
|
||||||
|
[guestMessage.id]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (checkGuestMessage.rows.length === 0) {
|
||||||
|
console.log(`Guest message ${guestMessage.id} no longer exists, skipping`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Сохраняем сообщение пользователя
|
// Сохраняем сообщение пользователя
|
||||||
const userMessageResult = await db.query(
|
const userMessageResult = await db.query(
|
||||||
`INSERT INTO messages
|
`INSERT INTO messages
|
||||||
(conversation_id, content, sender_type, role, guest_message_id, channel, created_at)
|
(conversation_id, content, sender_type, role, channel, created_at)
|
||||||
VALUES
|
VALUES
|
||||||
($1, $2, $3, $4, $5, $6, $7)
|
($1, $2, $3, $4, $5, $6)
|
||||||
RETURNING *`,
|
RETURNING *`,
|
||||||
[
|
[
|
||||||
conversation.id,
|
conversation.id,
|
||||||
guestMessage.content,
|
guestMessage.content,
|
||||||
'user',
|
'user',
|
||||||
'user',
|
'user',
|
||||||
guestMessage.id,
|
|
||||||
'web',
|
'web',
|
||||||
guestMessage.created_at
|
guestMessage.created_at
|
||||||
]
|
]
|
||||||
@@ -73,28 +83,27 @@ async function processGuestMessages(userId, guestId) {
|
|||||||
// Сохраняем ответ от ИИ
|
// Сохраняем ответ от ИИ
|
||||||
const aiMessageResult = await db.query(
|
const aiMessageResult = await db.query(
|
||||||
`INSERT INTO messages
|
`INSERT INTO messages
|
||||||
(conversation_id, content, sender_type, role, guest_message_id, channel, created_at)
|
(conversation_id, content, sender_type, role, channel, created_at)
|
||||||
VALUES
|
VALUES
|
||||||
($1, $2, $3, $4, $5, $6, $7)
|
($1, $2, $3, $4, $5, $6)
|
||||||
RETURNING *`,
|
RETURNING *`,
|
||||||
[
|
[
|
||||||
conversation.id,
|
conversation.id,
|
||||||
aiResponse,
|
aiResponse,
|
||||||
'assistant',
|
'assistant',
|
||||||
'assistant',
|
'assistant',
|
||||||
guestMessage.id,
|
|
||||||
'web',
|
'web',
|
||||||
new Date()
|
new Date()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`Saved AI response with ID ${aiMessageResult.rows[0].id}`);
|
console.log(`Saved AI response with ID ${aiMessageResult.rows[0].id}`);
|
||||||
|
|
||||||
|
// Удаляем обработанное гостевое сообщение
|
||||||
|
await db.query('DELETE FROM guest_messages WHERE id = $1', [guestMessage.id]);
|
||||||
|
console.log(`Deleted processed guest message ${guestMessage.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Удаляем гостевые сообщения, так как они уже обработаны
|
|
||||||
await db.query('DELETE FROM guest_messages WHERE guest_id = $1', [guestId]);
|
|
||||||
console.log('Deleted processed guest messages');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `Processed ${guestMessages.length} guest messages`,
|
message: `Processed ${guestMessages.length} guest messages`,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ async function checkOllamaModels() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
console.log('\nДля использования конкретной модели, укажите ее в .env файле:');
|
console.log('\nДля использования конкретной модели, укажите ее в .env файле:');
|
||||||
console.log('OLLAMA_EMBEDDINGS_MODEL=mistral');
|
console.log('OLLAMA_EMBEDDINGS_MODEL=mistral:7b-instruct-q4_K_M');
|
||||||
console.log('OLLAMA_MODEL=mistral');
|
console.log('OLLAMA_MODEL=mistral:7b-instruct-q4_K_M');
|
||||||
} else {
|
} else {
|
||||||
console.log('Не удалось получить список моделей');
|
console.log('Не удалось получить список моделей');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const fetch = require('node-fetch');
|
|||||||
class AIAssistant {
|
class AIAssistant {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.baseUrl = process.env.OLLAMA_BASE_URL || 'http://localhost:11434';
|
this.baseUrl = process.env.OLLAMA_BASE_URL || 'http://localhost:11434';
|
||||||
this.defaultModel = process.env.OLLAMA_MODEL || 'mistral';
|
this.defaultModel = process.env.OLLAMA_MODEL || 'mistral:7b-instruct-q4_K_M';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создание экземпляра ChatOllama с нужными параметрами
|
// Создание экземпляра ChatOllama с нужными параметрами
|
||||||
|
|||||||
@@ -6,18 +6,18 @@ export function useAuth() {
|
|||||||
const authType = ref(null);
|
const authType = ref(null);
|
||||||
const userId = ref(null);
|
const userId = ref(null);
|
||||||
const address = ref(null);
|
const address = ref(null);
|
||||||
const telegramInfo = ref(null);
|
|
||||||
const isAdmin = ref(false);
|
|
||||||
const telegramId = ref(null);
|
const telegramId = ref(null);
|
||||||
|
const isAdmin = ref(false);
|
||||||
const email = ref(null);
|
const email = ref(null);
|
||||||
|
|
||||||
const updateAuth = ({ authenticated, authType: newAuthType, userId: newUserId, address: newAddress, telegramId: newTelegramId, isAdmin: newIsAdmin }) => {
|
const updateAuth = ({ authenticated, authType: newAuthType, userId: newUserId, address: newAddress, telegramId: newTelegramId, isAdmin: newIsAdmin, email: newEmail }) => {
|
||||||
isAuthenticated.value = authenticated;
|
isAuthenticated.value = authenticated;
|
||||||
authType.value = newAuthType;
|
authType.value = newAuthType;
|
||||||
userId.value = newUserId;
|
userId.value = newUserId;
|
||||||
address.value = newAddress;
|
address.value = newAddress;
|
||||||
telegramId.value = newTelegramId;
|
telegramId.value = newTelegramId;
|
||||||
isAdmin.value = newIsAdmin;
|
isAdmin.value = newIsAdmin;
|
||||||
|
email.value = newEmail;
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkAuth = async () => {
|
const checkAuth = async () => {
|
||||||
@@ -49,6 +49,7 @@ export function useAuth() {
|
|||||||
userId: null,
|
userId: null,
|
||||||
address: null,
|
address: null,
|
||||||
telegramId: null,
|
telegramId: null,
|
||||||
|
email: null,
|
||||||
isAdmin: false
|
isAdmin: false
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -58,9 +59,6 @@ export function useAuth() {
|
|||||||
localStorage.removeItem('address');
|
localStorage.removeItem('address');
|
||||||
localStorage.removeItem('isAdmin');
|
localStorage.removeItem('isAdmin');
|
||||||
|
|
||||||
// Перезагружаем страницу
|
|
||||||
window.location.reload();
|
|
||||||
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error disconnecting:', error);
|
console.error('Error disconnecting:', error);
|
||||||
@@ -77,7 +75,6 @@ export function useAuth() {
|
|||||||
authType,
|
authType,
|
||||||
userId,
|
userId,
|
||||||
address,
|
address,
|
||||||
telegramInfo,
|
|
||||||
isAdmin,
|
isAdmin,
|
||||||
telegramId,
|
telegramId,
|
||||||
email,
|
email,
|
||||||
|
|||||||
@@ -182,14 +182,14 @@
|
|||||||
<div v-if="auth.address?.value" class="user-info-item">
|
<div v-if="auth.address?.value" class="user-info-item">
|
||||||
<span class="user-info-label">Кошелек:</span>
|
<span class="user-info-label">Кошелек:</span>
|
||||||
<span class="user-info-value">{{ truncateAddress(auth.address.value) }}</span>
|
<span class="user-info-value">{{ truncateAddress(auth.address.value) }}</span>
|
||||||
</div>
|
|
||||||
<div v-if="auth.telegramId?.value" class="user-info-item">
|
|
||||||
<span class="user-info-label">Telegram:</span>
|
|
||||||
<span class="user-info-value">{{ auth.telegramId.value }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="auth.email?.value" class="user-info-item">
|
<div v-if="auth.telegramId" class="user-info-item">
|
||||||
|
<span class="user-info-label">Telegram:</span>
|
||||||
|
<span class="user-info-value">{{ auth.telegramId }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="auth.email" class="user-info-item">
|
||||||
<span class="user-info-label">Email:</span>
|
<span class="user-info-label">Email:</span>
|
||||||
<span class="user-info-value">{{ auth.email.value }}</span>
|
<span class="user-info-value">{{ auth.email }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -551,6 +551,29 @@ const cancelTelegramAuth = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Загружаем сообщения при изменении аутентификации
|
||||||
|
watch(() => isAuthenticated.value, async (newValue, oldValue) => {
|
||||||
|
// Если пользователь только что авторизовался
|
||||||
|
if (newValue && !oldValue) {
|
||||||
|
try {
|
||||||
|
// Связываем гостевые сообщения только один раз при первой авторизации
|
||||||
|
const response = await api.post('/api/chat/link-guest-messages');
|
||||||
|
console.log('Guest messages linking response:', response.data);
|
||||||
|
} catch (linkError) {
|
||||||
|
console.error('Error linking guest messages:', linkError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// В любом случае перезагружаем сообщения
|
||||||
|
messages.value = [];
|
||||||
|
offset.value = 0;
|
||||||
|
hasMoreMessages.value = true;
|
||||||
|
await loadMoreMessages();
|
||||||
|
|
||||||
|
await nextTick();
|
||||||
|
scrollToBottom();
|
||||||
|
});
|
||||||
|
|
||||||
// Обработчик для Telegram аутентификации
|
// Обработчик для Telegram аутентификации
|
||||||
const handleTelegramAuth = async () => {
|
const handleTelegramAuth = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -569,38 +592,19 @@ const handleTelegramAuth = async () => {
|
|||||||
console.log('Проверка авторизации:', response.data);
|
console.log('Проверка авторизации:', response.data);
|
||||||
|
|
||||||
if (response.data.authenticated) {
|
if (response.data.authenticated) {
|
||||||
// Обновляем состояние аутентификации
|
// Обновляем состояние аутентификации с полным набором данных
|
||||||
auth.updateAuth({
|
auth.updateAuth({
|
||||||
isAuthenticated: true,
|
isAuthenticated: true,
|
||||||
|
authenticated: true,
|
||||||
authType: response.data.authType,
|
authType: response.data.authType,
|
||||||
userId: response.data.userId,
|
userId: response.data.userId,
|
||||||
telegramId: response.data.telegramId
|
telegramId: response.data.telegramId,
|
||||||
|
isAdmin: response.data.isAdmin,
|
||||||
|
address: response.data.address
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Telegram authentication successful:', response.data);
|
console.log('Telegram authentication successful:', response.data);
|
||||||
|
|
||||||
// Обновляем все данные пользователя
|
|
||||||
await auth.checkAuth();
|
|
||||||
|
|
||||||
// Загружаем историю сообщений
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
hasMoreMessages.value = true;
|
|
||||||
await loadMoreMessages();
|
|
||||||
|
|
||||||
// Связываем гостевые сообщения
|
|
||||||
try {
|
|
||||||
await api.post('/api/chat/link-guest-messages');
|
|
||||||
console.log('Guest messages linked to authenticated user');
|
|
||||||
|
|
||||||
// Перезагружаем сообщения после связывания
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
await loadMoreMessages();
|
|
||||||
} catch (linkError) {
|
|
||||||
console.error('Error linking guest messages:', linkError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Обновляем баланс токенов
|
// Обновляем баланс токенов
|
||||||
await updateBalances();
|
await updateBalances();
|
||||||
|
|
||||||
@@ -697,35 +701,6 @@ const loadMoreMessages = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Загружаем сообщения при изменении аутентификации
|
|
||||||
watch(() => isAuthenticated.value, async (newValue, oldValue) => {
|
|
||||||
// Если пользователь только что авторизовался
|
|
||||||
if (newValue && !oldValue) {
|
|
||||||
try {
|
|
||||||
// Связываем гостевые сообщения (копируем из guest_messages в messages)
|
|
||||||
await api.post('/api/chat/link-guest-messages');
|
|
||||||
console.log('Guest messages linked to authenticated user');
|
|
||||||
|
|
||||||
// Перезагружаем все сообщения
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
hasMoreMessages.value = true;
|
|
||||||
await loadMoreMessages();
|
|
||||||
|
|
||||||
await nextTick();
|
|
||||||
scrollToBottom();
|
|
||||||
} catch (linkError) {
|
|
||||||
console.error('Error linking guest messages:', linkError);
|
|
||||||
}
|
|
||||||
} else if (!newValue && oldValue) {
|
|
||||||
// Если пользователь вышел из системы, загружаем только гостевые сообщения
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
hasMoreMessages.value = true;
|
|
||||||
await loadMoreMessages(); // Загрузит гостевые сообщения, если они есть
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Функция для подключения кошелька
|
// Функция для подключения кошелька
|
||||||
const handleWalletAuth = async () => {
|
const handleWalletAuth = async () => {
|
||||||
if (isConnecting.value || isAuthenticated.value) return;
|
if (isConnecting.value || isAuthenticated.value) return;
|
||||||
@@ -739,25 +714,6 @@ const handleWalletAuth = async () => {
|
|||||||
// Обновляем состояние авторизации
|
// Обновляем состояние авторизации
|
||||||
await auth.checkAuth();
|
await auth.checkAuth();
|
||||||
|
|
||||||
// Загружаем историю сообщений
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
hasMoreMessages.value = true;
|
|
||||||
await loadMoreMessages();
|
|
||||||
|
|
||||||
// Связываем гостевые сообщения
|
|
||||||
try {
|
|
||||||
await api.post('/api/chat/link-guest-messages');
|
|
||||||
console.log('Guest messages linked to authenticated user');
|
|
||||||
|
|
||||||
// Перезагружаем сообщения после связывания
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
await loadMoreMessages();
|
|
||||||
} catch (linkError) {
|
|
||||||
console.error('Error linking guest messages:', linkError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Добавляем небольшую задержку перед сбросом состояния isConnecting
|
// Добавляем небольшую задержку перед сбросом состояния isConnecting
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
isConnecting.value = false;
|
isConnecting.value = false;
|
||||||
|
|||||||
@@ -1,663 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<!-- Боковая панель -->
|
|
||||||
<div class="sidebar">
|
|
||||||
<button class="menu-button">
|
|
||||||
<div class="hamburger"></div>
|
|
||||||
</button>
|
|
||||||
<div class="nav-buttons">
|
|
||||||
<button class="nav-btn">1</button>
|
|
||||||
<button class="nav-btn">2</button>
|
|
||||||
<button class="nav-btn">3</button>
|
|
||||||
<button class="nav-btn">4</button>
|
|
||||||
<button class="nav-btn">5</button>
|
|
||||||
<button class="nav-btn">6</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Основной контент -->
|
|
||||||
<div class="main-content">
|
|
||||||
<div class="header">
|
|
||||||
<div class="title">
|
|
||||||
<span class="hand-emoji">✌️</span> HB3 - Accelerator DLE (Digital Legal Entity - DAO Fork)
|
|
||||||
</div>
|
|
||||||
<div class="subtitle">
|
|
||||||
Венчурный фонд и поставщик программного обеспечения
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="chat-container">
|
|
||||||
<div class="chat-messages" ref="messagesContainer">
|
|
||||||
<div v-for="message in messages" :key="message.id"
|
|
||||||
:class="['message', message.role === 'assistant' ? 'ai-message' : 'user-message']">
|
|
||||||
<div class="message-content" v-html="formatMessage(message.content)"></div>
|
|
||||||
<div class="message-time">{{ formatTime(message.timestamp || message.created_at) }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="chat-input">
|
|
||||||
<textarea
|
|
||||||
v-model="newMessage"
|
|
||||||
placeholder="Введите сообщение..."
|
|
||||||
@keydown.enter.prevent="handleMessage(newMessage)"
|
|
||||||
:disabled="isLoading"
|
|
||||||
></textarea>
|
|
||||||
<button @click="handleMessage(newMessage)" :disabled="isLoading || !newMessage.trim()">
|
|
||||||
{{ isLoading ? 'Отправка...' : 'Отправить' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Правая панель с информацией о кошельке -->
|
|
||||||
<div class="wallet-sidebar">
|
|
||||||
<button v-if="!isAuthenticated" @click="handleWalletAuth" class="wallet-connect-btn">
|
|
||||||
Подключить кошелек
|
|
||||||
</button>
|
|
||||||
<button v-else @click="disconnectWallet" class="wallet-disconnect-btn">
|
|
||||||
Отключить кошелек
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- Добавляем дополнительные кнопки авторизации -->
|
|
||||||
<div v-if="!isAuthenticated" class="auth-buttons">
|
|
||||||
<button @click="handleTelegramAuth" class="auth-btn telegram-btn">
|
|
||||||
Подключить Telegram
|
|
||||||
</button>
|
|
||||||
<button @click="handleEmailAuth" class="auth-btn email-btn">
|
|
||||||
Подключить Email
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Блок для верификации Telegram -->
|
|
||||||
<div v-if="showTelegramVerification" class="verification-block">
|
|
||||||
<div class="verification-code">
|
|
||||||
<span>Код верификации:</span>
|
|
||||||
<code @click="copyCode(telegramVerificationCode)">{{ telegramVerificationCode }}</code>
|
|
||||||
<span v-if="codeCopied" class="copied-message">Скопировано!</span>
|
|
||||||
</div>
|
|
||||||
<a :href="telegramBotLink" target="_blank" class="bot-link">Открыть бота Telegram</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Форма для Email верификации -->
|
|
||||||
<div v-if="showEmailForm" class="email-form">
|
|
||||||
<p>Введите ваш email для получения кода подтверждения:</p>
|
|
||||||
<div class="email-input-container">
|
|
||||||
<input
|
|
||||||
v-model="emailInput"
|
|
||||||
type="email"
|
|
||||||
placeholder="Ваш email"
|
|
||||||
class="email-input"
|
|
||||||
:class="{ 'email-input-error': emailFormatError }"
|
|
||||||
/>
|
|
||||||
<button @click="sendEmailVerification" class="send-email-btn" :disabled="isEmailSending">
|
|
||||||
{{ isEmailSending ? 'Отправка...' : 'Отправить код' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p v-if="emailFormatError" class="email-format-error">Пожалуйста, введите корректный email</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Сообщение об ошибке в Email -->
|
|
||||||
<div v-if="emailError" class="error-message">
|
|
||||||
{{ emailError }}
|
|
||||||
<button class="close-error" @click="clearEmailError">×</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Форма для ввода кода верификации Email -->
|
|
||||||
<div v-if="showEmailVerificationInput" class="email-verification-form">
|
|
||||||
<p>На ваш email <strong>{{ emailVerificationEmail }}</strong> отправлен код подтверждения.</p>
|
|
||||||
<div class="verification-input">
|
|
||||||
<input
|
|
||||||
v-model="emailVerificationCode"
|
|
||||||
type="text"
|
|
||||||
placeholder="Введите код верификации"
|
|
||||||
maxlength="6"
|
|
||||||
/>
|
|
||||||
<button @click="verifyEmailCode" class="verify-btn" :disabled="isVerifying">
|
|
||||||
{{ isVerifying ? 'Проверка...' : 'Подтвердить' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Блок баланса токенов -->
|
|
||||||
<div class="balance-container">
|
|
||||||
<h3>Баланс:</h3>
|
|
||||||
<div class="token-balance">
|
|
||||||
<span class="token-name">ETH:</span>
|
|
||||||
<span class="token-amount">{{ isAuthenticated ? '1500000' : '0' }}</span>
|
|
||||||
<span class="token-symbol">HB3A</span>
|
|
||||||
</div>
|
|
||||||
<div class="token-balance">
|
|
||||||
<span class="token-name">ARB:</span>
|
|
||||||
<span class="token-amount">{{ isAuthenticated ? '500000' : '0' }}</span>
|
|
||||||
<span class="token-symbol">HB3A</span>
|
|
||||||
</div>
|
|
||||||
<div class="token-balance">
|
|
||||||
<span class="token-name">POL:</span>
|
|
||||||
<span class="token-amount">{{ isAuthenticated ? '500000' : '0' }}</span>
|
|
||||||
<span class="token-symbol">HB3A</span>
|
|
||||||
</div>
|
|
||||||
<div class="token-balance">
|
|
||||||
<span class="token-name">BNB:</span>
|
|
||||||
<span class="token-amount">0</span>
|
|
||||||
<span class="token-symbol">HB3A</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Блок информации о пользователе -->
|
|
||||||
<div v-if="isAuthenticated" class="user-info">
|
|
||||||
<h3>Идентификаторы:</h3>
|
|
||||||
<div v-if="auth.address?.value" class="user-info-item">
|
|
||||||
<span class="user-info-label">Кошелек:</span>
|
|
||||||
<span class="user-info-value">{{ truncateAddress(auth.address.value) }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="auth.telegramId?.value" class="user-info-item">
|
|
||||||
<span class="user-info-label">Telegram:</span>
|
|
||||||
<span class="user-info-value">{{ auth.telegramId.value }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="auth.email?.value" class="user-info-item">
|
|
||||||
<span class="user-info-label">Email:</span>
|
|
||||||
<span class="user-info-value">{{ auth.email.value }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="language-selector">
|
|
||||||
RU <span class="dropdown-icon">▼</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref, computed, onMounted, watch, nextTick, onBeforeUnmount } from 'vue';
|
|
||||||
import { useAuth } from '../composables/useAuth';
|
|
||||||
import { connectWithWallet } from '../services/wallet';
|
|
||||||
import axios from 'axios';
|
|
||||||
import api from '../api/axios';
|
|
||||||
import DOMPurify from 'dompurify';
|
|
||||||
import { marked } from 'marked';
|
|
||||||
import '../assets/styles/home.css';
|
|
||||||
|
|
||||||
console.log('HomeView.vue: Version with chat loaded');
|
|
||||||
|
|
||||||
const auth = useAuth();
|
|
||||||
const isAuthenticated = computed(() => auth.isAuthenticated.value);
|
|
||||||
const isConnecting = ref(false);
|
|
||||||
const messages = ref([]);
|
|
||||||
const newMessage = ref('');
|
|
||||||
const isLoading = ref(false);
|
|
||||||
const messagesContainer = ref(null);
|
|
||||||
const userLanguage = ref('ru');
|
|
||||||
|
|
||||||
// Состояния для пагинации
|
|
||||||
const isLoadingMore = ref(false);
|
|
||||||
const hasMoreMessages = ref(false);
|
|
||||||
const offset = ref(0);
|
|
||||||
const limit = ref(20);
|
|
||||||
|
|
||||||
// Состояния для верификации
|
|
||||||
const showTelegramVerification = ref(false);
|
|
||||||
const telegramVerificationCode = ref('');
|
|
||||||
const telegramBotLink = ref('');
|
|
||||||
const telegramAuthCheckInterval = ref(null);
|
|
||||||
const showEmailVerification = ref(false);
|
|
||||||
const emailVerificationCode = ref('');
|
|
||||||
const emailError = ref('');
|
|
||||||
const codeCopied = ref(false);
|
|
||||||
const showEmailAlternatives = ref(false);
|
|
||||||
|
|
||||||
// Состояния для формы ввода кода
|
|
||||||
const showEmailVerificationInput = ref(false);
|
|
||||||
const emailVerificationEmail = ref('');
|
|
||||||
|
|
||||||
// Состояния для формы ввода email
|
|
||||||
const showEmailForm = ref(false);
|
|
||||||
const emailInput = ref('');
|
|
||||||
const emailFormatError = ref(false);
|
|
||||||
const isEmailSending = ref(false);
|
|
||||||
|
|
||||||
// Состояния для индикации и успешных сообщений
|
|
||||||
const isVerifying = ref(false);
|
|
||||||
const successMessage = ref('');
|
|
||||||
const showSuccessMessage = ref(false);
|
|
||||||
|
|
||||||
// Функция для копирования кода
|
|
||||||
const copyCode = (code) => {
|
|
||||||
navigator.clipboard.writeText(code).then(() => {
|
|
||||||
codeCopied.value = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
codeCopied.value = false;
|
|
||||||
}, 2000);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для очистки ошибки
|
|
||||||
const clearEmailError = () => {
|
|
||||||
emailError.value = '';
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для обработки Email аутентификации
|
|
||||||
const handleEmailAuth = async () => {
|
|
||||||
try {
|
|
||||||
// Показываем форму для ввода email
|
|
||||||
showEmailForm.value = true;
|
|
||||||
// Сбрасываем другие состояния форм
|
|
||||||
showEmailVerification.value = false;
|
|
||||||
showEmailVerificationInput.value = false;
|
|
||||||
// Очищаем поля и ошибки
|
|
||||||
emailInput.value = '';
|
|
||||||
emailFormatError.value = false;
|
|
||||||
emailError.value = '';
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error in email auth:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для отправки запроса на верификацию email
|
|
||||||
const sendEmailVerification = async () => {
|
|
||||||
try {
|
|
||||||
emailFormatError.value = false;
|
|
||||||
emailError.value = '';
|
|
||||||
|
|
||||||
// Проверяем формат email
|
|
||||||
if (!emailInput.value || !emailInput.value.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
|
|
||||||
emailFormatError.value = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isEmailSending.value = true;
|
|
||||||
|
|
||||||
// Отправляем запрос на сервер для инициализации email аутентификации
|
|
||||||
const response = await axios.post('/api/auth/email/init', { email: emailInput.value });
|
|
||||||
|
|
||||||
if (response.data.success) {
|
|
||||||
// Скрываем форму ввода email
|
|
||||||
showEmailForm.value = false;
|
|
||||||
// Показываем форму для ввода кода
|
|
||||||
showEmailVerificationInput.value = true;
|
|
||||||
// Скрываем старую форму кода верификации
|
|
||||||
showEmailVerification.value = false;
|
|
||||||
// Сохраняем email
|
|
||||||
emailVerificationEmail.value = emailInput.value;
|
|
||||||
// Очищаем поле для ввода кода
|
|
||||||
emailVerificationCode.value = '';
|
|
||||||
} else {
|
|
||||||
emailError.value = response.data.error || 'Ошибка инициализации аутентификации по email';
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
emailError.value = 'Ошибка при запросе кода подтверждения';
|
|
||||||
console.error('Error in email auth:', error);
|
|
||||||
} finally {
|
|
||||||
isEmailSending.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для проверки введенного кода
|
|
||||||
const verifyEmailCode = async () => {
|
|
||||||
try {
|
|
||||||
// Очищаем сообщение об ошибке
|
|
||||||
emailError.value = '';
|
|
||||||
|
|
||||||
if (!emailVerificationCode.value) {
|
|
||||||
emailError.value = 'Пожалуйста, введите код верификации';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Показываем индикатор процесса верификации
|
|
||||||
isVerifying.value = true;
|
|
||||||
|
|
||||||
const response = await axios.post('/api/auth/check-email-verification', {
|
|
||||||
code: emailVerificationCode.value
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.success) {
|
|
||||||
// Сбрасываем все состояния форм email
|
|
||||||
showEmailVerificationInput.value = false;
|
|
||||||
showEmailForm.value = false;
|
|
||||||
showEmailVerification.value = false;
|
|
||||||
|
|
||||||
// Показываем сообщение об успешной верификации
|
|
||||||
successMessage.value = `Email ${emailVerificationEmail.value} успешно подтвержден!`;
|
|
||||||
showSuccessMessage.value = true;
|
|
||||||
|
|
||||||
// Скрываем сообщение через 3 секунды
|
|
||||||
setTimeout(() => {
|
|
||||||
showSuccessMessage.value = false;
|
|
||||||
}, 3000);
|
|
||||||
|
|
||||||
// Обновляем состояние аутентификации
|
|
||||||
await auth.checkAuth();
|
|
||||||
|
|
||||||
// Перезагружаем страницу для обновления UI через 1 секунду
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 1000);
|
|
||||||
} else {
|
|
||||||
emailError.value = response.data.message || 'Неверный код верификации';
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
emailError.value = 'Ошибка при проверке кода';
|
|
||||||
console.error('Error verifying email code:', error);
|
|
||||||
} finally {
|
|
||||||
isVerifying.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Обработчик для Telegram аутентификации
|
|
||||||
const handleTelegramAuth = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await axios.post('/api/auth/telegram/init');
|
|
||||||
const { verificationCode, botLink } = data;
|
|
||||||
|
|
||||||
// Показываем код верификации
|
|
||||||
showTelegramVerification.value = true;
|
|
||||||
telegramVerificationCode.value = verificationCode;
|
|
||||||
telegramBotLink.value = botLink;
|
|
||||||
|
|
||||||
// Запускаем проверку статуса аутентификации
|
|
||||||
telegramAuthCheckInterval.value = setInterval(async () => {
|
|
||||||
try {
|
|
||||||
const response = await axios.get('/api/auth/check');
|
|
||||||
if (response.data.authenticated) {
|
|
||||||
auth.updateAuth({
|
|
||||||
isAuthenticated: true,
|
|
||||||
authType: response.data.authType,
|
|
||||||
userId: response.data.userId
|
|
||||||
});
|
|
||||||
|
|
||||||
clearInterval(telegramAuthCheckInterval.value);
|
|
||||||
telegramAuthCheckInterval.value = null;
|
|
||||||
showTelegramVerification.value = false;
|
|
||||||
|
|
||||||
// Перезагружаем страницу для полного обновления состояния
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error checking auth status:', error);
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// Очищаем интервал через 5 минут
|
|
||||||
setTimeout(() => {
|
|
||||||
if (telegramAuthCheckInterval.value) {
|
|
||||||
clearInterval(telegramAuthCheckInterval.value);
|
|
||||||
telegramAuthCheckInterval.value = null;
|
|
||||||
showTelegramVerification.value = false;
|
|
||||||
}
|
|
||||||
}, 5 * 60 * 1000);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error initializing Telegram auth:', error);
|
|
||||||
alert('Ошибка при инициализации Telegram аутентификации');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для сокращения адреса кошелька
|
|
||||||
const truncateAddress = (address) => {
|
|
||||||
if (!address) return '';
|
|
||||||
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция прокрутки к последнему сообщению
|
|
||||||
const scrollToBottom = () => {
|
|
||||||
if (messagesContainer.value) {
|
|
||||||
messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Загрузка сообщений
|
|
||||||
const loadMoreMessages = async () => {
|
|
||||||
if (!isAuthenticated.value) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
isLoadingMore.value = true;
|
|
||||||
const response = await api.get('/api/chat/history', {
|
|
||||||
params: {
|
|
||||||
limit: limit.value,
|
|
||||||
offset: offset.value
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.success) {
|
|
||||||
const newMessages = response.data.messages.map(msg => ({
|
|
||||||
id: msg.id,
|
|
||||||
content: msg.content,
|
|
||||||
role: msg.role || (msg.sender_type === 'assistant' ? 'assistant' : 'user'),
|
|
||||||
timestamp: msg.created_at,
|
|
||||||
showAuthOptions: false
|
|
||||||
}));
|
|
||||||
|
|
||||||
messages.value = [...messages.value, ...newMessages];
|
|
||||||
hasMoreMessages.value = response.data.total > messages.value.length;
|
|
||||||
offset.value += newMessages.length;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error loading chat history:', error);
|
|
||||||
} finally {
|
|
||||||
isLoadingMore.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Загружаем сообщения при изменении аутентификации
|
|
||||||
watch(() => isAuthenticated.value, async (newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
hasMoreMessages.value = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Сначала загружаем историю из messages
|
|
||||||
await loadMoreMessages();
|
|
||||||
|
|
||||||
// Связываем гостевые сообщения (копируем из guest_messages в messages)
|
|
||||||
await api.post('/api/chat/link-guest-messages');
|
|
||||||
console.log('Guest messages linked to authenticated user');
|
|
||||||
|
|
||||||
// Перезагружаем сообщения, чтобы получить все, включая перенесенные
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
await loadMoreMessages();
|
|
||||||
|
|
||||||
await nextTick();
|
|
||||||
scrollToBottom();
|
|
||||||
} catch (linkError) {
|
|
||||||
console.error('Error linking guest messages:', linkError);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
messages.value = [];
|
|
||||||
offset.value = 0;
|
|
||||||
hasMoreMessages.value = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Функция для подключения кошелька
|
|
||||||
const handleWalletAuth = async () => {
|
|
||||||
if (isConnecting.value || isAuthenticated.value) return; // Предотвращаем повторное подключение
|
|
||||||
|
|
||||||
isConnecting.value = true;
|
|
||||||
try {
|
|
||||||
const result = await connectWithWallet();
|
|
||||||
console.log('Wallet connection result:', result);
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
// Обновляем состояние авторизации
|
|
||||||
await auth.checkAuth();
|
|
||||||
|
|
||||||
// Добавляем небольшую задержку перед сбросом состояния isConnecting
|
|
||||||
setTimeout(() => {
|
|
||||||
isConnecting.value = false;
|
|
||||||
}, 500);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
console.error('Failed to connect wallet:', result.error);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error connecting wallet:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
isConnecting.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для отключения кошелька/выхода
|
|
||||||
const disconnectWallet = async () => {
|
|
||||||
try {
|
|
||||||
await axios.post('/api/auth/logout');
|
|
||||||
auth.isAuthenticated.value = false;
|
|
||||||
auth.address.value = null;
|
|
||||||
auth.authType.value = null;
|
|
||||||
auth.telegramId = null;
|
|
||||||
auth.email = null;
|
|
||||||
|
|
||||||
// Перезагружаем страницу для сброса состояния
|
|
||||||
window.location.reload();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error disconnecting wallet:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Форматирование времени
|
|
||||||
const formatTime = (timestamp) => {
|
|
||||||
if (!timestamp) return '';
|
|
||||||
|
|
||||||
try {
|
|
||||||
const date = new Date(timestamp);
|
|
||||||
|
|
||||||
// Проверяем, является ли дата валидной
|
|
||||||
if (isNaN(date.getTime())) {
|
|
||||||
console.warn('Invalid timestamp:', timestamp);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Форматируем дату с указанием дня, месяца, года и времени
|
|
||||||
return date.toLocaleString([], {
|
|
||||||
year: 'numeric',
|
|
||||||
month: 'short',
|
|
||||||
day: 'numeric',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error formatting time:', error, timestamp);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Форматирование сообщения с поддержкой markdown
|
|
||||||
const formatMessage = (text) => {
|
|
||||||
if (!text) return '';
|
|
||||||
const rawHtml = marked.parse(text);
|
|
||||||
return DOMPurify.sanitize(rawHtml);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для отправки сообщения
|
|
||||||
const handleMessage = async (text) => {
|
|
||||||
try {
|
|
||||||
const messageContent = text.trim();
|
|
||||||
if (!messageContent) return;
|
|
||||||
|
|
||||||
newMessage.value = '';
|
|
||||||
isLoading.value = true;
|
|
||||||
|
|
||||||
if (!isAuthenticated.value) {
|
|
||||||
// Сохраняем в таблицу guest_messages
|
|
||||||
const response = await api.post('/api/chat/guest-message', {
|
|
||||||
message: messageContent,
|
|
||||||
language: userLanguage.value
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.success) {
|
|
||||||
const userMessage = {
|
|
||||||
id: response.data.messageId,
|
|
||||||
content: messageContent,
|
|
||||||
role: 'user',
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
showAuthButtons: false
|
|
||||||
};
|
|
||||||
messages.value.push(userMessage);
|
|
||||||
|
|
||||||
messages.value.push({
|
|
||||||
id: Date.now() + 1,
|
|
||||||
content: 'Для получения ответа от ассистента, пожалуйста, авторизуйтесь одним из способов:',
|
|
||||||
role: 'assistant',
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
showAuthButtons: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Для авторизованного пользователя сохраняем в messages
|
|
||||||
const response = await api.post('/api/chat/message', {
|
|
||||||
message: messageContent,
|
|
||||||
language: userLanguage.value
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.success) {
|
|
||||||
const message = {
|
|
||||||
id: response.data.messageId,
|
|
||||||
content: messageContent,
|
|
||||||
role: 'user',
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
hasResponse: true
|
|
||||||
};
|
|
||||||
messages.value.push(message);
|
|
||||||
|
|
||||||
const aiMessage = {
|
|
||||||
id: response.data.aiMessageId,
|
|
||||||
content: response.data.message,
|
|
||||||
role: 'assistant',
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
};
|
|
||||||
messages.value.push(aiMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await nextTick();
|
|
||||||
scrollToBottom();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error sending message:', error);
|
|
||||||
messages.value.push({
|
|
||||||
id: Date.now(),
|
|
||||||
content: 'Произошла ошибка при отправке сообщения.',
|
|
||||||
role: 'assistant',
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Обработка прокрутки
|
|
||||||
const handleScroll = async () => {
|
|
||||||
const element = messagesContainer.value;
|
|
||||||
if (
|
|
||||||
!isLoadingMore.value &&
|
|
||||||
hasMoreMessages.value &&
|
|
||||||
element.scrollTop === 0
|
|
||||||
) {
|
|
||||||
await loadMoreMessages();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
// Добавляем слушатель прокрутки
|
|
||||||
if (messagesContainer.value) {
|
|
||||||
messagesContainer.value.addEventListener('scroll', handleScroll);
|
|
||||||
}
|
|
||||||
console.log('Auth state on mount:', {
|
|
||||||
isAuthenticated: auth.isAuthenticated.value,
|
|
||||||
authType: auth.authType.value,
|
|
||||||
telegramId: auth.telegramId.value
|
|
||||||
});
|
|
||||||
|
|
||||||
// Проверяем статус авторизации
|
|
||||||
auth.checkAuth();
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
// Удаляем слушатель
|
|
||||||
if (messagesContainer.value) {
|
|
||||||
messagesContainer.value.removeEventListener('scroll', handleScroll);
|
|
||||||
}
|
|
||||||
if (telegramAuthCheckInterval.value) {
|
|
||||||
clearInterval(telegramAuthCheckInterval.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
Reference in New Issue
Block a user