From 222c9b8f3cbcdb1f44276534f352750729d85612 Mon Sep 17 00:00:00 2001 From: Furrium Network Date: Tue, 11 Aug 2026 09:22:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E6=B6=88=E6=81=AF=E6=B0=94?= =?UTF-8?q?=E6=B3=A1=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/app.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/js/app.js b/js/app.js index 06abafd..c4c524c 100644 --- a/js/app.js +++ b/js/app.js @@ -3,6 +3,36 @@ // ============================================================ let currentUser = null; +function showToast(message, type = 'success', duration = 3000) { + // 移除已有 toast + const existing = document.querySelector('.toast'); + if (existing) existing.remove(); + + const toast = document.createElement('div'); + toast.className = 'toast ' + type; + + const icons = { + success: ``, + error: ``, + warning: `` + }; + + toast.innerHTML = ` + ${icons[type] || icons.success} + ${message} + `; + + document.body.appendChild(toast); + + requestAnimationFrame(() => { + toast.classList.add('show'); + }); + + setTimeout(() => { + toast.classList.remove('show'); + setTimeout(() => toast.remove(), 400); + }, duration); +} let currentPage = 'feed'; let currentPageNum = 1;