Update app.js

This commit is contained in:
Furrium Network authored and GitHub committed 2026-08-09 19:58:22 +08:00
1 parent bbaa1e9748
commit ff46812564
1 file changed
-19
-19
View File
@@ -116,7 +116,6 @@ function switchPage(page, param) {
document.getElementById('fileInput').value = ''; document.getElementById('fileInput').value = '';
document.getElementById('postCaptchaInput').value = ''; document.getElementById('postCaptchaInput').value = '';
refreshCaptcha('post'); refreshCaptcha('post');
// 重置上传区域文字
const dropText = document.getElementById('dropZoneText'); const dropText = document.getElementById('dropZoneText');
if (dropText) dropText.textContent = '点击或拖拽上传图片'; if (dropText) dropText.textContent = '点击或拖拽上传图片';
} }
@@ -390,7 +389,6 @@ async function init() {
// 绑定所有事件 // 绑定所有事件
// ============================================================ // ============================================================
// 主题切换
const themeToggle = document.getElementById('themeToggle'); const themeToggle = document.getElementById('themeToggle');
if (themeToggle) { if (themeToggle) {
themeToggle.addEventListener('click', function(e) { themeToggle.addEventListener('click', function(e) {
@@ -401,7 +399,6 @@ async function init() {
}); });
} }
// 头像下拉
document.getElementById('avatarImg').addEventListener('click', function(e) { document.getElementById('avatarImg').addEventListener('click', function(e) {
e.stopPropagation(); e.stopPropagation();
document.getElementById('dropdownMenu').classList.toggle('show'); document.getElementById('dropdownMenu').classList.toggle('show');
@@ -410,7 +407,6 @@ async function init() {
document.getElementById('dropdownMenu').classList.remove('show'); document.getElementById('dropdownMenu').classList.remove('show');
}); });
// 导航菜单
document.querySelectorAll('[data-page]').forEach(el => { document.querySelectorAll('[data-page]').forEach(el => {
el.addEventListener('click', function(e) { el.addEventListener('click', function(e) {
e.preventDefault(); e.preventDefault();
@@ -424,14 +420,12 @@ async function init() {
}); });
}); });
// 返回按钮
document.querySelectorAll('.back-btn').forEach(btn => { document.querySelectorAll('.back-btn').forEach(btn => {
btn.addEventListener('click', function() { btn.addEventListener('click', function() {
switchPage('feed'); switchPage('feed');
}); });
}); });
// 设置保存
document.getElementById('settingsSave').addEventListener('click', async () => { document.getElementById('settingsSave').addEventListener('click', async () => {
if (!currentUser) { alert('请先登录'); return; } if (!currentUser) { alert('请先登录'); return; }
const username = document.getElementById('settingsUsername').value.trim(); const username = document.getElementById('settingsUsername').value.trim();
@@ -455,18 +449,15 @@ async function init() {
} }
}); });
// 点击论坛名回首页
document.getElementById('forumName').addEventListener('click', function() { document.getElementById('forumName').addEventListener('click', function() {
switchPage('feed'); switchPage('feed');
}); });
// 发帖按钮
document.getElementById('fab').addEventListener('click', () => { document.getElementById('fab').addEventListener('click', () => {
if (!currentUser) { alert('请先登录'); return; } if (!currentUser) { alert('请先登录'); return; }
switchPage('new'); switchPage('new');
}); });
// 发帖提交
document.getElementById('postSubmit').addEventListener('click', async () => { document.getElementById('postSubmit').addEventListener('click', async () => {
if (!currentUser || !currentUser.id) { if (!currentUser || !currentUser.id) {
alert('请先登录'); alert('请先登录');
@@ -495,7 +486,6 @@ async function init() {
} }
}); });
// 验证码刷新
document.getElementById('postCaptchaQuestion').addEventListener('click', function() { document.getElementById('postCaptchaQuestion').addEventListener('click', function() {
refreshCaptcha('post'); refreshCaptcha('post');
}); });
@@ -503,7 +493,6 @@ async function init() {
refreshCaptcha('reg'); refreshCaptcha('reg');
}); });
// 图片上传 - 拖拽区域
const dropZone = document.getElementById('dropZone'); const dropZone = document.getElementById('dropZone');
const fileInput = document.getElementById('fileInput'); const fileInput = document.getElementById('fileInput');
const dropZoneText = document.getElementById('dropZoneText'); const dropZoneText = document.getElementById('dropZoneText');
@@ -540,7 +529,6 @@ async function init() {
}); });
} }
// 举报提交
document.getElementById('reportSubmit').addEventListener('click', async () => { document.getElementById('reportSubmit').addEventListener('click', async () => {
if (!reportTargetPostId) return; if (!reportTargetPostId) return;
const reason = document.getElementById('reportReason').value; const reason = document.getElementById('reportReason').value;
@@ -554,7 +542,6 @@ async function init() {
} }
}); });
// 模态框关闭
document.querySelectorAll('.modal .close').forEach(btn => { document.querySelectorAll('.modal .close').forEach(btn => {
btn.addEventListener('click', function() { btn.addEventListener('click', function() {
document.getElementById(this.dataset.modal).classList.remove('active'); document.getElementById(this.dataset.modal).classList.remove('active');
@@ -566,7 +553,6 @@ async function init() {
}); });
}); });
// 浏览器前进后退
window.addEventListener('popstate', function(e) { window.addEventListener('popstate', function(e) {
const state = e.state || {}; const state = e.state || {};
const page = state.page || 'feed'; const page = state.page || 'feed';
@@ -581,7 +567,6 @@ async function init() {
} }
}); });
// 私信按钮
const messageBtn = document.getElementById('messageBtn'); const messageBtn = document.getElementById('messageBtn');
if (messageBtn) { if (messageBtn) {
const newBtn = messageBtn.cloneNode(true); const newBtn = messageBtn.cloneNode(true);
@@ -593,19 +578,16 @@ async function init() {
}); });
} }
// 私信列表关闭
const closeMessageListBtn = document.querySelector('#messageListModal .close'); const closeMessageListBtn = document.querySelector('#messageListModal .close');
if (closeMessageListBtn) { if (closeMessageListBtn) {
closeMessageListBtn.addEventListener('click', closeMessageList); closeMessageListBtn.addEventListener('click', closeMessageList);
} }
// 聊天关闭
const closeChatBtn = document.querySelector('#chatModal .close'); const closeChatBtn = document.querySelector('#chatModal .close');
if (closeChatBtn) { if (closeChatBtn) {
closeChatBtn.addEventListener('click', closeChat); closeChatBtn.addEventListener('click', closeChat);
} }
// 聊天输入框 Enter 发送
const chatInput = document.getElementById('chatInput'); const chatInput = document.getElementById('chatInput');
if (chatInput) { if (chatInput) {
chatInput.addEventListener('keydown', function(e) { chatInput.addEventListener('keydown', function(e) {
@@ -616,7 +598,6 @@ async function init() {
}); });
} }
// 点击模态框背景关闭
document.querySelectorAll('.modal').forEach(m => { document.querySelectorAll('.modal').forEach(m => {
m.addEventListener('click', function(e) { m.addEventListener('click', function(e) {
if (e.target === this) { if (e.target === this) {