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

Allow all page parameters

Rodja Trappe 2 роки тому
батько
коміт
bac537843a

+ 5 - 5
examples/modularization/example_c.py

@@ -8,13 +8,13 @@ router = APIRouter(prefix='/c')
 @router.page('/')
 @router.page('/')
 def example_page():
 def example_page():
     with theme.frame('- Example C -'):
     with theme.frame('- Example C -'):
-        with ui.column().classes('items-center'):
-            ui.label('Example C').classes('text-h4 text-grey-8')
-            for i in range(1, 4):
-                ui.link(f'Item {i}', f'/c/items/{i}').classes('text-xl text-grey-8')
+        ui.label('Example C').classes('text-h4 text-grey-8')
+        for i in range(1, 4):
+            ui.link(f'Item {i}', f'/c/items/{i}').classes('text-xl text-grey-8')
 
 
 
 
-@router.page('/items/{id}')
+@router.page('/items/{id}', dark=True)
 def item(id: str):
 def item(id: str):
     with theme.frame(f'- Example C{id} -'):
     with theme.frame(f'- Example C{id} -'):
         ui.label(f'Item  #{id}').classes('text-h4 text-grey-8')
         ui.label(f'Item  #{id}').classes('text-h4 text-grey-8')
+        ui.link('go back', router.prefix).classes('text-xl text-grey-8')

+ 1 - 1
examples/modularization/theme.py

@@ -14,5 +14,5 @@ def frame(navtitle: str):
         ui.label(navtitle)
         ui.label(navtitle)
         with ui.row():
         with ui.row():
             menu()
             menu()
-    with ui.row().classes('absolute-center'):
+    with ui.column().classes('absolute-center items-center'):
         yield
         yield

+ 2 - 2
nicegui/api_router.py

@@ -7,5 +7,5 @@ from .page import page as ui_page
 
 
 class APIRouter(fastapi.APIRouter):
 class APIRouter(fastapi.APIRouter):
 
 
-    def page(self, func: Callable) -> Callable:
-        return ui_page(func, api_router=self)
+    def page(self, *args, **kwargs) -> Callable:
+        return ui_page(*args, api_router=self, **kwargs)