700 lines
21 KiB
HTML
700 lines
21 KiB
HTML
|
||
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>机械设计云平台</title>
|
||
<!-- 添加Iconify脚本 -->
|
||
<script src="https://code.iconify.design/iconify-icon/1.0.7/iconify-icon.min.js"></script>
|
||
<style>
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
body {
|
||
font-family: 'Arial', sans-serif;
|
||
display: flex;
|
||
height: 100vh;
|
||
}
|
||
|
||
/* 为图标添加样式 */
|
||
.nav-button iconify-icon {
|
||
margin-right: 8px;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
.header-title iconify-icon {
|
||
margin-right: 8px;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
/* 侧边栏样式 */
|
||
.sidebar {
|
||
width: 220px;
|
||
background-color: #FFFFFF;
|
||
display: flex;
|
||
flex-direction: column;
|
||
padding: 20px;
|
||
box-shadow: 2px 0 5px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.logo {
|
||
height: 80px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 30px;
|
||
}
|
||
|
||
.logo img {
|
||
max-width: 150px;
|
||
}
|
||
|
||
.nav-buttons {
|
||
flex-grow: 1;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.nav-button {
|
||
display: flex;
|
||
align-items: center;
|
||
width: 100%;
|
||
padding: 12px 15px;
|
||
margin-bottom: 10px;
|
||
background-color: #FFFFFF;
|
||
color: #4B5563;
|
||
border: none;
|
||
text-align: left;
|
||
cursor: pointer;
|
||
border-radius: 8px;
|
||
transition: all 0.3s ease;
|
||
font-weight: 600;
|
||
font-size: 15px;
|
||
}
|
||
|
||
.nav-button:hover {
|
||
background-color: #F3F4F6;
|
||
}
|
||
|
||
/* 激活按钮样式,显示竖线 */
|
||
.nav-button.active::before {
|
||
content: '';
|
||
display: block;
|
||
width: 3px;
|
||
height: 20px; /* 竖线的高度,比按钮的高度短 */
|
||
background-color: green;
|
||
margin-right: 15px; /* 留出空间与按钮文字分开 */
|
||
}
|
||
|
||
.nav-button.active {
|
||
background-color: #F3F4F6;
|
||
color: #1F2937;
|
||
}
|
||
|
||
.user-info {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 15px;
|
||
background-color: #FFFFFF;
|
||
}
|
||
|
||
.user-avatar {
|
||
width: 50px;
|
||
height: 50px;
|
||
border-radius: 50%;
|
||
margin-right: 10px;
|
||
background-color: #E5E7EB;
|
||
position: relative;
|
||
cursor: pointer;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.user-avatar:hover {
|
||
background-color: #F3F4F6;
|
||
}
|
||
|
||
.login-register {
|
||
position: relative;
|
||
cursor: pointer;
|
||
color: #4B5563;
|
||
transition: color 0.3s ease;
|
||
}
|
||
|
||
.login-register:hover {
|
||
color: #1F2937;
|
||
}
|
||
|
||
.main-content {
|
||
flex-grow: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
position: relative;
|
||
}
|
||
|
||
.header {
|
||
height: 60px;
|
||
background-color: #FFFFFF;
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 0 20px;
|
||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.header-title {
|
||
flex-grow: 1;
|
||
font-weight: bold;
|
||
color: #1F2937;
|
||
font-size: 18px;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.header-settings {
|
||
cursor: pointer;
|
||
color: #4B5563;
|
||
}
|
||
|
||
.settings-button {
|
||
background-color: #262E45;
|
||
color: #FFFFFF;
|
||
border: none;
|
||
padding: 8px 15px;
|
||
border-radius: 6px;
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
margin-left: 10px;
|
||
cursor: pointer;
|
||
transition: background-color 0.3s ease;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.settings-button:hover {
|
||
background-color: #3B4563;
|
||
}
|
||
|
||
.content-area {
|
||
flex-grow: 1;
|
||
padding: 20px;
|
||
background-color: #EFF4F9;
|
||
position: relative;
|
||
}
|
||
|
||
.function-zone {
|
||
position: absolute;
|
||
left: calc(10px);
|
||
top: calc(10px);
|
||
right: 10px;
|
||
bottom: 10px;
|
||
background-color: #FFFFFF;
|
||
border-radius: 5px;
|
||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||
padding: 20px;
|
||
overflow: auto;
|
||
}
|
||
|
||
.status-bar {
|
||
height: 40px;
|
||
background-color: #FFFFFF;
|
||
color: #6B7280;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
align-items: center;
|
||
padding: 0 20px;
|
||
font-size: 12px;
|
||
box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.settings-button span {
|
||
margin-left: 5px; /* Adjusted space between icon and text */
|
||
}
|
||
|
||
/* 模态框样式 */
|
||
.modal-overlay {
|
||
display: none;
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
background-color: rgba(0, 0, 0, 0.5);
|
||
align-items: center;
|
||
justify-content: center;
|
||
z-index: 1000;
|
||
}
|
||
|
||
.modal {
|
||
width: 50%;
|
||
background-color: #FFFFFF;
|
||
border-radius: 10px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
/* 设置框标题居左 */
|
||
.modal-header {
|
||
height: 60px;
|
||
background-color: #F1F1F1;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 0 20px;
|
||
font-size: 18px;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.modal-header .close-button {
|
||
background: none;
|
||
border: none;
|
||
font-size: 18px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.modal-body {
|
||
padding: 20px;
|
||
}
|
||
|
||
.tabs {
|
||
display: flex;
|
||
border-bottom: 2px solid #E0E0E0;
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.tab {
|
||
padding: 10px 20px;
|
||
cursor: pointer;
|
||
margin-right: 10px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
/* 悬停时背景色变化但下划线无圆角 */
|
||
.tab:hover {
|
||
background-color: #F3F4F6;
|
||
border-top-left-radius: 8px; /* 左上角圆角 */
|
||
border-top-right-radius: 8px; /* 右上角圆角 */
|
||
border-bottom-left-radius: 0; /* 左下角无圆角 */
|
||
border-bottom-right-radius: 0; /* 右上角无圆角 */
|
||
}
|
||
|
||
.tab.active {
|
||
border-bottom: 2px solid #4B5563;
|
||
}
|
||
|
||
.modal-body .tab-content {
|
||
display: none;
|
||
}
|
||
|
||
.modal-body .tab-content.active {
|
||
display: block;
|
||
}
|
||
|
||
.modal-footer {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
padding: 10px 20px;
|
||
background-color: #F1F1F1;
|
||
}
|
||
|
||
/* 确定按钮背景改为深色 */
|
||
.modal-footer button {
|
||
padding: 8px 15px;
|
||
background-color: #262E45; /* 新背景色 */
|
||
color: white;
|
||
border: none;
|
||
border-radius: 5px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
/* 鼠标悬停确定按钮的样式 */
|
||
.modal-footer button:hover {
|
||
background-color: #3B4563; /* 保留原悬停效果 */
|
||
}
|
||
|
||
/* 渐隐文字样式 */
|
||
.fade-text {
|
||
position: fixed;
|
||
top: 2%;
|
||
left: 50%;
|
||
transform: translateX(-50%);
|
||
color: #333;
|
||
font-size: 16px;
|
||
font-weight: bold;
|
||
animation: fadeOut 1s forwards;
|
||
}
|
||
|
||
@keyframes fadeOut {
|
||
from {
|
||
opacity: 1;
|
||
}
|
||
to {
|
||
opacity: 0;
|
||
}
|
||
}
|
||
|
||
/* 登录模态框样式 */
|
||
.login-modal {
|
||
display: none;
|
||
position: fixed;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
background-color: #FFFFFF;
|
||
padding: 20px;
|
||
border-radius: 10px; /* 与其它模态框一致 */
|
||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||
z-index: 1000;
|
||
}
|
||
|
||
.login-form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 15px;
|
||
}
|
||
|
||
.login-input {
|
||
padding: 8px;
|
||
border: 1px solid #E0E0E0;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.login-button {
|
||
padding: 8px;
|
||
background-color: #262E45;
|
||
color: white;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.login-button:hover {
|
||
background-color: #3B4563;
|
||
}
|
||
|
||
/* 注销按钮样式 */
|
||
.logout-button {
|
||
padding: 5px 10px;
|
||
background-color: #E0E0E0;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.logout-button:hover {
|
||
background-color: #D1D5DB;
|
||
}
|
||
|
||
/* 个人信息模态框 */
|
||
#profileModal {
|
||
display: none;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="sidebar">
|
||
<div class="logo">
|
||
<img src="v38_8.png" alt="Logo">
|
||
</div>
|
||
|
||
<div class="nav-buttons">
|
||
<button class="nav-button active" data-title="仪表板" data-icon="mdi:barometer">
|
||
<iconify-icon icon="mdi:barometer"></iconify-icon>仪表板
|
||
</button>
|
||
<button class="nav-button" data-title="电机" data-icon="mdi:motor-outline">
|
||
<iconify-icon icon="mdi:motor-outline"></iconify-icon>电机
|
||
</button>
|
||
<button class="nav-button" data-title="减速机" data-icon="fa6-solid:gears">
|
||
<iconify-icon icon="fa6-solid:gears"></iconify-icon>减速机
|
||
</button>
|
||
<button class="nav-button" data-title="联轴器" data-icon="ri:coupon-4-line">
|
||
<iconify-icon icon="ri:coupon-4-line"></iconify-icon>联轴器
|
||
</button>
|
||
<button class="nav-button" data-title="滚珠丝杆" data-icon="mdi:screw-machine-round-top">
|
||
<iconify-icon icon="mdi:screw-machine-round-top"></iconify-icon>滚珠丝杆
|
||
</button>
|
||
<button class="nav-button" data-title="直线导轨" data-icon="ic:baseline-drag-handle">
|
||
<iconify-icon icon="ic:baseline-drag-handle"></iconify-icon>直线导轨
|
||
</button>
|
||
<button class="nav-button" data-title="轴承" data-icon="ic:baseline-adjust">
|
||
<iconify-icon icon="ic:baseline-adjust"></iconify-icon>轴承
|
||
</button>
|
||
</div>
|
||
|
||
<div class="user-info">
|
||
<!-- 用户头像或登录/注册文字 -->
|
||
<div class="user-avatar">
|
||
<iconify-icon icon="mdi:barometer"></iconify-icon>
|
||
</div>
|
||
<div class="user-name"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="main-content">
|
||
<div class="header">
|
||
<div class="header-title">
|
||
<!-- 初始状态不会有图标 -->
|
||
</div>
|
||
<button class="settings-button" id="settingsButton">
|
||
<iconify-icon icon="uiw:setting-o"></iconify-icon><span>设置</span>
|
||
</button>
|
||
</div>
|
||
|
||
<div class="content-area">
|
||
<div class="function-zone">
|
||
<h2>功能区域</h2>
|
||
<p>Hello 星程技术</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="status-bar">
|
||
网络状态: 在线 | 系统版本: V1.0.0 | 开发者: 星程技术
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 模态框 -->
|
||
<div class="modal-overlay" id="modalOverlay">
|
||
<div class="modal">
|
||
<div class="modal-header">
|
||
设置
|
||
<button class="close-button" id="closeModal">X</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="tabs">
|
||
<div class="tab active">常规设置</div>
|
||
<div class="tab">系统设置</div>
|
||
<div class="tab">高级设置</div>
|
||
</div>
|
||
<div class="tab-content active">
|
||
<h3>常规设置内容</h3>
|
||
<p>这里是常规设置项。</p>
|
||
</div>
|
||
<div class="tab-content">
|
||
<h3>系统设置内容</h3>
|
||
<p>这里是系统设置项。</p>
|
||
</div>
|
||
<div class="tab-content">
|
||
<h3>高级设置内容</h3>
|
||
<p>这里是高级设置项。</p>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button id="confirmButton">确定</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 登录模态框 -->
|
||
<div class="modal-overlay login-modal" id="loginModalOverlay">
|
||
<div class="modal">
|
||
<div class="modal-header">
|
||
登录
|
||
<button class="close-button">X</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="login-form">
|
||
<input type="text" class="login-input" placeholder="用户名">
|
||
<input type="password" class="login-input" placeholder="密码">
|
||
<button type="submit" class="login-button">登录</button>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<!-- 确定按钮 -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 个人信息模态框 -->
|
||
<div class="modal-overlay" id="profileModalOverlay">
|
||
<div class="modal">
|
||
<div class="modal-header">
|
||
个人信息
|
||
<button class="close-button" id="closeProfile">X</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="user-profile">
|
||
<div class="profile-info">
|
||
<p>用户名: admin</p>
|
||
<!-- 可以添加更多用户信息 -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button class="logout-button">注销</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
const navButtons = document.querySelectorAll('.nav-button');
|
||
const headerTitle = document.querySelector('.header-title');
|
||
const functionZone = document.querySelector('.function-zone h2');
|
||
const settingsButton = document.getElementById('settingsButton');
|
||
const modalOverlay = document.getElementById('modalOverlay');
|
||
const loginModalOverlay = document.getElementById('loginModalOverlay');
|
||
const profileModalOverlay = document.getElementById('profileModalOverlay');
|
||
const closeModal = document.getElementById('closeModal');
|
||
const closeProfileModal = document.getElementById('closeProfile');
|
||
const userInfo = document.querySelector('.user-info');
|
||
const userAvatar = document.querySelector('.user-avatar');
|
||
const logoutButton = document.querySelector('.logout-button');
|
||
const loginRegisterText = document.querySelector('.login-register');
|
||
|
||
// 默认显示第一个功能页
|
||
window.onload = () => {
|
||
const defaultButton = document.querySelector('.nav-button.active');
|
||
if (defaultButton) {
|
||
updateContent(defaultButton);
|
||
}
|
||
// 检查用户登录状态
|
||
checkLoginStatus();
|
||
};
|
||
|
||
// 切换导航功能
|
||
navButtons.forEach(button => {
|
||
button.addEventListener('click', () => {
|
||
navButtons.forEach(b => b.classList.remove('active'));
|
||
button.classList.add('active');
|
||
updateContent(button);
|
||
});
|
||
});
|
||
|
||
function updateContent(button) {
|
||
const title = button.getAttribute('data-title');
|
||
const icon = button.getAttribute('data-icon');
|
||
|
||
// 更新顶部标题
|
||
headerTitle.innerHTML = `<iconify-icon icon="${icon}"></iconify-icon> ${title}`;
|
||
|
||
// 更新功能区内容
|
||
functionZone.textContent = `欢迎来到 ${title} 页面!`;
|
||
|
||
// 控制“设置”按钮显示状态
|
||
if (title === "仪表板") {
|
||
settingsButton.style.display = "flex";
|
||
} else {
|
||
settingsButton.style.display = "none";
|
||
}
|
||
}
|
||
|
||
// 打开设置弹窗
|
||
settingsButton.addEventListener('click', () => {
|
||
modalOverlay.style.display = 'flex';
|
||
});
|
||
|
||
// 关闭设置弹窗
|
||
closeModal.addEventListener('click', () => {
|
||
modalOverlay.style.display = 'none';
|
||
});
|
||
|
||
// 打开登录模态框
|
||
userAvatar.addEventListener('click', function() {
|
||
const isLoggedIn = localStorage.getItem('isLoggedIn');
|
||
if (isLoggedIn !== 'true') {
|
||
loginModalOverlay.style.display = 'flex';
|
||
} else {
|
||
profileModalOverlay.style.display = 'flex';
|
||
}
|
||
});
|
||
|
||
// 关闭个人信息模态框
|
||
closeProfileModal.addEventListener('click', () => {
|
||
profileModalOverlay.style.display = 'none';
|
||
});
|
||
|
||
// 处理注销
|
||
logoutButton.addEventListener('click', () => {
|
||
localStorage.removeItem('isLoggedIn');
|
||
profileModalOverlay.style.display = 'none';
|
||
window.location.reload();
|
||
});
|
||
|
||
// 登录表单提交处理
|
||
document.querySelector('.login-form').addEventListener('submit', function(e) {
|
||
e.preventDefault();
|
||
const username = this.querySelector('input[type="text"]').value;
|
||
const password = this.querySelector('input[type="password"]').value;
|
||
|
||
// 测试账号信息(admin/123)
|
||
if (username === 'admin' && password === '123') {
|
||
localStorage.setItem('isLoggedIn', 'true');
|
||
localStorage.setItem('userName', username);
|
||
loginModalOverlay.style.display = 'none';
|
||
checkLoginStatus();
|
||
} else {
|
||
alert('用户名或密码错误');
|
||
}
|
||
});
|
||
|
||
// 检查用户登录状态
|
||
function checkLoginStatus() {
|
||
const isLoggedIn = localStorage.getItem('isLoggedIn');
|
||
if (isLoggedIn === 'true') {
|
||
// 显示用户信息
|
||
const userName = localStorage.getItem('userName') || 'admin';
|
||
userAvatar.innerHTML = `
|
||
<iconify-icon icon="mdi:barometer" style="font-size: 24px;"></iconify-icon>
|
||
`;
|
||
document.querySelector('.user-name').textContent = userName;
|
||
loginRegisterText.style.display = 'none';
|
||
} else {
|
||
// 显示登录/注册
|
||
userAvatar.innerHTML = `
|
||
<span role="img" aria-label="登 录/注册">👋</span>
|
||
`;
|
||
document.querySelector('.user-name').textContent = '登录/注册';
|
||
loginRegisterText.style.display = 'block';
|
||
}
|
||
}
|
||
|
||
// 模态框TAB切换功能
|
||
const modalTabs = document.querySelectorAll('.tab');
|
||
const modalBodies = document.querySelectorAll('.tab-content');
|
||
modalTabs.forEach((tab, index) => {
|
||
tab.addEventListener('click', () => {
|
||
modalTabs.forEach(t => t.classList.remove('active'));
|
||
modalBodies.forEach(body => body.classList.remove('active'));
|
||
tab.classList.add('active');
|
||
modalBodies[index].classList.add('active');
|
||
});
|
||
});
|
||
|
||
// 确定按钮逻辑
|
||
const confirmButton = document.getElementById('confirmButton');
|
||
confirmButton.addEventListener('click', () => {
|
||
modalOverlay.style.display = 'none'; // 关闭模态框
|
||
// 显示“设置已保存”文字
|
||
const fadeText = document.createElement('div');
|
||
fadeText.className = 'fade-text';
|
||
fadeText.textContent = '设置已保存';
|
||
document.body.appendChild(fadeText);
|
||
// 3秒后移除文字
|
||
setTimeout(() => {
|
||
fadeText.remove();
|
||
}, 3000);
|
||
});
|
||
|
||
// 处理用户头像的悬停效果
|
||
userAvatar.addEventListener('mouseover', function() {
|
||
this.style.backgroundColor = '#F3F4F6';
|
||
});
|
||
|
||
userAvatar.addEventListener('mouseout', function() {
|
||
this.style.backgroundColor = '';
|
||
});
|
||
|
||
// 关闭登录模态框
|
||
document.querySelector('.login-modal .close-button').addEventListener('click', () => {
|
||
loginModalOverlay.style.display = 'none';
|
||
});
|
||
|
||
// 关闭个人信息模态框
|
||
document.querySelector('#profileModalOverlay .close-button').addEventListener('click', () => {
|
||
profileModalOverlay.style.display = 'none';
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|