dm-design/平台端web/index.html

640 lines
20 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理后台</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 14px;
color: #333;
height: 100vh;
overflow: hidden;
}
.admin-layout {
display: flex;
height: 100vh;
}
/* 左侧菜单栏 */
.sidebar {
width: 210px;
background-color: rgb(48, 65, 86);
position: relative;
overflow-y: auto;
flex-shrink: 0;
}
.menu-list {
list-style: none;
padding: 0;
margin: 0;
}
.menu-item {
position: relative;
}
.menu-item-link {
display: flex;
align-items: center;
padding: 15px 20px;
color: rgba(255, 255, 255, 0.85);
text-decoration: none;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
border: none;
background: none;
width: 100%;
}
.menu-item-link:hover {
background-color: rgba(255, 255, 255, 0.1);
color: #fff;
}
.menu-item-link.active {
background-color: #40a9ff;
color: #fff;
}
.menu-icon {
width: 16px;
height: 16px;
margin-right: 12px;
flex-shrink: 0;
display: inline-block;
}
.menu-icon svg {
width: 100%;
height: 100%;
fill: rgba(255, 255, 255, 0.7);
}
.menu-text {
flex: 1;
}
.menu-arrow {
width: 12px;
height: 12px;
transition: transform 0.2s;
}
.menu-arrow svg {
width: 100%;
height: 100%;
fill: rgba(255, 255, 255, 0.6);
}
.menu-item.expanded .menu-arrow {
transform: rotate(180deg);
}
/* 子菜单 */
.submenu {
background-color: rgba(0, 0, 0, 0.1);
display: none;
padding-left: 48px;
}
.menu-item.expanded .submenu {
display: block;
}
.submenu-item {
display: block;
padding: 12px 20px;
color: rgba(255, 255, 255, 0.7);
text-decoration: none;
font-size: 14px;
cursor: pointer;
transition: all 0.3s;
}
.submenu-item:hover {
background-color: rgba(255, 255, 255, 0.1);
color: #fff;
}
.submenu-item.active {
background-color: #40a9ff;
color: #fff;
}
/* 右侧主内容区 */
.main-content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* 顶部导航栏 */
.header {
height: 64px;
background: #fff;
border-bottom: 1px solid #f0f0f0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.header-left {
display: flex;
align-items: center;
}
.menu-trigger {
width: 20px;
height: 20px;
cursor: pointer;
margin-right: 16px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.menu-trigger::before,
.menu-trigger::after,
.menu-trigger {
content: '';
height: 2px;
background: #333;
border-radius: 1px;
}
.menu-trigger::before,
.menu-trigger::after {
display: block;
width: 100%;
}
.breadcrumb {
display: flex;
align-items: center;
font-size: 14px;
color: #666;
}
.breadcrumb-item {
color: #666;
text-decoration: none;
transition: all 0.3s;
}
.breadcrumb-item:hover {
color: #1890ff;
}
.breadcrumb-separator {
margin: 0 8px;
color: #ddd;
}
.header-right {
display: flex;
align-items: center;
}
.user-info {
display: flex;
align-items: center;
padding: 8px 12px;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s;
}
.user-info:hover {
background-color: #fafafa;
}
.user-avatar {
width: 24px;
height: 24px;
background: #1890ff;
border-radius: 50%;
margin-right: 8px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 12px;
}
/* 标签页区域 */
.tabs-container {
height: 48px;
background: #fff;
border-bottom: 1px solid #f0f0f0;
display: flex;
align-items: center;
padding: 0 16px;
overflow-x: auto;
}
.tab-item {
display: flex;
align-items: center;
padding: 8px 16px;
background: #fafafa;
border: 1px solid #ddd;
border-radius: 4px 4px 0 0;
margin-right: 2px;
cursor: pointer;
font-size: 14px;
white-space: nowrap;
transition: all 0.3s;
position: relative;
min-width: 120px;
justify-content: space-between;
}
.tab-item.active {
background: #fff;
border-bottom-color: #fff;
z-index: 1;
margin-bottom: -1px;
}
.tab-item:hover {
background: #e6f7ff;
}
.tab-title {
flex: 1;
}
.tab-close {
width: 16px;
height: 16px;
background: #ddd;
border-radius: 50%;
margin-left: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: #fff;
opacity: 0.7;
transition: all 0.3s;
}
.tab-close:hover {
background: #ff4d4f;
opacity: 1;
}
.tab-item:first-child .tab-close {
display: none;
}
/* 内容区域 */
.content-area {
flex: 1;
background: #f5f5f5;
padding: 20px;
overflow-y: auto;
}
.content-container {
background: #fff;
border-radius: 8px;
padding: 24px;
min-height: 400px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
/* 响应式设计 */
@media (max-width: 768px) {
.sidebar {
position: fixed;
left: -210px;
top: 0;
height: 100vh;
z-index: 1000;
transition: left 0.3s;
}
.sidebar.open {
left: 0;
}
.main-content {
margin-left: 0;
}
}
/* 滚动条样式 */
.sidebar::-webkit-scrollbar {
width: 6px;
}
.sidebar::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.1);
}
.sidebar::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.5);
}
</style>
</head>
<body>
<div class="admin-layout">
<!-- 左侧菜单 -->
<aside class="sidebar">
<nav role="navigation">
<ul class="menu-list">
<li class="menu-item">
<button class="menu-item-link" onclick="toggleSubmenu(this)">
<span class="menu-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
<path fill="currentColor" d="M160 448a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32zm448 0a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32zM160 896a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32zm448 0a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32z"></path>
</svg>
</span>
<span class="menu-text">权限管理</span>
<span class="menu-arrow">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
<path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>
</svg>
</span>
</button>
<div class="submenu">
<a href="./权限管理/权限编辑.html" class="submenu-item" onclick="openTabWithIframe(this, '权限编辑')">权限编辑</a>
<a href="./权限管理/市场经营者创建.html" class="submenu-item" onclick="openTabWithIframe(this, '市场经营者创建')">市场经营者创建</a>
</div>
</li>
</ul>
</nav>
</aside>
<!-- 右侧主内容区 -->
<main class="main-content">
<!-- 顶部导航栏 -->
<header class="header">
<div class="header-left">
<div class="menu-trigger" onclick="toggleSidebar()"></div>
<nav class="breadcrumb">
<a href="#/dashboard" class="breadcrumb-item">首页</a>
<span class="breadcrumb-separator">/</span>
<a href="#" class="breadcrumb-item">权限管理</a>
<span class="breadcrumb-separator">/</span>
<span class="breadcrumb-item">权限编辑</span>
</nav>
</div>
<div class="header-right">
<div class="user-info">
<div class="user-avatar">A</div>
<span>admin</span>
</div>
</div>
</header>
<!-- 标签页区域 -->
<div class="tabs-container">
<div class="tab-item active" data-tab="home">
<span class="tab-title">首页</span>
</div>
</div>
<!-- 内容区域 -->
<div class="content-area">
<div class="content-container">
<div id="tab-content-home" class="tab-content active">
<h2 style="font-size: 24px; font-weight: 600; color: #262626; margin-bottom: 16px;">欢迎使用管理后台</h2>
<p style="color: #666; font-size: 14px;">这是首页内容区域,点击左侧菜单可以在此区域显示对应的页面内容。</p>
</div>
</div>
</div>
</main>
</div>
<script>
// 切换子菜单展开状态
function toggleSubmenu(button) {
const menuItem = button.parentElement;
menuItem.classList.toggle('expanded');
}
// 切换侧边栏显示/隐藏(移动端)
function toggleSidebar() {
const sidebar = document.querySelector('.sidebar');
sidebar.classList.toggle('open');
}
// 打开标签页
function openTab(link, title) {
const tabId = title.toLowerCase().replace(/\s+/g, '-');
// 检查标签页是否已存在
const existingTab = document.querySelector(`[data-tab="${tabId}"]`);
if (existingTab) {
// 激活已存在的标签页
setActiveTab(tabId, title);
return;
}
// 创建新标签页
const tabsContainer = document.querySelector('.tabs-container');
const newTab = document.createElement('div');
newTab.className = 'tab-item';
newTab.setAttribute('data-tab', tabId);
newTab.innerHTML = `
<span class="tab-title">${title}</span>
<span class="tab-close" onclick="closeTab(this)">×</span>
`;
newTab.onclick = () => setActiveTab(tabId, title);
tabsContainer.appendChild(newTab);
// 创建新内容区域
const contentArea = document.querySelector('.content-container');
const newContent = document.createElement('div');
newContent.id = `tab-content-${tabId}`;
newContent.className = 'tab-content';
newContent.style.display = 'none';
newContent.innerHTML = `
<p>这里是${title}页面的内容...</p>
`;
contentArea.appendChild(newContent);
// 激活新标签页
setActiveTab(tabId, title);
}
// 通过iframe打开标签页
function openTabWithIframe(link, title) {
const tabId = title.toLowerCase().replace(/\s+/g, '-');
// 检查标签页是否已存在
const existingTab = document.querySelector(`[data-tab="${tabId}"]`);
if (existingTab) {
// 激活已存在的标签页
setActiveTab(tabId, title);
return;
}
// 创建新标签页
const tabsContainer = document.querySelector('.tabs-container');
const newTab = document.createElement('div');
newTab.className = 'tab-item';
newTab.setAttribute('data-tab', tabId);
newTab.innerHTML = `
<span class="tab-title">${title}</span>
<span class="tab-close" onclick="closeTab(this)">×</span>
`;
newTab.onclick = () => setActiveTab(tabId, title);
tabsContainer.appendChild(newTab);
// 创建新内容区域使用iframe嵌入页面
const contentArea = document.querySelector('.content-container');
const newContent = document.createElement('div');
newContent.id = `tab-content-${tabId}`;
newContent.className = 'tab-content';
newContent.style.display = 'none';
newContent.innerHTML = `
<iframe src="${link.href}" style="width: 100%; height: 600px; border: none;"></iframe>
`;
contentArea.appendChild(newContent);
// 激活新标签页
setActiveTab(tabId, title);
}
// 设置活动标签页
function setActiveTab(tabId, title) {
// 移除所有标签页的活动状态
document.querySelectorAll('.tab-item').forEach(tab => {
tab.classList.remove('active');
});
document.querySelectorAll('.tab-content').forEach(content => {
content.style.display = 'none';
});
// 激活指定标签页
const activeTab = document.querySelector(`[data-tab="${tabId}"]`);
const activeContent = document.querySelector(`#tab-content-${tabId}`);
if (activeTab && activeContent) {
activeTab.classList.add('active');
activeContent.style.display = 'block';
// 不更新面包屑导航中的标题
}
}
// 关闭标签页
function closeTab(closeBtn) {
const tab = closeBtn.parentElement;
const tabId = tab.getAttribute('data-tab');
// 不能关闭首页标签
if (tabId === 'home') {
return;
}
const isActive = tab.classList.contains('active');
// 移除标签页和内容
tab.remove();
const content = document.querySelector(`#tab-content-${tabId}`);
if (content) {
content.remove();
}
// 如果关闭的是活动标签页,则激活首页
if (isActive) {
setActiveTab('home', '首页');
}
}
// 标签页点击事件
document.querySelectorAll('.tab-item').forEach(tab => {
tab.onclick = () => {
const tabId = tab.getAttribute('data-tab');
// 获取标签标题用于更新面包屑
const title = tab.querySelector('.tab-title').textContent;
setActiveTab(tabId, title);
};
});
// 更新面包屑导航
function updateBreadcrumb(title) {
// 不更新面包屑导航中的标题
return;
}
// 重写标签页点击事件处理函数以支持iframe标签页的面包屑更新
document.querySelectorAll('.tab-item').forEach(tab => {
tab.onclick = () => {
const tabId = tab.getAttribute('data-tab');
// 获取标签标题用于更新面包屑
const title = tab.querySelector('.tab-title').textContent;
setActiveTab(tabId, title);
};
});
// 菜单项点击事件处理
document.querySelectorAll('.submenu-item').forEach(item => {
item.addEventListener('click', function(e) {
// 如果有onclick属性阻止默认行为并执行onclick
if (this.onclick) {
e.preventDefault();
// 移除其他菜单项的激活状态
document.querySelectorAll('.submenu-item.active').forEach(activeItem => {
activeItem.classList.remove('active');
});
// 激活当前菜单项
this.classList.add('active');
const title = this.textContent;
this.onclick.call(this);
// 不更新面包屑导航中的标题
}
// 如果没有onclick属性允许默认行为链接跳转
});
});
// 响应式处理
window.addEventListener('resize', function() {
if (window.innerWidth > 768) {
document.querySelector('.sidebar').classList.remove('open');
}
});
// 点击外部区域关闭侧边栏(移动端)
document.addEventListener('click', function(e) {
const sidebar = document.querySelector('.sidebar');
const menuTrigger = document.querySelector('.menu-trigger');
if (window.innerWidth <= 768 &&
sidebar.classList.contains('open') &&
!sidebar.contains(e.target) &&
!menuTrigger.contains(e.target)) {
sidebar.classList.remove('open');
}
});
</script>
</body>
</html>