继续完善前端登录模块
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
<div class="avatar-section">
|
||||
<h2 class="section-title">修改头像</h2>
|
||||
|
||||
<div class="avatar-upload-container">
|
||||
<div class="current-avatar">
|
||||
<img src="{$user.avatar|default='/static/images/avatar.png'}" alt="当前头像" id="currentAvatar">
|
||||
<p class="avatar-tip">当前头像</p>
|
||||
</div>
|
||||
|
||||
<div class="upload-area" id="uploadArea">
|
||||
<i class="layui-icon layui-icon-upload"></i>
|
||||
<p>点击或拖拽图片到此处上传</p>
|
||||
<p class="upload-tip">支持 jpg、png、gif 格式,大小不超过 2MB</p>
|
||||
<input type="file" id="avatarFile" accept="image/*" style="display: none;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="avatar-preview" style="display: none;">
|
||||
<h3>预览</h3>
|
||||
<div class="preview-container">
|
||||
<img src="" alt="预览图" id="previewImage">
|
||||
</div>
|
||||
<div class="preview-actions">
|
||||
<button class="layui-btn" id="confirmUpload">确认上传</button>
|
||||
<button class="layui-btn layui-btn-primary" id="cancelUpload">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.avatar-section {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.avatar-upload-container {
|
||||
display: flex;
|
||||
gap: 40px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.current-avatar {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.current-avatar img {
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 3px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.avatar-tip {
|
||||
margin-top: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
flex: 1;
|
||||
border: 2px dashed #d9d9d9;
|
||||
border-radius: 8px;
|
||||
padding: 40px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.upload-area:hover {
|
||||
border-color: #1677ff;
|
||||
}
|
||||
|
||||
.upload-area .layui-icon {
|
||||
font-size: 48px;
|
||||
color: #999;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.upload-area p {
|
||||
margin: 8px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.avatar-preview {
|
||||
margin-top: 32px;
|
||||
padding-top: 32px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.avatar-preview h3 {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.preview-container {
|
||||
text-align: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.preview-container img {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.preview-actions {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.preview-actions .layui-btn {
|
||||
margin: 0 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.avatar-upload-container {
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.current-avatar img {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
padding: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['upload', 'layer'], function(){
|
||||
var upload = layui.upload;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 点击上传区域触发文件选择
|
||||
document.getElementById('uploadArea').addEventListener('click', function() {
|
||||
document.getElementById('avatarFile').click();
|
||||
});
|
||||
|
||||
// 处理文件选择
|
||||
document.getElementById('avatarFile').addEventListener('change', function(e) {
|
||||
var file = e.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
// 检查文件类型
|
||||
if (!['image/jpeg', 'image/png', 'image/gif'].includes(file.type)) {
|
||||
layer.msg('请上传 jpg、png 或 gif 格式的图片');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查文件大小
|
||||
if (file.size > 2 * 1024 * 1024) {
|
||||
layer.msg('图片大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
|
||||
// 预览图片
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
document.getElementById('previewImage').src = e.target.result;
|
||||
document.querySelector('.avatar-preview').style.display = 'block';
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
|
||||
// 确认上传
|
||||
document.getElementById('confirmUpload').addEventListener('click', function() {
|
||||
var file = document.getElementById('avatarFile').files[0];
|
||||
if (!file) return;
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('avatar', file);
|
||||
|
||||
// 显示上传中
|
||||
var loadIndex = layer.load(2);
|
||||
|
||||
// 发送上传请求
|
||||
fetch('/index/user/update_avatar', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
layer.close(loadIndex);
|
||||
if (data.code === 0) {
|
||||
layer.msg('头像上传成功', {icon: 1});
|
||||
// 更新当前头像显示
|
||||
document.getElementById('currentAvatar').src = data.data.url;
|
||||
// 隐藏预览区域
|
||||
document.querySelector('.avatar-preview').style.display = 'none';
|
||||
// 清空文件输入
|
||||
document.getElementById('avatarFile').value = '';
|
||||
} else {
|
||||
layer.msg(data.msg || '上传失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.close(loadIndex);
|
||||
layer.msg('上传失败,请重试', {icon: 2});
|
||||
});
|
||||
});
|
||||
|
||||
// 取消上传
|
||||
document.getElementById('cancelUpload').addEventListener('click', function() {
|
||||
document.querySelector('.avatar-preview').style.display = 'none';
|
||||
document.getElementById('avatarFile').value = '';
|
||||
});
|
||||
|
||||
// 拖拽上传
|
||||
var uploadArea = document.getElementById('uploadArea');
|
||||
|
||||
uploadArea.addEventListener('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
this.style.borderColor = '#1677ff';
|
||||
});
|
||||
|
||||
uploadArea.addEventListener('dragleave', function(e) {
|
||||
e.preventDefault();
|
||||
this.style.borderColor = '#d9d9d9';
|
||||
});
|
||||
|
||||
uploadArea.addEventListener('drop', function(e) {
|
||||
e.preventDefault();
|
||||
this.style.borderColor = '#d9d9d9';
|
||||
|
||||
var file = e.dataTransfer.files[0];
|
||||
if (!file) return;
|
||||
|
||||
// 触发文件选择事件
|
||||
var dataTransfer = new DataTransfer();
|
||||
dataTransfer.items.add(file);
|
||||
document.getElementById('avatarFile').files = dataTransfer.files;
|
||||
|
||||
// 手动触发change事件
|
||||
var event = new Event('change');
|
||||
document.getElementById('avatarFile').dispatchEvent(event);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,127 @@
|
||||
<div class="basic-info">
|
||||
<h2 class="section-title">个人资料</h2>
|
||||
<form class="layui-form" lay-filter="basicForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" value="{$user.name}" placeholder="请输入用户名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{$user.account}" class="layui-input" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">QQ</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="qq" name="qq" value="{$user.qq}" placeholder="请输入QQ号" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">手机号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="tel" name="phone" value="{$user.phone}" placeholder="请输入手机号" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">性别</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="sex" value="1" title="男" {if $user.sex==1}checked{/if}>
|
||||
<input type="radio" name="sex" value="2" title="女" {if $user.sex==2}checked{/if}>
|
||||
<input type="radio" name="sex" value="0" title="保密" {if $user.sex==0}checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="saveBasic">保存修改</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.basic-info {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
.layui-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.layui-textarea {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.layui-form-label {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 110px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 监听表单提交
|
||||
form.on('submit(saveBasic)', function (data) {
|
||||
// 发送AJAX请求保存数据
|
||||
fetch('/index/user/saveBasic', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
body: JSON.stringify(data.field)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 0) {
|
||||
layer.msg(result.msg, { icon: 1 }, function () {
|
||||
// 保存成功后刷新页面
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 });
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('保存失败:', error);
|
||||
layer.msg('保存失败,请稍后重试', { icon: 2 });
|
||||
});
|
||||
|
||||
return false; // 阻止表单默认提交
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,310 @@
|
||||
<div class="messages-section">
|
||||
<h2 class="section-title">我的消息</h2>
|
||||
|
||||
<div class="message-tabs">
|
||||
<div class="layui-tab layui-tab-brief" lay-filter="messageTabs">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">全部消息</li>
|
||||
<li>未读消息</li>
|
||||
<li>已读消息</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="message-list" id="allMessages">
|
||||
<!-- 消息列表将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="message-list" id="unreadMessages">
|
||||
<!-- 未读消息列表 -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="message-list" id="readMessages">
|
||||
<!-- 已读消息列表 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.messages-section {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.message-tabs {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.message-item:hover {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.message-item.unread {
|
||||
background-color: #f0f7ff;
|
||||
}
|
||||
|
||||
.message-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.message-title {
|
||||
font-weight: 500;
|
||||
margin-bottom: 4px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.message-text {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.message-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.message-time {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.message-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.message-actions button {
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
background: none;
|
||||
border: 1px solid #d9d9d9;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.message-actions button:hover {
|
||||
border-color: #1677ff;
|
||||
color: #1677ff;
|
||||
}
|
||||
|
||||
.empty-message {
|
||||
text-align: center;
|
||||
padding: 40px 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.message-item {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.message-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['element', 'layer'], function(){
|
||||
var element = layui.element;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 加载消息列表
|
||||
function loadMessages(type) {
|
||||
var container = document.getElementById(type + 'Messages');
|
||||
var loadIndex = layer.load(2);
|
||||
|
||||
fetch('/index/user/getMessages?type=' + type)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
layer.close(loadIndex);
|
||||
if(data.code === 0) {
|
||||
renderMessages(container, data.data);
|
||||
} else {
|
||||
layer.msg(data.msg || '加载失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.close(loadIndex);
|
||||
layer.msg('加载失败,请重试', {icon: 2});
|
||||
});
|
||||
}
|
||||
|
||||
// 渲染消息列表
|
||||
function renderMessages(container, messages) {
|
||||
if(!messages || messages.length === 0) {
|
||||
container.innerHTML = '<div class="empty-message">暂无消息</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '';
|
||||
messages.forEach(function(message) {
|
||||
html += `
|
||||
<div class="message-item ${message.is_read ? '' : 'unread'}" data-id="${message.id}">
|
||||
<img src="${message.avatar || '/static/images/avatar.png'}" class="message-avatar" alt="头像">
|
||||
<div class="message-content">
|
||||
<div class="message-title">${message.title}</div>
|
||||
<div class="message-text">${message.content}</div>
|
||||
<div class="message-meta">
|
||||
<span class="message-time">${message.create_time}</span>
|
||||
<div class="message-actions">
|
||||
${!message.is_read ? '<button class="mark-read">标记已读</button>' : ''}
|
||||
<button class="delete-message">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
container.innerHTML = html;
|
||||
|
||||
// 绑定事件
|
||||
bindMessageEvents(container);
|
||||
}
|
||||
|
||||
// 绑定消息事件
|
||||
function bindMessageEvents(container) {
|
||||
// 标记已读
|
||||
container.querySelectorAll('.mark-read').forEach(btn => {
|
||||
btn.addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
var messageId = this.closest('.message-item').dataset.id;
|
||||
markAsRead(messageId);
|
||||
});
|
||||
});
|
||||
|
||||
// 删除消息
|
||||
container.querySelectorAll('.delete-message').forEach(btn => {
|
||||
btn.addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
var messageId = this.closest('.message-item').dataset.id;
|
||||
deleteMessage(messageId);
|
||||
});
|
||||
});
|
||||
|
||||
// 点击消息
|
||||
container.querySelectorAll('.message-item').forEach(item => {
|
||||
item.addEventListener('click', function() {
|
||||
var messageId = this.dataset.id;
|
||||
viewMessage(messageId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 标记已读
|
||||
function markAsRead(messageId) {
|
||||
fetch('/index/user/markMessageRead', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({id: messageId})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg('已标记为已读', {icon: 1});
|
||||
// 重新加载消息列表
|
||||
loadMessages('all');
|
||||
loadMessages('unread');
|
||||
loadMessages('read');
|
||||
} else {
|
||||
layer.msg(data.msg || '操作失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('操作失败,请重试', {icon: 2});
|
||||
});
|
||||
}
|
||||
|
||||
// 删除消息
|
||||
function deleteMessage(messageId) {
|
||||
layer.confirm('确定要删除这条消息吗?', {
|
||||
btn: ['确定','取消']
|
||||
}, function(){
|
||||
fetch('/index/user/deleteMessage', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({id: messageId})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg('删除成功', {icon: 1});
|
||||
// 重新加载消息列表
|
||||
loadMessages('all');
|
||||
loadMessages('unread');
|
||||
loadMessages('read');
|
||||
} else {
|
||||
layer.msg(data.msg || '删除失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('删除失败,请重试', {icon: 2});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 查看消息详情
|
||||
function viewMessage(messageId) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '消息详情',
|
||||
area: ['500px', '400px'],
|
||||
content: '/index/user/messageDetail?id=' + messageId
|
||||
});
|
||||
}
|
||||
|
||||
// 监听标签切换
|
||||
element.on('tab(messageTabs)', function(data){
|
||||
var type = ['all', 'unread', 'read'][data.index];
|
||||
loadMessages(type);
|
||||
});
|
||||
|
||||
// 初始加载全部消息
|
||||
loadMessages('all');
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,210 @@
|
||||
<div class="notifications-section">
|
||||
<h2 class="section-title">系统通知</h2>
|
||||
|
||||
<div class="layui-tab layui-tab-brief" lay-filter="notificationTabs">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">全部通知</li>
|
||||
<li>未读通知</li>
|
||||
<li>已读通知</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="notification-list" id="allNotifications"></div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="notification-list" id="unreadNotifications"></div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="notification-list" id="readNotifications"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.notifications-section {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.notification-list {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.notification-item {
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.notification-item:hover {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.notification-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.notification-title {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.notification-time {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.notification-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.notification-item.unread .notification-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.notification-item.unread::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background-color: #1677ff;
|
||||
border-radius: 50%;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.notification-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['element', 'layer'], function(){
|
||||
var element = layui.element;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 加载通知列表
|
||||
function loadNotifications(type) {
|
||||
var container = document.getElementById(type + 'Notifications');
|
||||
container.innerHTML = '<div class="layui-anim layui-anim-upbit layui-anim-loop layui-anim-shrink" style="text-align: center; padding: 20px;"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i></div>';
|
||||
|
||||
fetch('/index/user/getNotifications?type=' + type)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
if(data.data.length === 0) {
|
||||
container.innerHTML = '<div class="layui-none">暂无通知</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '';
|
||||
data.data.forEach(function(notification) {
|
||||
html += `
|
||||
<div class="notification-item ${notification.is_read ? '' : 'unread'}" data-id="${notification.id}">
|
||||
<div class="notification-content">
|
||||
<div class="notification-title">${notification.title}</div>
|
||||
<div class="notification-time">${notification.create_time}</div>
|
||||
</div>
|
||||
<div class="notification-actions">
|
||||
<button class="layui-btn layui-btn-xs" onclick="viewNotification(${notification.id})">查看</button>
|
||||
<button class="layui-btn layui-btn-xs layui-btn-danger" onclick="deleteNotification(${notification.id})">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
container.innerHTML = html;
|
||||
} else {
|
||||
layer.msg(data.msg || '加载失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('加载失败,请重试', {icon: 2});
|
||||
});
|
||||
}
|
||||
|
||||
// 查看通知
|
||||
window.viewNotification = function(notificationId) {
|
||||
fetch('/index/user/readNotification', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({id: notificationId})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '通知详情',
|
||||
area: ['500px', '400px'],
|
||||
content: '/index/user/notificationDetail?id=' + notificationId
|
||||
});
|
||||
// 重新加载通知列表
|
||||
loadNotifications('all');
|
||||
loadNotifications('unread');
|
||||
loadNotifications('read');
|
||||
} else {
|
||||
layer.msg(data.msg || '操作失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('操作失败,请重试', {icon: 2});
|
||||
});
|
||||
}
|
||||
|
||||
// 删除通知
|
||||
window.deleteNotification = function(notificationId) {
|
||||
layer.confirm('确定要删除这条通知吗?', {
|
||||
btn: ['确定','取消']
|
||||
}, function(){
|
||||
fetch('/index/user/deleteNotification', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({id: notificationId})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg('删除成功', {icon: 1});
|
||||
// 重新加载通知列表
|
||||
loadNotifications('all');
|
||||
loadNotifications('unread');
|
||||
loadNotifications('read');
|
||||
} else {
|
||||
layer.msg(data.msg || '删除失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('删除失败,请重试', {icon: 2});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 监听标签切换
|
||||
element.on('tab(notificationTabs)', function(data){
|
||||
var type = ['all', 'unread', 'read'][data.index];
|
||||
loadNotifications(type);
|
||||
});
|
||||
|
||||
// 初始加载全部通知
|
||||
loadNotifications('all');
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,111 @@
|
||||
<div class="password-section">
|
||||
<h2 class="section-title">修改密码</h2>
|
||||
|
||||
<form class="layui-form" lay-filter="passwordForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">当前密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="oldPassword" placeholder="请输入当前密码" class="layui-input" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="newPassword" placeholder="请输入新密码" class="layui-input" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">确认密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="confirmPassword" placeholder="请再次输入新密码" class="layui-input" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="savePassword">保存修改</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.password-section {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
.layui-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.layui-form-label {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 110px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function(){
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 监听表单提交
|
||||
form.on('submit(savePassword)', function(data){
|
||||
// 验证两次密码是否一致
|
||||
if(data.field.newPassword !== data.field.confirmPassword) {
|
||||
layer.msg('两次输入的密码不一致', {icon: 2});
|
||||
return false;
|
||||
}
|
||||
|
||||
// 发送AJAX请求修改密码
|
||||
fetch('/index/user/changePassword', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data.field)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg('密码修改成功', {icon: 1});
|
||||
// 清空表单
|
||||
document.querySelector('form').reset();
|
||||
} else {
|
||||
layer.msg(data.msg || '修改失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('修改失败,请重试', {icon: 2});
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,170 @@
|
||||
<div class="security-section">
|
||||
<h2 class="section-title">安全设置</h2>
|
||||
|
||||
<form class="layui-form" lay-filter="securityForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">登录密码</label>
|
||||
<div class="layui-input-block">
|
||||
<button type="button" class="layui-btn" onclick="changePassword()">修改密码</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">手机绑定</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="phone-info">
|
||||
<span id="phoneNumber">未绑定</span>
|
||||
<button type="button" class="layui-btn layui-btn-primary" onclick="bindPhone()">绑定手机</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">邮箱绑定</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="email-info">
|
||||
<span id="emailAddress">未绑定</span>
|
||||
<button type="button" class="layui-btn layui-btn-primary" onclick="bindEmail()">绑定邮箱</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">两步验证</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="twoFactor" lay-skin="switch" lay-text="开启|关闭">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.security-section {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.phone-info, .email-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.layui-form-label {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 110px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function(){
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 加载用户安全信息
|
||||
loadSecurityInfo();
|
||||
|
||||
// 监听两步验证开关
|
||||
form.on('switch(twoFactor)', function(data){
|
||||
updateTwoFactor(data.elem.checked);
|
||||
});
|
||||
});
|
||||
|
||||
// 加载安全信息
|
||||
function loadSecurityInfo() {
|
||||
fetch('/index/user/getSecurityInfo')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
document.getElementById('phoneNumber').textContent = data.data.phone || '未绑定';
|
||||
document.getElementById('emailAddress').textContent = data.data.email || '未绑定';
|
||||
// 设置两步验证开关状态
|
||||
layui.form.val('securityForm', {
|
||||
twoFactor: data.data.twoFactor
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 修改密码
|
||||
function changePassword() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改密码',
|
||||
area: ['500px', '400px'],
|
||||
content: '/index/user/component/password'
|
||||
});
|
||||
}
|
||||
|
||||
// 绑定手机
|
||||
function bindPhone() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '绑定手机',
|
||||
area: ['500px', '400px'],
|
||||
content: '/index/user/component/bindPhone'
|
||||
});
|
||||
}
|
||||
|
||||
// 绑定邮箱
|
||||
function bindEmail() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '绑定邮箱',
|
||||
area: ['500px', '400px'],
|
||||
content: '/index/user/component/bindEmail'
|
||||
});
|
||||
}
|
||||
|
||||
// 更新两步验证状态
|
||||
function updateTwoFactor(enabled) {
|
||||
fetch('/index/user/updateTwoFactor', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({enabled: enabled})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg(enabled ? '两步验证已开启' : '两步验证已关闭', {icon: 1});
|
||||
} else {
|
||||
layer.msg(data.msg || '操作失败', {icon: 2});
|
||||
// 恢复开关状态
|
||||
layui.form.val('securityForm', {
|
||||
twoFactor: !enabled
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('操作失败,请重试', {icon: 2});
|
||||
// 恢复开关状态
|
||||
layui.form.val('securityForm', {
|
||||
twoFactor: !enabled
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,109 @@
|
||||
<div class="settings-section">
|
||||
<h2 class="section-title">基本设置</h2>
|
||||
|
||||
<form class="layui-form" lay-filter="settingsForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="username" value="{$user.username}" class="layui-input" lay-verify="required" placeholder="请输入用户名">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">邮箱</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="email" name="email" value="{$user.email}" class="layui-input" lay-verify="required|email" placeholder="请输入邮箱">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">手机号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="phone" value="{$user.phone}" class="layui-input" lay-verify="phone" placeholder="请输入手机号">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">个人简介</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="bio" placeholder="请输入个人简介" class="layui-textarea">{$user.bio}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="saveSettings">保存设置</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.settings-section {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.layui-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.layui-form-label {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 110px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function(){
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
|
||||
// 监听表单提交
|
||||
form.on('submit(saveSettings)', function(data){
|
||||
fetch('/index/user/updateSettings', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data.field)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg('设置保存成功', {icon: 1});
|
||||
} else {
|
||||
layer.msg(data.msg || '保存失败', {icon: 2});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('保存失败,请重试', {icon: 2});
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,158 @@
|
||||
<div class="sidebar">
|
||||
<div class="user-info">
|
||||
<div class="avatar-wrapper">
|
||||
<img src="{$user.avatar|default='/static/images/avatar.png'}" class="avatar" alt="用户头像">
|
||||
</div>
|
||||
<h3 class="username">{$user.name}</h3>
|
||||
<p class="email">{$user.account}</p>
|
||||
</div>
|
||||
|
||||
<nav class="menu">
|
||||
<a href="javascript:;" class="menu-item active" data-target="profile-basic">
|
||||
<i class="icon">👤</i>
|
||||
<span>个人资料</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="menu-item" data-target="profile-avatar">
|
||||
<i class="icon">🖼️</i>
|
||||
<span>修改头像</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="menu-item" data-target="profile-password">
|
||||
<i class="icon">🔒</i>
|
||||
<span>修改密码</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="menu-item" data-target="profile-messages">
|
||||
<i class="icon">✉️</i>
|
||||
<span>我的消息</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="menu-item" data-target="profile-notifications">
|
||||
<i class="icon">🔔</i>
|
||||
<span>系统通知</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="menu-item" data-target="profile-settings">
|
||||
<i class="icon">⚙️</i>
|
||||
<span>基本设置</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="menu-item" data-target="profile-security">
|
||||
<i class="icon">🛡️</i>
|
||||
<span>安全设置</span>
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
||||
padding: 24px 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
text-align: center;
|
||||
padding: 0 24px 24px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.avatar-wrapper {
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
margin: 0 auto 16px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 3px solid #f5f5f5;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.avatar:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
|
||||
.email {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
color: #666;
|
||||
text-decoration: none;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 4px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.menu-item:hover {
|
||||
background: #f5f7fa;
|
||||
color: #1677ff;
|
||||
}
|
||||
|
||||
.menu-item.active {
|
||||
background: #e6f4ff;
|
||||
color: #1677ff;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 20px;
|
||||
margin-right: 12px;
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
/* 响应式适配 */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// 获取当前页面路径
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
// 移除所有active类
|
||||
document.querySelectorAll('.menu-item').forEach(item => {
|
||||
item.classList.remove('active');
|
||||
});
|
||||
|
||||
// 为当前页面对应的菜单项添加active类
|
||||
document.querySelectorAll('.menu-item').forEach(item => {
|
||||
if (item.getAttribute('href') === currentPath) {
|
||||
item.classList.add('active');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user