Skip to content

Commit 70fdfec

Browse files
committed
feat(navbar): 为面包屑组件添加显示图标的可选参数
在 render_breadcrumbs 模板标签中新增 show_icon 参数,用于控制面包屑导航项中图标的显示与隐藏。模板相应更新条件判断逻辑,使图标显示行为可配置。
1 parent 114c085 commit 70fdfec

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/django_starter/contrib/navbar/templates/django_starter/components/breadcrumbs_items.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<li>
33
{% if item.url and not forloop.last %}
44
<a href="{{ item.url }}" class="hover:text-primary transition-colors flex items-center gap-2">
5-
{% if item.icon %}<i class="{{ item.icon }}"></i>{% endif %}
5+
{% if show_icon and item.icon %}<i class="{{ item.icon }}"></i>{% endif %}
66
{{ item.text }}
77
</a>
88
{% else %}
99
<span class="text-base-content font-semibold flex items-center gap-2">
10-
{% if item.icon %}<i class="{{ item.icon }}"></i>{% endif %}
10+
{% if show_icon and item.icon %}<i class="{{ item.icon }}"></i>{% endif %}
1111
{{ item.text }}
1212
</span>
1313
{% endif %}

src/django_starter/contrib/navbar/templatetags/page_tags.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ def page_header(title, breadcrumbs=None):
4040
}
4141

4242
@register.inclusion_tag('django_starter/components/breadcrumbs_items.html')
43-
def render_breadcrumbs(breadcrumbs):
43+
def render_breadcrumbs(breadcrumbs, show_icon=False):
4444
"""
4545
仅渲染面包屑导航列表项 (<li>...</li>)
4646
用于 navbar 等需要单独显示面包屑的地方
47+
48+
:param show_icon: 是否显示图标,默认为 False
4749
"""
4850
return {
4951
'breadcrumbs': _normalize_breadcrumbs(breadcrumbs),
52+
'show_icon': show_icon,
5053
}

0 commit comments

Comments
 (0)