Falko Schindler hace 1 año
padre
commit
401a138de9
Se han modificado 2 ficheros con 5 adiciones y 6 borrados
  1. 2 2
      nicegui/helpers.py
  2. 3 4
      website/search.py

+ 2 - 2
nicegui/helpers.py

@@ -19,11 +19,11 @@ from starlette.middleware.sessions import SessionMiddleware
 from . import background_tasks, globals
 from .storage import RequestTrackingMiddleware
 
-mimetypes.init()
-
 if TYPE_CHECKING:
     from .client import Client
 
+mimetypes.init()
+
 KWONLY_SLOTS = {'kw_only': True, 'slots': True} if sys.version_info >= (3, 10) else {}
 
 

+ 3 - 4
website/search.py

@@ -53,17 +53,16 @@ class Search:
         with self.results:
             for result in await ui.run_javascript(f'return window.fuse.search("{e.value}").slice(0, 50)'):
                 href: str = result['item']['url']
-                with ui.element('q-item').props(f'clickable').on('click', lambda href=href: self.clicked(href)):
+                with ui.element('q-item').props(f'clickable').on('click', lambda href=href: self.open_url(href)):
                     with ui.element('q-item-section'):
                         ui.label(result['item']['title'])
 
-    async def clicked(self, url: str) -> None:
+    async def open_url(self, url: str) -> None:
         await ui.run_javascript(f'''
             const url = "{url}"
             if (url.startsWith("http"))
                 window.open(url, "_blank");
             else
                 window.location.href = url;
-      ''', respond=False)
+        ''', respond=False)
         self.dialog.close()
-        print(url, flush=True)