M17idd commited on
Commit
cc3f791
·
verified ·
1 Parent(s): 01ff352

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +149 -123
app.py CHANGED
@@ -14,173 +14,199 @@ import streamlit as st
14
  from docx import Document as DocxDocument
15
 
16
 
17
- # ----------------- تنظیمات صفحه -----------------
18
- st.set_page_config(page_title="رزم یار ارتش", page_icon="🪖", layout="wide")
19
-
20
- # ----------------- استایل سفارشی -----------------
21
  st.markdown("""
22
  <style>
23
  @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap');
 
24
  html, body, [class*="css"] {
25
  font-family: 'Vazirmatn', Tahoma, sans-serif;
26
  direction: rtl;
27
  text-align: right;
28
  }
 
29
  .stApp {
30
- background: linear-gradient(to left, #f0f4f7, #d9e2ec);
 
31
  }
32
- .sidebar .sidebar-content {
33
- background-color: #ffffff;
34
- border-left: 2px solid #4e8a3e;
35
- padding-top: 10px;
 
 
 
36
  }
37
- .sidebar .sidebar-content div {
38
- margin-bottom: 10px;
39
- font-weight: bold;
40
- color: #2c3e50;
41
- font-size: 15px;
 
 
 
 
 
 
 
 
 
 
42
  }
 
 
 
 
 
 
 
43
  .stButton>button {
44
- background-color: #4e8a3e !important;
45
- color: white !important;
46
- font-weight: bold;
47
- border-radius: 8px;
48
- padding: 5px 16px;
49
- transition: 0.3s;
50
- font-size: 14px;
 
 
 
 
51
  }
 
52
  .stButton>button:hover {
53
- background-color: #3c6d30 !important;
 
 
54
  }
 
 
55
  .header-text {
56
  text-align: center;
57
- margin-top: 15px;
58
- margin-bottom: 25px;
59
- background-color: rgba(255, 255, 255, 0.85);
60
- padding: 16px;
61
- border-radius: 16px;
62
- box-shadow: 0 4px 10px rgba(0,0,0,0.1);
63
  }
 
64
  .header-text h1 {
65
- font-size: 36px;
66
- color: #2c3e50;
67
  margin: 0;
68
- font-weight: bold;
69
  }
 
70
  .subtitle {
71
- font-size: 16px;
72
- color: #34495e;
73
- margin-top: 5px;
74
  }
 
 
75
  .chat-message {
76
- background-color: rgba(255, 255, 255, 0.95);
77
- border: 1px solid #4e8a3e;
78
- border-radius: 12px;
79
- padding: 14px;
80
- margin-bottom: 10px;
81
- box-shadow: 0 4px 8px rgba(0,0,0,0.08);
82
- animation: fadeIn 0.5s ease;
 
 
 
 
 
 
 
 
 
 
83
  }
 
 
84
  .stTextInput>div>input, .stTextArea textarea {
85
- background-color: rgba(255,255,255,0.9) !important;
86
- border-radius: 8px !important;
87
- direction: rtl;
88
- text-align: right;
89
  font-family: 'Vazirmatn', Tahoma;
 
 
90
  }
 
91
  img.small-logo {
92
- width: 90px;
93
- margin-bottom: 15px;
94
  display: block;
95
- margin-right: auto;
96
- margin-left: auto;
97
  }
98
- .menu-item {
99
- display: flex;
100
- align-items: center;
101
- gap: 8px;
102
- padding: 6px 0;
103
- font-size: 15px;
104
- cursor: pointer;
105
- }
106
- .menu-item img {
107
- width: 20px;
108
- height: 20px;
109
- }
110
- </style>
111
- """, unsafe_allow_html=True)
112
-
113
- # ----------------- بدنه اصلی -----------------
114
- with st.sidebar:
115
- st.image("log.png", width=90)
116
-
117
 
118
- st.markdown("""
119
- <div class="menu-item">
120
- <img src="https://cdn-icons-png.flaticon.com/512/3596/3596165.png" />
121
- گفتگوی جدید
122
- </div>
123
- <div class="menu-item">
124
- <img src="https://cdn-icons-png.flaticon.com/512/709/709496.png" />
125
- تاریخچه
126
- </div>
127
- <hr/>
128
- <div class="menu-item">
129
- <img src="https://cdn-icons-png.flaticon.com/512/1828/1828932.png" />
130
- مدل‌های هوش مصنوعی
131
- </div>
132
- <div class="menu-item">
133
- <img src="https://cdn-icons-png.flaticon.com/512/681/681494.png" />
134
- تولید محتوا
135
- </div>
136
- <hr/>
137
- <div class="menu-item">
138
- <img src="https://cdn-icons-png.flaticon.com/512/3601/3601646.png" />
139
- دستیار ویژه
140
- </div>
141
- <div class="menu-item">
142
- <img src="https://cdn-icons-png.flaticon.com/512/709/709612.png" />
143
- ابزار مالی
144
- </div>
145
- <hr/>
146
- <div class="menu-item">
147
- <img src="https://cdn-icons-png.flaticon.com/512/2099/2099058.png" />
148
- تنظیمات
149
- </div>
150
- <div class="menu-item">
151
- <img src="https://cdn-icons-png.flaticon.com/512/597/597177.png" />
152
- پشتیبانی
153
- </div>
154
- """, unsafe_allow_html=True)
155
- st.markdown("""
156
- <style>
157
- /* تنظیم سایز سایدبار */
158
- [data-testid="stSidebar"] {
159
- width: 220px !important;
160
- flex-shrink: 0;
161
  }
 
 
162
  [data-testid="stSidebar"] > div {
163
- width: 220px !important;
164
  }
165
  </style>
166
  """, unsafe_allow_html=True)
167
 
168
- # محتوای اصلی
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  st.markdown("""
170
  <div class="header-text">
171
- <h1>رزم یار ارتش</h1>
172
- <div class="subtitle">دستیار هوشمند ارتشی برای پشتیبانی و راهبری</div>
173
  </div>
174
  """, unsafe_allow_html=True)
175
 
176
- st.markdown('<div class="chat-message">👋 سلام! چطور میتونم کمکتون کنم؟</div>', unsafe_allow_html=True)
177
-
178
- # چت اینپوت کاربر
179
- #user_input = st.text_input("پیام خود را وارد کنید...")
180
-
181
- #if user_input:
182
- # st.markdown(f'<div class="chat-message">📩 شما: {user_input}</div>', unsafe_allow_html=True)
183
-
184
 
185
 
186
  # ----------------- لود csv و ساخت ایندکس -----------------
 
14
  from docx import Document as DocxDocument
15
 
16
 
 
 
 
 
17
  st.markdown("""
18
  <style>
19
  @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap');
20
+
21
  html, body, [class*="css"] {
22
  font-family: 'Vazirmatn', Tahoma, sans-serif;
23
  direction: rtl;
24
  text-align: right;
25
  }
26
+
27
  .stApp {
28
+ background: linear-gradient(to left, #4b5e40, #2e3b2e);
29
+ color: #ffffff;
30
  }
31
+
32
+ /* استایل سایدبار */
33
+ [data-testid="stSidebar"] {
34
+ width: 260px !important;
35
+ background-color: #1a2b1e;
36
+ border: none !important; /* حذف حاشیه زرد */
37
+ padding-top: 20px;
38
  }
39
+
40
+ .menu-item {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 12px;
44
+ padding: 12px 20px;
45
+ font-size: 16px;
46
+ color: #d4d4d4;
47
+ cursor: pointer;
48
+ transition: background-color 0.3s ease;
49
+ }
50
+
51
+ .menu-item:hover {
52
+ background-color: #2e3b2e;
53
+ color: #b8860b;
54
  }
55
+
56
+ .menu-item img {
57
+ width: 24px;
58
+ height: 24px;
59
+ }
60
+
61
+ /* استایل دکمه‌ها */
62
  .stButton>button {
63
+ background-color: #b8860b !important;
64
+ color: #1a2b1e !important;
65
+ font-family: 'Vazirmatn', Tahoma;
66
+ font-weight: 700;
67
+ border-radius: 10px;
68
+ padding: 12px 24px;
69
+ border: none;
70
+ transition: all 0.3s ease;
71
+ font-size: 16px;
72
+ width: 100%;
73
+ margin: 10px 0;
74
  }
75
+
76
  .stButton>button:hover {
77
+ background-color: #8b6508 !important;
78
+ transform: translateY(-2px);
79
+ box-shadow: 0 4px 8px rgba(0,0,0,0.3);
80
  }
81
+
82
+ /* استایل هدر */
83
  .header-text {
84
  text-align: center;
85
+ margin: 20px 0;
86
+ background-color: rgba(26, 43, 30, 0.9);
87
+ padding: 25px;
88
+ border-radius: 15px;
89
+ box-shadow: 0 6px 12px rgba(0,0,0,0.4);
 
90
  }
91
+
92
  .header-text h1 {
93
+ font-size: 42px;
94
+ color: #b8860b;
95
  margin: 0;
96
+ font-weight: 700;
97
  }
98
+
99
  .subtitle {
100
+ font-size: 18px;
101
+ color: #d4d4d4;
102
+ margin-top: 10px;
103
  }
104
+
105
+ /* استایل پیام چت */
106
  .chat-message {
107
+ background-color: rgba(26, 43, 30, 0.95);
108
+ border: 2px solid #b8860b;
109
+ border-radius: 15px;
110
+ padding: 20px;
111
+ margin: 15px 0;
112
+ box-shadow: 0 6px 12px rgba(0,0,0,0.3);
113
+ animation: fadeIn 0.6s ease;
114
+ font-size: 18px;
115
+ color: #d4d4d4;
116
+ display: flex;
117
+ align-items: center;
118
+ gap: 15px;
119
+ }
120
+
121
+ @keyframes fadeIn {
122
+ from { opacity: 0; transform: translateY(10px); }
123
+ to { opacity: 1; transform: translateY(0); }
124
  }
125
+
126
+ /* استایل ورودی‌ها */
127
  .stTextInput>div>input, .stTextArea textarea {
128
+ background-color: rgba(26, 43, 30, 0.95) !important;
129
+ border-radius: 10px !important;
130
+ border: 1px solid #b8860b !important;
131
+ padding: 12px !important;
132
  font-family: 'Vazirmatn', Tahoma;
133
+ font-size: 16px;
134
+ color: #d4d4d4 !important;
135
  }
136
+
137
  img.small-logo {
138
+ width: 120px;
139
+ margin: 0 auto 20px;
140
  display: block;
 
 
141
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
+ hr {
144
+ border: 1px solid #b8860b;
145
+ margin: 15px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
147
+
148
+ /* رفع مشکل نوار زرد */
149
  [data-testid="stSidebar"] > div {
150
+ border: none !important;
151
  }
152
  </style>
153
  """, unsafe_allow_html=True)
154
 
155
+ # ----------------- احراز هویت ساده -----------------
156
+ if "authenticated" not in st.session_state:
157
+ st.session_state.authenticated = False
158
+
159
+ if not st.session_state.authenticated:
160
+ st.markdown("<h3 style='text-align: center; color: #b8860b;'>ورود به رزم‌یار ارتش</h3>", unsafe_allow_html=True)
161
+ username = st.text_input("نام کاربری:", placeholder="شناسه نظامی خود را وارد کنید")
162
+ password = st.text_input("رمز عبور:", type="password", placeholder="رمز عبور نظامی")
163
+ if st.button("ورود"):
164
+ if username == "admin" and password == "123":
165
+ st.session_state.authenticated = True
166
+ st.rerun()
167
+ else:
168
+ st.error("نام کاربری یا رمز عبور اشتباه است.")
169
+ st.stop()
170
+
171
+ # ----------------- سایدبار -----------------
172
+ with st.sidebar:
173
+ st.image("log.png", use_container_width=True) # اصلاح use_column_width
174
+
175
+ menu_items = [
176
+ ("گزارش عملیاتی", "https://cdn-icons-png.flaticon.com/512/3596/3596165.png"),
177
+ ("تاریخچه ماموریت‌ها", "https://cdn-icons-png.flaticon.com/512/709/709496.png"),
178
+ ("تحلیل داده‌های نظامی", "https://cdn-icons-png.flaticon.com/512/1828/1828932.png"),
179
+ ("مدیریت منابع", "https://cdn-icons-png.flaticon.com/512/681/681494.png"),
180
+ ("دستیار فرماندهی", "https://cdn-icons-png.flaticon.com/512/3601/3601646.png"),
181
+ ("تنظیمات امنیتی", "https://cdn-icons-png.flaticon.com/512/2099/2099058.png"),
182
+ ("پشتیبانی فنی", "https://cdn-icons-png.flaticon.com/512/597/597177.png"),
183
+ ]
184
+
185
+ for idx, (text, icon) in enumerate(menu_items):
186
+ st.markdown(f"""
187
+ <div class="menu-item">
188
+ <img src="{icon}" />
189
+ {text}
190
+ </div>
191
+ """, unsafe_allow_html=True)
192
+ if idx in [1, 3, 5]:
193
+ st.markdown("<hr/>", unsafe_allow_html=True)
194
+
195
+ # ----------------- محتوای اصلی -----------------
196
  st.markdown("""
197
  <div class="header-text">
198
+ <h1>رزم‌یار ارتش</h1>
199
+ <div class="subtitle">دستیار هوشمندارتش</div>
200
  </div>
201
  """, unsafe_allow_html=True)
202
 
203
+ # پیام خوش‌آمدگویی
204
+ st.markdown(f"""
205
+ <div class="chat-message">
206
+ <span style="font-size: 24px;">🪖</span>
207
+ <span>به رزم‌یار ارتش خوش آمدید. </span>
208
+ </div>
209
+ """, unsafe_allow_html=True)
 
210
 
211
 
212
  # ----------------- لود csv و ساخت ایندکس -----------------