Переглянути джерело

#231 allow running NiceGUI without Tailwind

Falko Schindler 2 роки тому
батько
коміт
f0ef6c507a
4 змінених файлів з 7 додано та 1 видалено
  1. 1 0
      nicegui/client.py
  2. 1 0
      nicegui/globals.py
  3. 3 0
      nicegui/run.py
  4. 2 1
      nicegui/templates/index.html

+ 1 - 0
nicegui/client.py

@@ -80,6 +80,7 @@ class Client:
             'favicon_url': get_favicon_url(self.page, prefix),
             'dark': str(self.page.resolve_dark()),
             'prefix': prefix,
+            'tailwind': globals.tailwind,
             'socket_io_js_extra_headers': globals.socket_io_js_extra_headers,
         }, status_code, {'Cache-Control': 'no-store', 'X-NiceGUI-Content': 'page'})
 

+ 1 - 0
nicegui/globals.py

@@ -35,6 +35,7 @@ favicon: Optional[str]
 dark: Optional[bool]
 binding_refresh_interval: float
 excludes: List[str]
+tailwind: bool
 socket_io_js_extra_headers: Dict = {}
 
 _socket_id: Optional[str] = None

+ 3 - 0
nicegui/run.py

@@ -26,6 +26,7 @@ def run(*,
         uvicorn_reload_includes: str = '*.py',
         uvicorn_reload_excludes: str = '.*, .py[cod], .sw.*, ~*',
         exclude: str = '',
+        tailwind: bool = True,
         ) -> None:
     '''ui.run
 
@@ -45,6 +46,7 @@ def run(*,
     :param uvicorn_reload_excludes: string with comma-separated list of glob-patterns which should be ignored for reload (default: `'.*, .py[cod], .sw.*, ~*'`)
     :param exclude: comma-separated string to exclude elements (with corresponding JavaScript libraries) to save bandwidth
       (possible entries: chart, colors, interactive_image, joystick, keyboard, log, scene, upload, table)
+    :param tailwind: whether to use Tailwind (default: `True`)
     '''
     globals.host = host
     globals.port = port
@@ -54,6 +56,7 @@ def run(*,
     globals.dark = dark
     globals.binding_refresh_interval = binding_refresh_interval
     globals.excludes = [e.strip() for e in exclude.split(',')]
+    globals.tailwind = tailwind
 
     if inspect.stack()[-2].filename.endswith('spawn.py'):
         return

+ 2 - 1
nicegui/templates/index.html

@@ -6,8 +6,9 @@
     <link href="{{ favicon_url }}" rel="shortcut icon" />
     <link href="{{ prefix | safe }}/_nicegui/static/fonts.css" rel="stylesheet" type="text/css" />
     <link href="{{ prefix | safe }}/_nicegui/static/quasar.prod.css" rel="stylesheet" type="text/css" />
+    {% if tailwind %}
     <script src="{{ prefix | safe }}/_nicegui/static/tailwind.min.js"></script>
-    {{ head_html | safe }}
+    {% endif %} {{ head_html | safe }}
   </head>
   <body>
     <script src="{{ prefix | safe }}/_nicegui/static/vue.global.prod.js"></script>