Spaces:
Paused
Paused
Update templates/index.html
Browse files- templates/index.html +11 -5
templates/index.html
CHANGED
|
@@ -1915,28 +1915,34 @@
|
|
| 1915 |
}
|
| 1916 |
}
|
| 1917 |
} catch (error) {
|
| 1918 |
-
|
| 1919 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1920 |
|
|
|
|
| 1921 |
if (!globalAudioPlayer.paused) globalAudioPlayer.pause();
|
| 1922 |
activeSources.forEach(source => { try { source.stop(); } catch(e) {} });
|
| 1923 |
activeSources = [];
|
| 1924 |
nextAudioTime = 0;
|
| 1925 |
|
|
|
|
| 1926 |
if (currentBotRow) {
|
| 1927 |
let finalHtml = `<div class="message-bubble">${formatMessageText(currentBotText)}</div><div class="action-buttons">`;
|
| 1928 |
finalHtml += `<button class="action-btn" title="کپی" onclick="copyMessageText(this)">${COPY_ICON_SVG}</button>`;
|
|
|
|
| 1929 |
finalHtml += `</div>`;
|
| 1930 |
currentBotRow.innerHTML = finalHtml;
|
| 1931 |
updateDynamicSpacer();
|
|
|
|
|
|
|
| 1932 |
if (currentBotText.trim() !== "") {
|
| 1933 |
saveMessage('bot', currentBotText, null, null, Date.now());
|
| 1934 |
}
|
| 1935 |
currentBotRow = null; currentBotBubble = null; currentBotText = "";
|
| 1936 |
}
|
| 1937 |
-
} else {
|
| 1938 |
-
statusBar.textContent = "خطا در ارتباط با سرور";
|
| 1939 |
-
// بخش ایجاد اجباری چت جدید حذف شد تا تاریخچه گفتگو باقی بماند
|
| 1940 |
}
|
| 1941 |
} finally {
|
| 1942 |
isGenerating = false;
|
|
|
|
| 1915 |
}
|
| 1916 |
}
|
| 1917 |
} catch (error) {
|
| 1918 |
+
// نمایش وضعیت مناسب بر اساس لغو یا خطای اینترنت
|
| 1919 |
+
if (error.name === 'AbortError') {
|
| 1920 |
+
statusBar.textContent = "تولید پیام متوقف شد";
|
| 1921 |
+
} else {
|
| 1922 |
+
statusBar.textContent = "اتصال به دلیل طولانی شدن پاسخ قطع شد";
|
| 1923 |
+
}
|
| 1924 |
|
| 1925 |
+
// قطع پخش صداها در صورت وجود خطا
|
| 1926 |
if (!globalAudioPlayer.paused) globalAudioPlayer.pause();
|
| 1927 |
activeSources.forEach(source => { try { source.stop(); } catch(e) {} });
|
| 1928 |
activeSources = [];
|
| 1929 |
nextAudioTime = 0;
|
| 1930 |
|
| 1931 |
+
// بازیابی متن دریافت شده تا این لحظه، نمایش دکمه کپی و ثبت در دیتابیس
|
| 1932 |
if (currentBotRow) {
|
| 1933 |
let finalHtml = `<div class="message-bubble">${formatMessageText(currentBotText)}</div><div class="action-buttons">`;
|
| 1934 |
finalHtml += `<button class="action-btn" title="کپی" onclick="copyMessageText(this)">${COPY_ICON_SVG}</button>`;
|
| 1935 |
+
// از آنجایی که استریم ناقص قطع شده، دکمه پخش مجدد صوتی برای این پیام غیرفعال میماند اما کپی در دسترس است
|
| 1936 |
finalHtml += `</div>`;
|
| 1937 |
currentBotRow.innerHTML = finalHtml;
|
| 1938 |
updateDynamicSpacer();
|
| 1939 |
+
|
| 1940 |
+
// ذخیره متن داستان در دیتابیس داخلی تا با رفرش ناپدید نشود
|
| 1941 |
if (currentBotText.trim() !== "") {
|
| 1942 |
saveMessage('bot', currentBotText, null, null, Date.now());
|
| 1943 |
}
|
| 1944 |
currentBotRow = null; currentBotBubble = null; currentBotText = "";
|
| 1945 |
}
|
|
|
|
|
|
|
|
|
|
| 1946 |
}
|
| 1947 |
} finally {
|
| 1948 |
isGenerating = false;
|