- 添加导航条目和分类数据模型 - 实现导航卡片网格展示 - 支持点击卡片打开链接 - 添加主题样式(渐变色、卡片阴影) - 区分系统默认和自定义条目 - 添加分类统计信息"
516 lines
15 KiB
HTML
516 lines
15 KiB
HTML
<!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>
|
||
:root {
|
||
--bg-color: #f7f9fb;
|
||
--card-bg: #ffffff;
|
||
--primary-color: #3b82f6;
|
||
--text-main: #1e293b;
|
||
--text-sub: #64748b;
|
||
--border-color: #e2e8f0;
|
||
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
|
||
--shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
|
||
|
||
--sidebar-width: 230px;
|
||
--sidebar-collapsed-width: 64px;
|
||
}
|
||
|
||
* {
|
||
box-sizing: border-box;
|
||
margin: 0;
|
||
padding: 0;
|
||
}
|
||
|
||
html {
|
||
scroll-behavior: smooth;
|
||
}
|
||
|
||
body {
|
||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||
background-color: var(--bg-color);
|
||
color: var(--text-main);
|
||
display: flex;
|
||
min-height: 100vh;
|
||
}
|
||
|
||
/* 侧边栏 */
|
||
.sidebar {
|
||
width: var(--sidebar-width);
|
||
background-color: var(--card-bg);
|
||
border-right: 1px solid var(--border-color);
|
||
padding: 20px 12px 12px 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
position: fixed;
|
||
height: 100vh;
|
||
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||
z-index: 100;
|
||
overflow-x: hidden;
|
||
}
|
||
|
||
body.sidebar-collapsed .sidebar {
|
||
width: var(--sidebar-collapsed-width);
|
||
padding: 20px 8px 12px 8px;
|
||
}
|
||
|
||
/* Logo 居中显示 */
|
||
.sidebar-header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 24px;
|
||
height: 40px;
|
||
text-align: center;
|
||
}
|
||
|
||
.logo {
|
||
font-size: 18px;
|
||
font-weight: 700;
|
||
color: var(--primary-color);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.logo-icon {
|
||
display: none;
|
||
font-size: 20px;
|
||
font-weight: 800;
|
||
color: var(--primary-color);
|
||
}
|
||
|
||
body.sidebar-collapsed .logo-text {
|
||
display: none;
|
||
}
|
||
|
||
body.sidebar-collapsed .logo-icon {
|
||
display: block;
|
||
}
|
||
|
||
/* 菜单区域 */
|
||
.nav-container {
|
||
flex: 1;
|
||
overflow-y: auto;
|
||
overflow-x: hidden;
|
||
}
|
||
|
||
.nav-group {
|
||
list-style: none;
|
||
}
|
||
|
||
.nav-item-wrapper {
|
||
margin-bottom: 4px;
|
||
}
|
||
|
||
.nav-link {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 11px 16px;
|
||
color: var(--text-sub);
|
||
text-decoration: none;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
cursor: pointer;
|
||
transition: all 0.2s;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.nav-link:hover {
|
||
background-color: #f8fafc;
|
||
color: var(--primary-color);
|
||
}
|
||
|
||
.nav-link.active {
|
||
background-color: #eff6ff;
|
||
color: var(--primary-color);
|
||
}
|
||
|
||
/* 小箭头样式与旋转特效 */
|
||
.arrow-icon {
|
||
font-size: 14px;
|
||
transition: transform 0.3s ease;
|
||
color: #94a3b8;
|
||
font-family: monospace;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.nav-item-wrapper.open > .nav-link .arrow-icon {
|
||
transform: rotate(90deg);
|
||
}
|
||
|
||
/* 子菜单 */
|
||
.sub-menu {
|
||
list-style: none;
|
||
padding-left: 16px;
|
||
max-height: 0;
|
||
overflow: hidden;
|
||
transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
|
||
}
|
||
|
||
.nav-item-wrapper.open .sub-menu {
|
||
max-height: 500px;
|
||
transition: max-height 0.3s ease-in-out;
|
||
}
|
||
|
||
.sub-menu .nav-link {
|
||
padding: 8px 16px;
|
||
font-size: 13px;
|
||
}
|
||
|
||
/* 侧边栏底部提交入口 */
|
||
.sidebar-footer {
|
||
border-top: 1px solid var(--border-color);
|
||
padding-top: 12px;
|
||
margin-top: 8px;
|
||
}
|
||
|
||
.submit-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 10px 16px;
|
||
color: var(--text-sub);
|
||
text-decoration: none;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
transition: all 0.2s;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.submit-btn:hover {
|
||
background-color: #f1f5f9;
|
||
color: var(--primary-color);
|
||
}
|
||
|
||
/* 折叠状态隐藏样式 */
|
||
body.sidebar-collapsed .nav-text,
|
||
body.sidebar-collapsed .arrow-icon,
|
||
body.sidebar-collapsed .sub-menu,
|
||
body.sidebar-collapsed .submit-text {
|
||
display: none !important;
|
||
}
|
||
|
||
body.sidebar-collapsed .nav-link,
|
||
body.sidebar-collapsed .submit-btn {
|
||
justify-content: center;
|
||
padding: 12px 0;
|
||
}
|
||
|
||
/* 主内容区 */
|
||
.main-content {
|
||
margin-left: var(--sidebar-width);
|
||
flex: 1;
|
||
padding: 24px 40px 40px 40px;
|
||
transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||
}
|
||
|
||
body.sidebar-collapsed .main-content {
|
||
margin-left: var(--sidebar-collapsed-width);
|
||
}
|
||
|
||
/* 顶部控制栏 */
|
||
.top-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16px;
|
||
max-width: 750px;
|
||
margin: 0 auto 36px auto;
|
||
}
|
||
|
||
.toggle-btn {
|
||
background: var(--card-bg);
|
||
border: 1px solid var(--border-color);
|
||
font-size: 18px;
|
||
color: var(--text-sub);
|
||
cursor: pointer;
|
||
width: 44px;
|
||
height: 44px;
|
||
border-radius: 12px;
|
||
box-shadow: var(--shadow);
|
||
transition: all 0.2s;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.toggle-btn:hover {
|
||
border-color: var(--primary-color);
|
||
color: var(--primary-color);
|
||
}
|
||
|
||
.search-container {
|
||
flex: 1;
|
||
}
|
||
|
||
.search-box {
|
||
width: 100%;
|
||
height: 44px;
|
||
padding: 0 20px;
|
||
font-size: 15px;
|
||
border: 1px solid var(--border-color);
|
||
border-radius: 12px;
|
||
background-color: var(--card-bg);
|
||
box-shadow: var(--shadow);
|
||
outline: none;
|
||
transition: border-color 0.2s, box-shadow 0.2s;
|
||
}
|
||
|
||
.search-box:focus {
|
||
border-color: var(--primary-color);
|
||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
|
||
}
|
||
|
||
/* 分组与卡片 */
|
||
.section-title {
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
margin-bottom: 16px;
|
||
color: var(--text-main);
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.section-title::before {
|
||
content: "";
|
||
display: inline-block;
|
||
width: 4px;
|
||
height: 16px;
|
||
background-color: var(--primary-color);
|
||
margin-right: 8px;
|
||
border-radius: 2px;
|
||
}
|
||
|
||
.grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||
gap: 16px;
|
||
margin-bottom: 36px;
|
||
}
|
||
|
||
.card {
|
||
background-color: var(--card-bg);
|
||
border: 1px solid var(--border-color);
|
||
border-radius: 10px;
|
||
padding: 14px 16px;
|
||
display: flex;
|
||
align-items: center;
|
||
text-decoration: none;
|
||
color: inherit;
|
||
box-shadow: var(--shadow);
|
||
transition: transform 0.2s, box-shadow 0.2s;
|
||
}
|
||
|
||
.card:hover {
|
||
transform: translateY(-2px);
|
||
box-shadow: var(--shadow-hover);
|
||
}
|
||
|
||
.card-icon {
|
||
width: 36px;
|
||
height: 36px;
|
||
border-radius: 8px;
|
||
background-color: #f1f5f9;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 600;
|
||
color: var(--primary-color);
|
||
margin-right: 12px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.card-info {
|
||
overflow: hidden;
|
||
}
|
||
|
||
.card-title {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.card-desc {
|
||
font-size: 12px;
|
||
color: var(--text-sub);
|
||
margin-top: 2px;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
/* 纯圆形回到顶部按钮 */
|
||
.back-to-top {
|
||
position: fixed;
|
||
bottom: 30px;
|
||
right: 30px;
|
||
width: 44px;
|
||
height: 44px;
|
||
background-color: var(--card-bg);
|
||
border: 1px solid var(--border-color);
|
||
border-radius: 50%;
|
||
color: var(--text-sub);
|
||
font-size: 18px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
cursor: pointer;
|
||
box-shadow: var(--shadow);
|
||
transition: all 0.2s ease;
|
||
text-decoration: none;
|
||
z-index: 90;
|
||
}
|
||
|
||
.back-to-top:hover {
|
||
color: var(--primary-color);
|
||
border-color: var(--primary-color);
|
||
transform: translateY(-3px);
|
||
box-shadow: var(--shadow-hover);
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<!-- 侧边导航 -->
|
||
<aside class="sidebar">
|
||
<!-- Logo 居中 -->
|
||
<div class="sidebar-header">
|
||
<div class="logo">
|
||
<span class="logo-text">Suxing Nav</span>
|
||
<span class="logo-icon">S</span>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 纯文字菜单(已移除所有 emoji 图标) -->
|
||
<div class="nav-container">
|
||
<ul class="nav-group">
|
||
<li class="nav-item-wrapper">
|
||
<a href="#common" class="nav-link active">
|
||
<span class="nav-text">常用推荐</span>
|
||
</a>
|
||
</li>
|
||
|
||
<li class="nav-item-wrapper">
|
||
<div class="nav-link has-sub">
|
||
<span class="nav-text">素材资源</span>
|
||
<span class="arrow-icon">›</span>
|
||
</div>
|
||
<ul class="sub-menu">
|
||
<li><a href="#design" class="nav-link"><span class="nav-text">UI 设计</span></a></li>
|
||
<li><a href="#icon" class="nav-link"><span class="nav-text">图标库</span></a></li>
|
||
<li><a href="#stock" class="nav-link"><span class="nav-text">高清壁纸</span></a></li>
|
||
</ul>
|
||
</li>
|
||
|
||
<li class="nav-item-wrapper">
|
||
<div class="nav-link has-sub">
|
||
<span class="nav-text">开发工具</span>
|
||
<span class="arrow-icon">›</span>
|
||
</div>
|
||
<ul class="sub-menu">
|
||
<li><a href="#dev" class="nav-link"><span class="nav-text">前端框架</span></a></li>
|
||
<li><a href="#api" class="nav-link"><span class="nav-text">在线 API</span></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<!-- 侧边栏底部纯文字提交按钮 -->
|
||
<div class="sidebar-footer">
|
||
<a href="#submit" class="submit-btn" title="提交网站">
|
||
<span class="submit-text">提交网站</span>
|
||
</a>
|
||
</div>
|
||
</aside>
|
||
|
||
<!-- 主体内容 -->
|
||
<main class="main-content">
|
||
<!-- 顶部控制栏 -->
|
||
<div class="top-bar">
|
||
<button class="toggle-btn" id="toggleBtn" title="展开/折叠侧边栏">☰</button>
|
||
<div class="search-container">
|
||
<input type="text" class="search-box" placeholder="输入关键字搜索全网资源...">
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 分组 1 -->
|
||
<div id="common">
|
||
<div class="section-title">常用推荐</div>
|
||
<div class="grid">
|
||
<a href="#" class="card">
|
||
<div class="card-icon">G</div>
|
||
<div class="card-info">
|
||
<div class="card-title">GitHub</div>
|
||
<div class="card-desc">代码托管与开源社区</div>
|
||
</div>
|
||
</a>
|
||
<a href="#" class="card">
|
||
<div class="card-icon">Z</div>
|
||
<div class="card-info">
|
||
<div class="card-title">知乎</div>
|
||
<div class="card-desc">深度内容问答社区</div>
|
||
</div>
|
||
</a>
|
||
<a href="#" class="card">
|
||
<div class="card-icon">B</div>
|
||
<div class="card-info">
|
||
<div class="card-title">哔哩哔哩</div>
|
||
<div class="card-desc">弹幕视频分享网站</div>
|
||
</div>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 分组 2 -->
|
||
<div id="design">
|
||
<div class="section-title">素材资源 - UI 设计</div>
|
||
<div class="grid">
|
||
<a href="#" class="card">
|
||
<div class="card-icon">F</div>
|
||
<div class="card-info">
|
||
<div class="card-title">Figma</div>
|
||
<div class="card-desc">协同界面设计工具</div>
|
||
</div>
|
||
</a>
|
||
<a href="#" class="card">
|
||
<div class="card-icon">D</div>
|
||
<div class="card-info">
|
||
<div class="card-title">Dribbble</div>
|
||
<div class="card-desc">全球设计作品分享社区</div>
|
||
</div>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
|
||
<!-- 圆形回到顶部按钮 -->
|
||
<a href="#" class="back-to-top" title="回到顶部">↑</a>
|
||
|
||
<script>
|
||
// 1. 顶部按钮控制侧边栏折叠/展开
|
||
const toggleBtn = document.getElementById('toggleBtn');
|
||
toggleBtn.addEventListener('click', () => {
|
||
document.body.classList.toggle('sidebar-collapsed');
|
||
});
|
||
|
||
// 2. 小箭头菜单折叠/展开
|
||
const subMenuTriggers = document.querySelectorAll('.has-sub');
|
||
subMenuTriggers.forEach(trigger => {
|
||
trigger.addEventListener('click', () => {
|
||
if (document.body.classList.contains('sidebar-collapsed')) {
|
||
document.body.classList.remove('sidebar-collapsed');
|
||
}
|
||
const parentItem = trigger.closest('.nav-item-wrapper');
|
||
parentItem.classList.toggle('open');
|
||
});
|
||
});
|
||
</script>
|
||
|
||
</body>
|
||
</html> |