refactor: 重写导航栏布局与交互
- 导航项重新排序:首页、投稿、信封图标、头像下拉菜单 - 铃铛图标替换为信封图标 - 用户名/设置/退出移入头像 hover 下拉菜单 - 设置改名为个人中心,退出改名为退出登录 - 头像点击跳转 /space,hover 展开下拉菜单 - 无头像时显示用户名首字彩色圆形占位 - Avatar 数据链路打通:Session→Middleware→BuildPageData→模板 - FindByIDForAuth 查询增加 avatar 列 - 新增 substr 模板函数
This commit is contained in:
@ -79,13 +79,16 @@ header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: .6rem 0;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: .6rem 2rem;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 1.4rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-primary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.logo span {
|
||||
@ -94,11 +97,19 @@ header {
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
list-style: none;
|
||||
gap: 2rem;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.nav-links li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-links a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
padding: .5rem 0;
|
||||
position: relative;
|
||||
@ -131,26 +142,11 @@ header {
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
.nav-user {
|
||||
color: var(--color-accent) !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
.nav-settings {
|
||||
font-size: .9rem;
|
||||
color: var(--color-secondary) !important;
|
||||
}
|
||||
|
||||
.nav-logout {
|
||||
color: var(--color-secondary) !important;
|
||||
}
|
||||
|
||||
/* ---------- Nav Contribute ---------- */
|
||||
.nav-contribute {
|
||||
display: inline-flex !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
vertical-align: middle;
|
||||
line-height: 1;
|
||||
gap: .25rem;
|
||||
color: var(--color-accent) !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
@ -158,36 +154,35 @@ header {
|
||||
.nav-contribute .icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.nav-contribute:hover {
|
||||
opacity: .8;
|
||||
}
|
||||
|
||||
/* ---------- Nav Messages Bell ---------- */
|
||||
.nav-messages {
|
||||
/* ---------- Nav Envelope ---------- */
|
||||
.nav-envelope {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 6px;
|
||||
padding: 4px;
|
||||
border-radius: 50%;
|
||||
transition: background .15s ease;
|
||||
}
|
||||
|
||||
.nav-messages:hover {
|
||||
.nav-links .nav-envelope::after,
|
||||
.nav-links .nav-envelope:hover::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-envelope:hover {
|
||||
background: rgba(52, 152, 219, .08);
|
||||
}
|
||||
|
||||
.nav-bell-icon {
|
||||
.nav-envelope-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.nav-bell-badge {
|
||||
.nav-envelope-badge {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -2px;
|
||||
@ -205,6 +200,97 @@ header {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ---------- Nav Avatar Dropdown ---------- */
|
||||
.nav-avatar-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-avatar-link {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
padding: 2px !important;
|
||||
}
|
||||
|
||||
.nav-links .nav-avatar-link::after,
|
||||
.nav-links .nav-avatar-link:hover::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 2px solid var(--color-border);
|
||||
transition: border-color .2s ease;
|
||||
}
|
||||
|
||||
.nav-avatar-default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--color-accent);
|
||||
color: #fff;
|
||||
font-size: .85rem;
|
||||
font-weight: 600;
|
||||
object-fit: unset;
|
||||
}
|
||||
|
||||
.nav-avatar-wrapper:hover .nav-avatar {
|
||||
border-color: var(--color-accent);
|
||||
}
|
||||
|
||||
.nav-dropdown {
|
||||
position: absolute;
|
||||
top: calc(100% + 8px);
|
||||
right: 0;
|
||||
min-width: 160px;
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,.12);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-4px);
|
||||
transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.nav-avatar-wrapper:hover .nav-dropdown {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.nav-dropdown-header {
|
||||
padding: .75rem 1rem;
|
||||
font-weight: 600;
|
||||
font-size: .9rem;
|
||||
color: var(--color-text);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.nav-dropdown-item {
|
||||
display: block !important;
|
||||
padding: .6rem 1rem !important;
|
||||
font-size: .9rem;
|
||||
color: var(--color-text-light) !important;
|
||||
transition: background .15s ease, color .15s ease;
|
||||
}
|
||||
|
||||
.nav-dropdown-item::after {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.nav-dropdown-item:hover {
|
||||
background: var(--color-bg);
|
||||
color: var(--color-accent) !important;
|
||||
}
|
||||
|
||||
.nav-dropdown-item.nav-logout:hover {
|
||||
color: var(--color-danger) !important;
|
||||
}
|
||||
|
||||
.mobile-menu-btn {
|
||||
display: none;
|
||||
background: none;
|
||||
@ -309,6 +395,9 @@ footer {
|
||||
|
||||
/* ---------- Responsive (共享:导航) ---------- */
|
||||
@media (max-width: 768px) {
|
||||
.nav-container {
|
||||
padding: .6rem 1rem;
|
||||
}
|
||||
.nav-links {
|
||||
display: none;
|
||||
position: absolute;
|
||||
@ -317,13 +406,28 @@ footer {
|
||||
width: 100%;
|
||||
background: var(--color-surface);
|
||||
flex-direction: column;
|
||||
padding: 1.5rem;
|
||||
padding: 1rem;
|
||||
box-shadow: 0 10px 15px rgba(0,0,0,.1);
|
||||
text-align: center;
|
||||
}
|
||||
.nav-links.active {
|
||||
display: flex;
|
||||
}
|
||||
.nav-links li {
|
||||
justify-content: center;
|
||||
}
|
||||
.nav-avatar-wrapper {
|
||||
justify-content: center;
|
||||
}
|
||||
.nav-dropdown {
|
||||
position: static;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
border-top: 1px solid var(--color-border);
|
||||
border-radius: 0;
|
||||
margin-top: .5rem;
|
||||
}
|
||||
.mobile-menu-btn {
|
||||
display: block;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user