157 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <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-wallet">
 | |
|             <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-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;
 | |
|         display: flex;
 | |
|         flex-direction: column;
 | |
|         align-items: center;
 | |
|     }
 | |
| 
 | |
|     .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;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     i {
 | |
|         font-style: normal;
 | |
|     }
 | |
| </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> |