Spaces:
Sleeping
Sleeping
File size: 4,861 Bytes
fb20480 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
"""
مكون ترويسة الصفحة المحسن
"""
import streamlit as st
from datetime import datetime
import config
def render_header():
"""
عرض ترويسة الصفحة المحسنة
"""
# إنشاء مكون الترويسة باستخدام HTML
header_html = """
<div class="header-container">
<div class="header-logo-title">
<img src="./static/images/logo.png" class="header-logo" alt="شعار النظام">
<div class="header-title">
<h1>نظام تحليل العقود والمناقصات</h1>
<p>الحلول الشاملة للتسعير والتحليل بالذكاء الاصطناعي</p>
</div>
</div>
<div class="header-info">
<button class="theme-toggle" id="theme-toggle" onclick="toggleTheme()">
<span id="theme-icon">🌙</span>
</button>
<div class="date-box">
<div class="date-day">{day}</div>
<div class="date-info">
<div class="date-month">{month}</div>
<div class="date-year">{year}</div>
</div>
</div>
</div>
</div>
<script>
function toggleTheme() {{
const body = document.body;
const icon = document.getElementById('theme-icon');
if (body.classList.contains('dark-theme')) {{
body.classList.remove('dark-theme');
icon.innerText = '🌙';
localStorage.setItem('theme', 'light');
}} else {{
body.classList.add('dark-theme');
icon.innerText = '☀️';
localStorage.setItem('theme', 'dark');
}}
}}
// تطبيق السمة المحفوظة عند تحميل الصفحة
document.addEventListener('DOMContentLoaded', () => {{
const savedTheme = localStorage.getItem('theme');
const icon = document.getElementById('theme-icon');
if (savedTheme === 'dark') {{
document.body.classList.add('dark-theme');
icon.innerText = '☀️';
}}
}});
</script>
"""
# الحصول على معلومات التاريخ الحالي
today = datetime.now()
day = today.day
month_names = [
"يناير", "فبراير", "مارس", "إبريل", "مايو", "يونيو",
"يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"
]
month = month_names[today.month - 1]
year = today.year
# استبدال القيم في قالب HTML
header_html = header_html.format(day=day, month=month, year=year)
# عرض الترويسة
st.markdown(header_html, unsafe_allow_html=True)
# إضافة شريط التنقل الرئيسي
if 'is_authenticated' in st.session_state and st.session_state.is_authenticated:
render_navigation_menu()
# إضافة خط فاصل
st.markdown("<hr>", unsafe_allow_html=True)
def render_navigation_menu():
"""
عرض قائمة التنقل الرئيسية المحسنة
"""
# إنشاء قائمة التنقل المختصرة
menu_items = [
{"icon": "🏠", "label": "الرئيسية", "url": "/?page=home", "active": True},
{"icon": "📊", "label": "لوحة المعلومات", "url": "/?page=dashboard", "active": False},
{"icon": "📑", "label": "المناقصات", "url": "/?page=tenders", "active": False},
{"icon": "📋", "label": "المشاريع", "url": "/?page=projects", "active": False},
{"icon": "⚙️", "label": "الإعدادات", "url": "/?page=settings", "active": False},
{"icon": "❓", "label": "المساعدة", "url": "/?page=help", "active": False}
]
# تحديد الصفحة النشطة
current_page = st.query_params.get("page", "home")
for item in menu_items:
if item["url"].endswith(current_page):
item["active"] = True
else:
item["active"] = False
# إنشاء قائمة HTML
menu_html = """
<div class="nav-menu">
<ul>
"""
for item in menu_items:
active_class = "active" if item["active"] else ""
menu_html += f"""
<li>
<a href="{item['url']}" class="{active_class}">
<span class="nav-icon">{item['icon']}</span>
<span class="nav-label">{item['label']}</span>
</a>
</li>
"""
menu_html += """
</ul>
</div>
"""
# عرض قائمة التنقل
st.markdown(menu_html, unsafe_allow_html=True)
|