GSMEthesis commited on
Commit
fdd9d59
·
verified ·
1 Parent(s): f4949e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -0
app.py CHANGED
@@ -176,6 +176,85 @@ st.markdown("""
176
  """, unsafe_allow_html=True)
177
 
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  # ========== توابع اصلی ==========
180
  def create_ride_map():
181
  """ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
 
176
  """, unsafe_allow_html=True)
177
 
178
 
179
+ st.components.v1.html("""
180
+ <script>
181
+ // تنظیم viewport دینامیک
182
+ document.querySelector('meta[name="viewport"]').content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
183
+
184
+ // تنظیمات کادر موبایل در دسکتاپ
185
+ function setupMobileFrame() {
186
+ const appContainer = document.querySelector('[data-testid="stAppViewContainer"]');
187
+ const isDesktop = window.innerWidth >= 768;
188
+
189
+ if (appContainer) {
190
+ if (isDesktop) {
191
+ // تنظیمات برای دسکتاپ
192
+ appContainer.style.width = '375px';
193
+ appContainer.style.height = '667px';
194
+ appContainer.style.margin = '0 auto';
195
+ appContainer.style.overflow = 'hidden';
196
+
197
+ // تنظیم اسکرول برای محتوای داخلی
198
+ const appContent = document.querySelector('.stApp > div');
199
+ if (appContent) {
200
+ appContent.style.maxHeight = 'calc(667px - 40px)';
201
+ appContent.style.overflowY = 'auto';
202
+ appContent.style.scrollbarWidth = 'none';
203
+ }
204
+
205
+ // تنظیم پس‌زمینه صفحه
206
+ document.body.style.background = '#f0f0f0';
207
+ document.body.style.display = 'flex';
208
+ document.body.style.justifyContent = 'center';
209
+ document.body.style.alignItems = 'center';
210
+ document.body.style.padding = '20px';
211
+ } else {
212
+ // تنظیمات برای موبایل واقعی
213
+ appContainer.style.width = '100%';
214
+ appContainer.style.maxWidth = '100%';
215
+ appContainer.style.height = 'auto';
216
+ appContainer.style.margin = '0';
217
+ appContainer.style.overflow = 'visible';
218
+ }
219
+ }
220
+ }
221
+
222
+ // غیرفعال کردن زوم و تنظیمات لمسی
223
+ function disableZoom() {
224
+ document.addEventListener('gesturestart', function(e) {
225
+ e.preventDefault();
226
+ });
227
+ document.addEventListener('dblclick', function(e) {
228
+ e.preventDefault();
229
+ }, { passive: false });
230
+ }
231
+
232
+ // تنظیم اندازه فونت بر اساس عرض دستگاه
233
+ function adjustFontSize() {
234
+ const container = document.querySelector('[data-testid="stAppViewContainer"]');
235
+ if (container) {
236
+ const width = container.offsetWidth;
237
+ const baseSize = width < 400 ? 14 : 16;
238
+ document.documentElement.style.fontSize = baseSize + 'px';
239
+ }
240
+ }
241
+
242
+ // اجرای تمام تنظیمات پس از لود صفحه
243
+ window.addEventListener('load', function() {
244
+ setupMobileFrame();
245
+ disableZoom();
246
+ adjustFontSize();
247
+ });
248
+
249
+ // اجرای مجدد تنظیمات هنگام تغییر سایز پنجره
250
+ window.addEventListener('resize', function() {
251
+ setupMobileFrame();
252
+ adjustFontSize();
253
+ });
254
+ </script>
255
+ """, height=0)
256
+
257
+
258
  # ========== توابع اصلی ==========
259
  def create_ride_map():
260
  """ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""