V1.3.1
This commit is contained in:
@@ -10,49 +10,20 @@ Copyright (c) 2018-2024 by 于小丘Yuerchu, All Rights Reserved.
|
||||
'''
|
||||
|
||||
from nicegui import ui
|
||||
from fastapi import Request
|
||||
from tool import *
|
||||
from ..framework import frame
|
||||
|
||||
|
||||
def create():
|
||||
@ui.page('/admin/about')
|
||||
async def admin_about():
|
||||
|
||||
dark_mode = ui.dark_mode(value=True)
|
||||
|
||||
ui.add_head_html(
|
||||
code="""
|
||||
<style>
|
||||
a:link:not(.browser-window *),
|
||||
a:visited:not(.browser-window *) {
|
||||
color: inherit !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover:not(.browser-window *),
|
||||
a:active:not(.browser-window *) {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.bold-links a:link {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.arrow-links a:link:not(.auto-link)::after {
|
||||
content: "north_east";
|
||||
font-family: "Material Icons";
|
||||
font-weight: 100;
|
||||
vertical-align: -10%;
|
||||
}
|
||||
</style>
|
||||
"""
|
||||
)
|
||||
|
||||
async def admin_about(request: Request):
|
||||
ui.add_head_html("""
|
||||
<style type="text/css" src="/static/css/about.css"></style>
|
||||
<script type="text/javascript" src="/static/js/main.js"></script>
|
||||
""")
|
||||
|
||||
async with frame():
|
||||
async with frame(request=request):
|
||||
|
||||
# 关于 Findreve
|
||||
with ui.tab_panel('about'):
|
||||
|
||||
@@ -11,17 +11,15 @@ Copyright (c) 2018-2024 by 于小丘Yuerchu, All Rights Reserved.
|
||||
|
||||
from nicegui import ui
|
||||
from tool import *
|
||||
from fastapi import Request
|
||||
from ..framework import frame
|
||||
|
||||
|
||||
def create():
|
||||
@ui.page('/admin/auth')
|
||||
async def admin_auth():
|
||||
|
||||
dark_mode = ui.dark_mode(value=True)
|
||||
|
||||
async def admin_auth(request: Request):
|
||||
# Findreve 授权
|
||||
async with frame():
|
||||
async with frame(request=request):
|
||||
|
||||
ui.label('Findreve 授权').classes('text-2xl text-bold')
|
||||
|
||||
|
||||
@@ -9,22 +9,21 @@ Description: Findreve 后台管理 admin
|
||||
Copyright (c) 2018-2024 by 于小丘Yuerchu, All Rights Reserved.
|
||||
'''
|
||||
|
||||
from nicegui import ui
|
||||
from nicegui import ui, app
|
||||
from fastapi import Request
|
||||
from fastapi.responses import RedirectResponse
|
||||
from tool import *
|
||||
from ..framework import frame
|
||||
|
||||
|
||||
def create():
|
||||
@ui.page('/admin')
|
||||
@app.get('/admin')
|
||||
async def jump():
|
||||
ui.navigate.to('/admin/home')
|
||||
|
||||
return RedirectResponse(url='/admin/home')
|
||||
|
||||
@ui.page('/admin/home')
|
||||
async def admin_home():
|
||||
|
||||
dark_mode = ui.dark_mode(value=True)
|
||||
|
||||
async with frame():
|
||||
async def admin_home(request: Request):
|
||||
async with frame(request=request):
|
||||
with ui.tab_panel('main_page'):
|
||||
ui.label('首页配置').classes('text-2xl text-bold')
|
||||
ui.label('暂不支持,请直接修改main_page.py').classes('text-md text-gray-600').classes('w-full')
|
||||
@@ -94,7 +94,7 @@ def create() -> None:
|
||||
|
||||
await ui.context.client.connected()
|
||||
|
||||
async with frame(page='found'):
|
||||
async with frame(page='found', request=request):
|
||||
if key == "" or key == None:
|
||||
ui.navigate.to('/404')
|
||||
return
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from nicegui import ui
|
||||
import asyncio
|
||||
from fastapi import Request
|
||||
from typing import Optional, Literal
|
||||
|
||||
@asynccontextmanager
|
||||
async def frame(
|
||||
page: Literal['admin', 'session', 'found'] = 'admin'
|
||||
request: Request = None,
|
||||
page: Literal['admin', 'session', 'found'] = 'admin',
|
||||
redirect_to: str = None
|
||||
):
|
||||
|
||||
ui.add_head_html("""
|
||||
@@ -15,8 +18,15 @@ async def frame(
|
||||
await ui.context.client.connected()
|
||||
|
||||
is_login = await ui.run_javascript('is_login()', timeout=3)
|
||||
if str(is_login).lower() != 'true' and page != 'session':
|
||||
ui.navigate.to('/login?redirect_to=/admin')
|
||||
if str(is_login).lower() != 'true':
|
||||
if page not in ['session', 'found']:
|
||||
ui.navigate.to(f'/login?redirect_to={request.url.path}')
|
||||
else:
|
||||
if page == 'session':
|
||||
ui.navigate.to(redirect_to)
|
||||
|
||||
if page != 'found':
|
||||
ui.dark_mode(value=True)
|
||||
|
||||
with ui.header() \
|
||||
.classes('items-center py-2 px-5 no-wrap').props('elevated'):
|
||||
@@ -31,7 +41,7 @@ async def frame(
|
||||
|
||||
with ui.left_drawer() as left_drawer:
|
||||
with ui.column(align_items='center').classes('w-full'):
|
||||
ui.image('/static/Findreve.png').classes('w-1/2 mx-auto')
|
||||
ui.image('/static/Findreve.png').classes('w-1/3 mx-auto')
|
||||
ui.label('Findreve').classes('text-2xl text-bold')
|
||||
ui.label("免费版,无需授权").classes('text-sm text-gray-500')
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ Copyright (c) 2018-2024 by 于小丘Yuerchu, All Rights Reserved.
|
||||
from nicegui import ui
|
||||
from typing import Optional
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi import Request
|
||||
from .framework import frame
|
||||
|
||||
def create() -> Optional[RedirectResponse]:
|
||||
@@ -23,9 +22,11 @@ def create() -> Optional[RedirectResponse]:
|
||||
""")
|
||||
|
||||
ui.page_title('登录 Findreve')
|
||||
ui.dark_mode(True)
|
||||
|
||||
async with frame(page='session'):
|
||||
async with frame(page='session', redirect_to=redirect_to):
|
||||
|
||||
await ui.context.client.connected()
|
||||
|
||||
async def login():
|
||||
if username.value == "" or password.value == "":
|
||||
ui.notify('账号或密码不能为空', color='negative')
|
||||
|
||||
@@ -24,22 +24,7 @@ def create() -> None:
|
||||
|
||||
# 添加页面过渡动画
|
||||
ui.add_head_html('''
|
||||
<style>
|
||||
.fade-in {
|
||||
animation: fadeIn 0.8s ease-in-out;
|
||||
}
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
body > div {
|
||||
opacity: 0;
|
||||
animation: fadeIn 0.8s ease-in-out forwards;
|
||||
}
|
||||
.transform {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css" src="/static/css/main_page.css"></style>
|
||||
''')
|
||||
|
||||
with ui.row(align_items='center').classes('w-full items-center justify-center items-stretch mx-auto mx-8 max-w-7xl p-24'):
|
||||
|
||||
Reference in New Issue
Block a user