feat: 主页右上角添加用户信息组件

- index.ui: 拆分导航栏为HBox(logo+链接+CTA | 用户信息)
- portal_userinfo.ui: 未登录显示登录/注册按钮,已登录显示用户头像+用户名
- user_menu.ui: 登录后下拉菜单(个人信息、退出登录)
- cms_styles.css: 添加用户信息区域样式
This commit is contained in:
Hermes Agent 2026-06-16 11:07:04 +08:00
parent 3ce149719e
commit f34ebcae43
4 changed files with 173 additions and 2 deletions

View File

@ -638,3 +638,47 @@ a { color: inherit; text-decoration: none; }
opacity: 1;
transform: translateY(0);
}
/* Portal User Info Widgets */
.portal-user-info {
display: flex;
align-items: center;
gap: 8px;
}
.portal-username {
font-size: 14px;
color: var(--text-secondary);
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.portal-login-btn,
.portal-register-btn {
font-size: 13px !important;
padding: 6px 16px !important;
border-radius: 6px !important;
border: none !important;
cursor: pointer !important;
transition: var(--transition);
}
.portal-login-btn {
background: rgba(255,255,255,0.1) !important;
color: var(--text-primary) !important;
}
.portal-login-btn:hover {
background: rgba(255,255,255,0.2) !important;
}
.portal-register-btn {
background: var(--brand-gradient) !important;
color: white !important;
}
.portal-register-btn:hover {
opacity: 0.9;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,89 @@
{% if get_user() %}
{
"widgettype": "HBox",
"options": {
"css": "portal-user-info clickable",
"width": "auto"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "urlwidget",
"popup_options": {
"eventpos": true,
"cwidth": 10,
"dismiss_events": ["command"]
},
"target": "Popup",
"options": {
"url": "{{entire_url('user_menu.ui')}}"
}
}
],
"subwidgets": [
{
"widgettype": "Svg",
"options": {
"url": "{{entire_url('/bricks/imgs/user.svg')}}",
"rate": 1.3
}
},
{
"widgettype": "Text",
"options": {
"css": "portal-username",
"text": "{{get_username()}}"
}
}
]
}
{% else %}
{
"widgettype": "HBox",
"options": {
"css": "portal-user-info",
"width": "auto"
},
"subwidgets": [
{
"widgettype": "Button",
"options": {
"label": "登录",
"css": "portal-login-btn",
"i18n": true
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "urlwidget",
"target": "self",
"options": {
"url": "{{entire_url('/rbac/user/login.ui')}}"
}
}
]
},
{
"widgettype": "Button",
"options": {
"label": "注册",
"css": "portal-register-btn",
"i18n": true
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "urlwidget",
"target": "self",
"options": {
"url": "{{entire_url('/rbac/user/register.ui')}}"
}
}
]
}
]
}
{% endif %}

18
wwwroot/user_menu.ui Normal file
View File

@ -0,0 +1,18 @@
{
"widgettype": "Menu",
"options": {
"cwidth": 10,
"items": [
{
"name": "profile",
"label": "个人信息",
"submenu": "{{entire_url('/rbac/user/userinfo.ui')}}"
},
{
"name": "logout",
"label": "退出登录",
"submenu": "{{entire_url('/rbac/user/logout.dspy')}}"
}
]
}
}