feat(ui): 用 showToast 替代全部原生 alert,输入框统一加凹陷效果
一、替换 53 处原生 alert() 原生 alert() 样式无法定制、只有单一「确定」按钮、且会阻塞页面渲染, 与站点风格割裂。全部改为 showToast(),按语义区分类型: - 失败/错误提示 -> error(36 处) - 表单校验与操作提示 -> warning(21 处) - 成功提示 -> success(9 处) 覆盖 admin.js(12)、app.js(23)、auth.js(8)、feed.js(2)、post.js(8)。 替换用一个括号配平的小脚本完成,避免正则误伤字符串里含括号的文案; 替换后逐文件做了语法检查。 二、输入框统一凹陷效果 输入框样式此前散落在至少 8 组选择器里(.modal-content / #pageSettings / #pageNew / #replyArea / #chatInput 等),各写一套背景色。亮色下多为 半透明白叠在白底上,几乎看不出输入区边界,用户难以分辨哪里可输入。 改为新增一层统一样式(文件末尾),用 inset box-shadow 制造内凹, 靠「凹陷」而非描边表明可输入区域: - 新增 --inset-bg / --inset-border / --inset-shadow / --input-focus-bg 四个变量,亮暗主题各一套 - 亮色:浅灰底 #eef1f6 + 深色内阴影;暗色:更深底色 + 更强内阴影 - 聚焦时内凹消失,换成品牌色外发光,形成明确的「浮起可编辑」反馈 - 悬停时加深边框,提示可交互 - 排除 checkbox / radio / file / range / color 等非文本控件 - 添加 disabled 与 placeholder 状态处理 三、顺带修正 移除此前误加的一份重复暗色输入框规则(项目下方本就有 「暗色模式下的特殊修复」区块处理同一批选择器),并为其补上 border-color,因为亮色边框已改为深色,暗色下需换回浅色。 已用 Puppeteer 实测:亮暗两主题下输入框背景、边框、内凹阴影与聚焦 光晕均符合预期;三种 toast 类型均正常弹出;中文字体渲染正常。
This commit is contained in:
1 parent
51032c44d0
commit
75cc78d5f8
6 files changed
+149
-53
No files matched your search
+12
-12
@@ -55,7 +55,7 @@ function renderAdminReports() {
|
|||||||
}
|
}
|
||||||
API.updateReport(id, status, note).then(() => {
|
API.updateReport(id, status, note).then(() => {
|
||||||
renderAdminReports();
|
renderAdminReports();
|
||||||
}).catch(err => alert('操作失败:' + err.message));
|
}).catch(err => showToast('操作失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
@@ -218,7 +218,7 @@ function renderAdminUsers(page = 1, search = '') {
|
|||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
API.updateUserRole(userId, role).then(() => {
|
API.updateUserRole(userId, role).then(() => {
|
||||||
renderAdminUsers(currentUsersPage, usersSearchKeyword);
|
renderAdminUsers(currentUsersPage, usersSearchKeyword);
|
||||||
}).catch(err => alert('操作失败:' + err.message));
|
}).catch(err => showToast('操作失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ function renderAdminLinks() {
|
|||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
API.deleteLink(this.dataset.linkid).then(() => {
|
API.deleteLink(this.dataset.linkid).then(() => {
|
||||||
loadLinks();
|
loadLinks();
|
||||||
}).catch(err => alert('删除失败:' + err.message));
|
}).catch(err => showToast('删除失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
@@ -413,12 +413,12 @@ function renderAdminLinks() {
|
|||||||
document.getElementById('addLinkBtn').addEventListener('click', function() {
|
document.getElementById('addLinkBtn').addEventListener('click', function() {
|
||||||
const title = document.getElementById('newLinkTitle').value.trim();
|
const title = document.getElementById('newLinkTitle').value.trim();
|
||||||
const url = document.getElementById('newLinkUrl').value.trim();
|
const url = document.getElementById('newLinkUrl').value.trim();
|
||||||
if (!title || !url) { alert('请填写完整信息'); return; }
|
if (!title || !url) { showToast('请填写完整信息', 'warning'); return; }
|
||||||
API.addLink(title, url).then(() => {
|
API.addLink(title, url).then(() => {
|
||||||
document.getElementById('newLinkTitle').value = '';
|
document.getElementById('newLinkTitle').value = '';
|
||||||
document.getElementById('newLinkUrl').value = '';
|
document.getElementById('newLinkUrl').value = '';
|
||||||
loadLinks();
|
loadLinks();
|
||||||
}).catch(err => alert('添加失败:' + err.message));
|
}).catch(err => showToast('添加失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +445,7 @@ function renderAdminSettings() {
|
|||||||
|
|
||||||
document.getElementById('settingsForumSave').addEventListener('click', async () => {
|
document.getElementById('settingsForumSave').addEventListener('click', async () => {
|
||||||
const name = document.getElementById('settingsForumName').value.trim();
|
const name = document.getElementById('settingsForumName').value.trim();
|
||||||
if (!name) { alert('请输入论坛名称'); return; }
|
if (!name) { showToast('请输入论坛名称', 'warning'); return; }
|
||||||
try {
|
try {
|
||||||
await API.updateSettings(name);
|
await API.updateSettings(name);
|
||||||
document.getElementById('settingsResult').innerHTML = `${getIcon('success')} 保存成功!`;
|
document.getElementById('settingsResult').innerHTML = `${getIcon('success')} 保存成功!`;
|
||||||
@@ -669,7 +669,7 @@ function loadCustomPageList() {
|
|||||||
API.deleteCustomPage(this.dataset.id).then(() => {
|
API.deleteCustomPage(this.dataset.id).then(() => {
|
||||||
loadCustomPageList();
|
loadCustomPageList();
|
||||||
loadCustomPagesNav();
|
loadCustomPagesNav();
|
||||||
}).catch(err => alert('删除失败:' + err.message));
|
}).catch(err => showToast('删除失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@@ -728,11 +728,11 @@ function openCustomPageEditor(page) {
|
|||||||
const content = document.getElementById('editorContent').value.trim();
|
const content = document.getElementById('editorContent').value.trim();
|
||||||
const enabled = document.getElementById('editorEnabled').value === 'true';
|
const enabled = document.getElementById('editorEnabled').value === 'true';
|
||||||
|
|
||||||
if (!name) { alert('请输入页面名称'); return; }
|
if (!name) { showToast('请输入页面名称', 'warning'); return; }
|
||||||
if (!title) { alert('请输入导航栏显示名称'); return; }
|
if (!title) { showToast('请输入导航栏显示名称', 'warning'); return; }
|
||||||
if (!content) { alert('请输入页面内容'); return; }
|
if (!content) { showToast('请输入页面内容', 'warning'); return; }
|
||||||
if (!/^[a-zA-Z0-9\-_]+$/.test(name)) {
|
if (!/^[a-zA-Z0-9\-_]+$/.test(name)) {
|
||||||
alert('页面名称只允许字母、数字、短横线和下划线');
|
showToast('页面名称只允许字母、数字、短横线和下划线', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,7 +746,7 @@ function openCustomPageEditor(page) {
|
|||||||
loadCustomPageList();
|
loadCustomPageList();
|
||||||
loadCustomPagesNav();
|
loadCustomPagesNav();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('保存失败:' + err.message);
|
showToast('保存失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ async function sendMessage() {
|
|||||||
renderMessageList();
|
renderMessageList();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('发送失败:' + err.message);
|
showToast('发送失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ async function openPrivateChat(otherUserId, otherUsername) {
|
|||||||
}
|
}
|
||||||
}, 3000);
|
}, 3000);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('打开私信失败:' + err.message);
|
showToast('打开私信失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,15 +520,15 @@ function handleImageFiles(files) {
|
|||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (selectedImageFiles.length >= 6) {
|
if (selectedImageFiles.length >= 6) {
|
||||||
alert('每篇帖子最多上传 6 张图片');
|
showToast('每篇帖子最多上传 6 张图片', 'warning');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!['image/jpeg', 'image/png', 'image/gif', 'image/webp'].includes(file.type)) {
|
if (!['image/jpeg', 'image/png', 'image/gif', 'image/webp'].includes(file.type)) {
|
||||||
alert('图片 ' + file.name + ' 格式不支持');
|
showToast('图片 ' + file.name + ' 格式不支持', 'error');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (file.size > 5 * 1024 * 1024) {
|
if (file.size > 5 * 1024 * 1024) {
|
||||||
alert('图片 ' + file.name + ' 超过 5MB,请压缩后上传');
|
showToast('图片 ' + file.name + ' 超过 5MB,请压缩后上传', 'warning');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,17 +911,17 @@ async function renderSettingsPage(tab = 'profile') {
|
|||||||
const username = document.getElementById('settingsUsername').value.trim();
|
const username = document.getElementById('settingsUsername').value.trim();
|
||||||
const bio = document.getElementById('settingsBio').value.trim();
|
const bio = document.getElementById('settingsBio').value.trim();
|
||||||
const signature = document.getElementById('settingsSignature').value.trim();
|
const signature = document.getElementById('settingsSignature').value.trim();
|
||||||
if (!username) { alert('用户名不能为空'); return; }
|
if (!username) { showToast('用户名不能为空', 'error'); return; }
|
||||||
try {
|
try {
|
||||||
await API.updateProfile(user.id, username, bio, signature);
|
await API.updateProfile(user.id, username, bio, signature);
|
||||||
currentUser.username = username;
|
currentUser.username = username;
|
||||||
currentUser.bio = bio;
|
currentUser.bio = bio;
|
||||||
currentUser.signature = signature;
|
currentUser.signature = signature;
|
||||||
alert('保存成功!');
|
showToast('保存成功!', 'success');
|
||||||
renderNav();
|
renderNav();
|
||||||
renderSettingsPage('profile');
|
renderSettingsPage('profile');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('保存失败:' + err.message);
|
showToast('保存失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1045,7 @@ async function renderSettingsPage(tab = 'profile') {
|
|||||||
const countData = await API.getRecoveryCodesCount();
|
const countData = await API.getRecoveryCodesCount();
|
||||||
if (recoveryStatus) recoveryStatus.textContent = '剩余 ' + (countData.count || 0) + ' 个可用恢复码';
|
if (recoveryStatus) recoveryStatus.textContent = '剩余 ' + (countData.count || 0) + ' 个可用恢复码';
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('获取恢复码失败:' + err.message);
|
showToast('获取恢复码失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1064,7 @@ async function renderSettingsPage(tab = 'profile') {
|
|||||||
const countData = await API.getRecoveryCodesCount();
|
const countData = await API.getRecoveryCodesCount();
|
||||||
if (recoveryStatus) recoveryStatus.textContent = '剩余 ' + (countData.count || 0) + ' 个可用恢复码';
|
if (recoveryStatus) recoveryStatus.textContent = '剩余 ' + (countData.count || 0) + ' 个可用恢复码';
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('重新生成失败:' + err.message);
|
showToast('重新生成失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1118,7 +1118,7 @@ function openEditModal(postId, currentTitle, currentContent) {
|
|||||||
modal.querySelector('#editPostSaveBtn').addEventListener('click', async function() {
|
modal.querySelector('#editPostSaveBtn').addEventListener('click', async function() {
|
||||||
const title = document.getElementById('editPostTitle').value.trim() || '无标题';
|
const title = document.getElementById('editPostTitle').value.trim() || '无标题';
|
||||||
const content = document.getElementById('editPostContent').value.trim();
|
const content = document.getElementById('editPostContent').value.trim();
|
||||||
if (!content) { alert('请填写内容'); return; }
|
if (!content) { showToast('请填写内容', 'warning'); return; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await API.updatePost(postId, title, content);
|
await API.updatePost(postId, title, content);
|
||||||
@@ -1128,9 +1128,9 @@ function openEditModal(postId, currentTitle, currentContent) {
|
|||||||
} else {
|
} else {
|
||||||
renderFeed();
|
renderFeed();
|
||||||
}
|
}
|
||||||
alert('编辑成功!');
|
showToast('编辑成功!', 'success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('编辑失败:' + err.message);
|
showToast('编辑失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1335,7 +1335,7 @@ async function init() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const page = this.dataset.page;
|
const page = this.dataset.page;
|
||||||
if (page === 'admin' && currentUser?.role !== 'admin') {
|
if (page === 'admin' && currentUser?.role !== 'admin') {
|
||||||
alert('无权限访问');
|
showToast('无权限访问', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
closeDropdown(document.getElementById('dropdownMenu'));
|
closeDropdown(document.getElementById('dropdownMenu'));
|
||||||
@@ -1398,13 +1398,13 @@ async function init() {
|
|||||||
|
|
||||||
// ===== 发帖 =====
|
// ===== 发帖 =====
|
||||||
document.getElementById('fab').addEventListener('click', () => {
|
document.getElementById('fab').addEventListener('click', () => {
|
||||||
if (!currentUser) { alert('请先登录'); return; }
|
if (!currentUser) { showToast('请先登录', 'warning'); 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('请先登录');
|
showToast('请先登录', 'warning');
|
||||||
switchPage('feed');
|
switchPage('feed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1412,8 +1412,8 @@ async function init() {
|
|||||||
const content = document.getElementById('postContent').value.trim();
|
const content = document.getElementById('postContent').value.trim();
|
||||||
const captchaInput = document.getElementById('postCaptchaInput').value.trim();
|
const captchaInput = document.getElementById('postCaptchaInput').value.trim();
|
||||||
const captchaAnswer = parseInt(document.getElementById('postCaptchaInput').dataset.answer);
|
const captchaAnswer = parseInt(document.getElementById('postCaptchaInput').dataset.answer);
|
||||||
if (!content) { alert('请填写内容'); return; }
|
if (!content) { showToast('请填写内容', 'warning'); return; }
|
||||||
if (parseInt(captchaInput) !== captchaAnswer) { alert('验证码错误,请重新计算'); refreshCaptcha('post'); return; }
|
if (parseInt(captchaInput) !== captchaAnswer) { showToast('验证码错误,请重新计算', 'error'); refreshCaptcha('post'); return; }
|
||||||
const submitButton = document.getElementById('postSubmit');
|
const submitButton = document.getElementById('postSubmit');
|
||||||
submitButton.disabled = true;
|
submitButton.disabled = true;
|
||||||
submitButton.textContent = selectedImageFiles.length ? '上传图片中...' : '发布中...';
|
submitButton.textContent = selectedImageFiles.length ? '上传图片中...' : '发布中...';
|
||||||
@@ -1425,13 +1425,13 @@ async function init() {
|
|||||||
}
|
}
|
||||||
await API.createPost(title, content, images);
|
await API.createPost(title, content, images);
|
||||||
|
|
||||||
alert('发布成功!');
|
showToast('发布成功!', 'success');
|
||||||
clearSelectedImages();
|
clearSelectedImages();
|
||||||
switchPage('feed');
|
switchPage('feed');
|
||||||
renderFeed();
|
renderFeed();
|
||||||
renderStats();
|
renderStats();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('发布失败:' + err.message);
|
showToast('发布失败:' + err.message, 'error');
|
||||||
} finally {
|
} finally {
|
||||||
submitButton.disabled = false;
|
submitButton.disabled = false;
|
||||||
submitButton.textContent = '发布帖子';
|
submitButton.textContent = '发布帖子';
|
||||||
@@ -1489,10 +1489,10 @@ async function init() {
|
|||||||
try {
|
try {
|
||||||
await API.createReport(reportTargetPostId, reason);
|
await API.createReport(reportTargetPostId, reason);
|
||||||
closeModal(document.getElementById('reportModal'));
|
closeModal(document.getElementById('reportModal'));
|
||||||
alert('举报已提交,管理员将尽快处理');
|
showToast('举报已提交,管理员将尽快处理', 'success');
|
||||||
reportTargetPostId = null;
|
reportTargetPostId = null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('举报失败:' + err.message);
|
showToast('举报失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1533,7 +1533,7 @@ async function init() {
|
|||||||
messageBtn.parentNode.replaceChild(newBtn, messageBtn);
|
messageBtn.parentNode.replaceChild(newBtn, messageBtn);
|
||||||
newBtn.addEventListener('click', function(e) {
|
newBtn.addEventListener('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!currentUser) { alert('请先登录'); return; }
|
if (!currentUser) { showToast('请先登录', 'warning'); return; }
|
||||||
openMessageList();
|
openMessageList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -10,7 +10,7 @@ document.getElementById('loginBtn').addEventListener('click', () => {
|
|||||||
document.getElementById('loginSubmit').addEventListener('click', async () => {
|
document.getElementById('loginSubmit').addEventListener('click', async () => {
|
||||||
const email = document.getElementById('loginEmail').value.trim();
|
const email = document.getElementById('loginEmail').value.trim();
|
||||||
const password = document.getElementById('loginPassword').value;
|
const password = document.getElementById('loginPassword').value;
|
||||||
if (!email || !password) { alert('请填写完整信息'); return; }
|
if (!email || !password) { showToast('请填写完整信息', 'warning'); return; }
|
||||||
try {
|
try {
|
||||||
const result = await API.login(email, password);
|
const result = await API.login(email, password);
|
||||||
closeModal(document.getElementById('loginModal'));
|
closeModal(document.getElementById('loginModal'));
|
||||||
@@ -27,7 +27,7 @@ document.getElementById('loginSubmit').addEventListener('click', async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('登录失败:' + err.message);
|
showToast('登录失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,13 +66,13 @@ document.getElementById('registerSubmit').addEventListener('click', async () =>
|
|||||||
: '';
|
: '';
|
||||||
const captchaInput = document.getElementById('regCaptchaInput').value.trim();
|
const captchaInput = document.getElementById('regCaptchaInput').value.trim();
|
||||||
const captchaAnswer = parseInt(document.getElementById('regCaptchaInput').dataset.answer);
|
const captchaAnswer = parseInt(document.getElementById('regCaptchaInput').dataset.answer);
|
||||||
if (!username || !email || !password) { alert('请填写完整信息'); return; }
|
if (!username || !email || !password) { showToast('请填写完整信息', 'warning'); return; }
|
||||||
if (password.length < 6) { alert('密码至少6位'); return; }
|
if (password.length < 6) { showToast('密码至少6位', 'warning'); return; }
|
||||||
if (parseInt(captchaInput) !== captchaAnswer) { alert('验证码错误,请重新计算'); refreshCaptcha('reg'); return; }
|
if (parseInt(captchaInput) !== captchaAnswer) { showToast('验证码错误,请重新计算', 'error'); refreshCaptcha('reg'); return; }
|
||||||
try {
|
try {
|
||||||
await API.register(email, password, username, bootstrapToken);
|
await API.register(email, password, username, bootstrapToken);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('注册失败:' + err.message);
|
showToast('注册失败:' + err.message, 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ document.getElementById('registerSubmit').addEventListener('click', async () =>
|
|||||||
renderStats();
|
renderStats();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('注册成功,但自动登录失败,请手动登录:' + err.message);
|
showToast('注册成功,但自动登录失败,请手动登录:' + err.message, 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ document.getElementById('registerSubmit').addEventListener('click', async () =>
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('恢复码生成失败:', err);
|
console.warn('恢复码生成失败:', err);
|
||||||
alert('注册并登录成功,但恢复码生成失败。请稍后在设置中重新生成。');
|
showToast('注册并登录成功,但恢复码生成失败。请稍后在设置中重新生成。', 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -187,7 +187,7 @@ function renderFeed() {
|
|||||||
container.querySelectorAll('.action-report').forEach(btn => {
|
container.querySelectorAll('.action-report').forEach(btn => {
|
||||||
btn.addEventListener('click', function(e) {
|
btn.addEventListener('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!currentUser) { alert('请先登录'); return; }
|
if (!currentUser) { showToast('请先登录', 'warning'); return; }
|
||||||
reportTargetPostId = this.dataset.postid;
|
reportTargetPostId = this.dataset.postid;
|
||||||
document.getElementById('reportModal').classList.add('active');
|
document.getElementById('reportModal').classList.add('active');
|
||||||
});
|
});
|
||||||
@@ -202,7 +202,7 @@ function renderFeed() {
|
|||||||
API.deletePost(this.dataset.postid).then(() => {
|
API.deletePost(this.dataset.postid).then(() => {
|
||||||
renderFeed();
|
renderFeed();
|
||||||
renderStats();
|
renderStats();
|
||||||
}).catch(err => alert('删除失败:' + err.message));
|
}).catch(err => showToast('删除失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
+8
-8
@@ -159,7 +159,7 @@ async function renderPostDetail(postId) {
|
|||||||
API.togglePinPost(postId).then(() => {
|
API.togglePinPost(postId).then(() => {
|
||||||
renderPostDetail(postId);
|
renderPostDetail(postId);
|
||||||
renderFeed();
|
renderFeed();
|
||||||
}).catch(err => alert('操作失败:' + err.message));
|
}).catch(err => showToast('操作失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,11 +182,11 @@ async function renderPostDetail(postId) {
|
|||||||
});
|
});
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
API.deletePost(postId).then(() => {
|
API.deletePost(postId).then(() => {
|
||||||
alert('删除成功');
|
showToast('删除成功', 'success');
|
||||||
switchPage('feed');
|
switchPage('feed');
|
||||||
renderFeed();
|
renderFeed();
|
||||||
renderStats();
|
renderStats();
|
||||||
}).catch(err => alert('删除失败:' + err.message));
|
}).catch(err => showToast('删除失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ async function renderPostDetail(postId) {
|
|||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
API.deleteReply(replyId).then(() => {
|
API.deleteReply(replyId).then(() => {
|
||||||
renderPostDetail(postId);
|
renderPostDetail(postId);
|
||||||
}).catch(err => alert('删除失败:' + err.message));
|
}).catch(err => showToast('删除失败:' + err.message, 'error'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -229,12 +229,12 @@ async function renderPostDetail(postId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleReplySubmit(postId) {
|
async function handleReplySubmit(postId) {
|
||||||
if (!currentUser) { alert('请先登录'); return; }
|
if (!currentUser) { showToast('请先登录', 'warning'); return; }
|
||||||
const content = document.getElementById('replyContent').value.trim();
|
const content = document.getElementById('replyContent').value.trim();
|
||||||
const captchaInput = document.getElementById('replyCaptchaInput').value.trim();
|
const captchaInput = document.getElementById('replyCaptchaInput').value.trim();
|
||||||
const captchaAnswer = parseInt(document.getElementById('replyCaptchaInput').dataset.answer);
|
const captchaAnswer = parseInt(document.getElementById('replyCaptchaInput').dataset.answer);
|
||||||
if (!content) { alert('请填写回复内容'); return; }
|
if (!content) { showToast('请填写回复内容', 'warning'); return; }
|
||||||
if (parseInt(captchaInput) !== captchaAnswer) { alert('验证码错误,请重新计算'); refreshCaptcha('reply'); return; }
|
if (parseInt(captchaInput) !== captchaAnswer) { showToast('验证码错误,请重新计算', 'error'); refreshCaptcha('reply'); return; }
|
||||||
try {
|
try {
|
||||||
await API.createReply(postId, content);
|
await API.createReply(postId, content);
|
||||||
|
|
||||||
@@ -244,6 +244,6 @@ async function handleReplySubmit(postId) {
|
|||||||
}
|
}
|
||||||
renderStats();
|
renderStats();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('回复失败:' + err.message);
|
showToast('回复失败:' + err.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2960,3 +2960,99 @@ a.btn-secondary {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================================
|
||||||
|
⌨️ 输入框统一凹陷效果
|
||||||
|
------------------------------------------------------------
|
||||||
|
输入框样式此前散落在至少 8 组选择器里(.modal-content /
|
||||||
|
#pageSettings / #pageNew / #replyArea / #chatInput 等),各写一套
|
||||||
|
背景色,亮色下多为半透明白叠在白底上,几乎看不出输入区边界。
|
||||||
|
这里统一收口,给所有输入控件加上内凹阴影,靠「凹陷」而非描边
|
||||||
|
来表明可输入区域。
|
||||||
|
|
||||||
|
实现要点:
|
||||||
|
- 用 inset box-shadow 制造整体内凹(上深下浅,模拟受光方向)
|
||||||
|
- 亮色用白底 + 深色内阴影;暗色用深底 + 更深内阴影
|
||||||
|
- 聚焦时凹陷消失并换成品牌色光晕,形成明确的「浮起可编辑」反馈
|
||||||
|
- !important 用于压过各处既有的散装 background/border 声明
|
||||||
|
============================================================ */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* 凹陷:上方投影较重、下方较浅,模拟向内受光 */
|
||||||
|
--inset-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.12),
|
||||||
|
inset 0 1px 2px rgba(0, 0, 0, 0.08);
|
||||||
|
--inset-border: rgba(0, 0, 0, 0.18);
|
||||||
|
/* 输入区底色需与白色弹窗/卡片明显区分,取值偏灰以保证一眼可辨 */
|
||||||
|
--inset-bg: #eef1f6;
|
||||||
|
/* 聚焦时的实心底色:亮色取白,暗色取深色(下方按主题覆盖) */
|
||||||
|
--input-focus-bg: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--inset-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55),
|
||||||
|
inset 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||||
|
--inset-border: rgba(255, 255, 255, 0.14);
|
||||||
|
/* 比弹窗底色更深,形成下沉感 */
|
||||||
|
--inset-bg: rgba(0, 0, 0, 0.32);
|
||||||
|
--input-focus-bg: rgba(0, 0, 0, 0.42);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 覆盖所有文本输入控件。排除 checkbox/radio/file/range/color 等
|
||||||
|
非文本控件,它们用凹陷阴影会显得突兀。 */
|
||||||
|
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
|
||||||
|
textarea,
|
||||||
|
select {
|
||||||
|
background: var(--inset-bg) !important;
|
||||||
|
border: 1px solid var(--inset-border) !important;
|
||||||
|
box-shadow: var(--inset-shadow) !important;
|
||||||
|
border-radius: var(--radius-sm) !important;
|
||||||
|
transition: box-shadow var(--dur-base, 0.26s) ease,
|
||||||
|
border-color var(--dur-base, 0.26s) ease,
|
||||||
|
background var(--dur-base, 0.26s) ease !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 聚焦:内凹消失,换成品牌色外发光,明确当前编辑目标 */
|
||||||
|
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):focus,
|
||||||
|
textarea:focus,
|
||||||
|
select:focus {
|
||||||
|
outline: none !important;
|
||||||
|
background: var(--input-focus-bg) !important;
|
||||||
|
border-color: var(--primary) !important;
|
||||||
|
box-shadow: 0 0 0 3px var(--primary-glow), 0 1px 2px rgba(0, 0, 0, 0.05) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):focus,
|
||||||
|
[data-theme="dark"] textarea:focus,
|
||||||
|
[data-theme="dark"] select:focus {
|
||||||
|
background: var(--input-focus-bg) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 悬停时轻微加深边框,提示可交互 */
|
||||||
|
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):hover:not(:focus),
|
||||||
|
textarea:hover:not(:focus),
|
||||||
|
select:hover:not(:focus) {
|
||||||
|
border-color: rgba(0, 0, 0, 0.24) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):hover:not(:focus),
|
||||||
|
[data-theme="dark"] textarea:hover:not(:focus),
|
||||||
|
[data-theme="dark"] select:hover:not(:focus) {
|
||||||
|
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 占位符与被禁用状态 */
|
||||||
|
input::placeholder,
|
||||||
|
textarea::placeholder {
|
||||||
|
color: var(--glass-text-light) !important;
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:disabled,
|
||||||
|
textarea:disabled,
|
||||||
|
select:disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
cursor: not-allowed;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 搜索框、验证码等内嵌小输入框同样适用,无需单独处理 */
|
||||||
Reference in new issue
Block a user