This commit is contained in:
2025-02-10 14:27:45 +08:00
parent bf378bdfbd
commit 4c2898d9a0
8 changed files with 94 additions and 40 deletions

16
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,16 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "启动 Findreve",
"type": "debugpy",
"request": "launch",
"program": "main.py",
"console": "integratedTerminal"
}
]
}

7
CHANGELOG.md Normal file
View File

@@ -0,0 +1,7 @@
# Findreve 更新日志
## V1.1.2 2025-02-10
- 新增 VSCode快速启动与调试
- 修复 非Pro版本显示未授权
- 修复 设置物品为丢失时不添加留言则物品页异常

View File

@@ -24,6 +24,7 @@ import json
import requests
from tool import *
from fastapi.responses import RedirectResponse
from datetime import datetime
def create():
@@ -47,18 +48,14 @@ def create():
siteDomain = request.base_url.hostname
with ui.left_drawer() as left_drawer:
ui.image('https://bing.img.run/1366x768.php').classes('w-full')
with ui.column().classes('w-full'):
ui.image('/static/Findreve.png').classes('w-1/2 mx-auto')
with ui.row(align_items='center').classes('w-full'):
ui.label('Findreve').classes('text-2xl text-bold')
ui.chip('Pro').classes('text-xs -left-3').props('floating outline')
if siteDomain == "127.0.0.1" or siteDomain == "localhost":
ui.label("本地模式无需授权").classes('text-gray-600 -mt-3')
elif not await model.Database().get_setting('License'):
ui.label("未授权,请立即前往授权").classes('text-red-600 -mt-3')
elif await model.Database().get_setting('License'):
ui.label("正版授权,希望是一万年").classes('text-green-600 -mt-3')
else:
ui.label("授权异常,请联系作者").classes('text-red-600 -mt-3')
ui.label("免费版,无需授权").classes('text-red-600 -mt-3')
ui.button('首页 & 信息', icon='fingerprint', on_click=lambda: tabs.set_value('main_page')) \
.classes('w-full').props('flat no-caps')
@@ -198,10 +195,10 @@ def create():
# 获取选中物品
object_id = object_table.selected[0]['id']
await model.Database().update_object(id=object_id, status='lost')
await model.Database().update_object(id=object_id, lost_at=datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
# 如果设置了留言,则更新留言
if lostReason.value != "":
await model.Database().update_object(id=object_id, context=lostReason.value)
await model.Database().update_object(id=object_id, lost_at=datetime.now())
except Exception as e:
ui.notify(str(e), color='negative')
else:
@@ -373,9 +370,3 @@ def create():
# 关于 Findreve
with ui.tab_panel('about'):
ui.label('关于 Findreve')
if __name__ not in {"__main__", "__mp_main__"}:
raise Exception('不支持单测模式请从main.py启动')

View File

@@ -2,7 +2,7 @@
Author: 于小丘 海枫
Date: 2024-10-02 15:23:34
LastEditors: Yuerchu admin@yuxiaoqiu.cn
LastEditTime: 2024-11-29 20:35:19
LastEditTime: 2024-11-29 20:03:58
FilePath: /Findreve/found.py
Description: Findreve 物品详情页 found
@@ -16,7 +16,7 @@ from tool import format_phone
def create() -> None:
@ui.page('/found')
async def found_page(key: str = "") -> None:
async def found_page(request: Request, key: str = "") -> None:
with ui.header() \
.classes('items-center duration-300 py-2 px-5 no-wrap') \
.style('box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1)'):
@@ -51,6 +51,63 @@ def create() -> None:
ui.label('请输入正确的序列号').classes('text-md w-full text-center')
ui.label('Please enter the correct serial number').classes('text-md w-full text-center')
elif object_data[4] == 'ok':
# 物品存在, 但未标记为丢失
with ui.card().classes('absolute-center w-3/4 h-3/4'):
# 添加标题
ui.button(icon=object_data[3]).props('outline round').classes('mx-auto w-auto shadow-sm w-fill max-md:hidden')
ui.label('关于此 '+ object_data[2]).classes('text-h5 w-full text-center')
ui.label('About this '+ object_data[2]).classes('text-xs w-full text-center text-gray-500 -mt-3')
ui.label('序列号(Serial number)'+ object_data[1]).classes('text-md w-full text-center')
ui.label('物主(Owner)'+ format_phone(object_data[5], private=True)).classes('text-md w-full text-center')
ui.space()
ui.label('此物品尚未标记为丢失状态。如果你意外捡到了此物品,请尽快联系物主。').classes('text-md w-full text-center')
ui.label('This item has not been marked as lost. If you accidentally picked it up, please contact the owner as soon as possible. ').classes('text-xs w-full text-center text-gray-500 -mt-3')
ui.button('返回首页',
on_click=lambda: ui.navigate.to('/')) \
.classes('items-center w-full').props('rounded')
elif object_data[4] == 'lost':
# 物品存在, 且标记为丢失
with ui.card().classes('absolute-center w-3/4 h-3/4'):
# 添加标题
ui.button(icon=object_data[3], color='red').props('outline round').classes('mx-auto w-auto shadow-sm w-fill max-md:hidden')
with ui.label('关于此 '+ object_data[2]).classes('text-h5 w-full text-center'):
ui.badge('已被标记为丢失 Already lost', color='red').classes('text-lg -right-10').props('floating')
ui.label('About this '+ object_data[2]).classes('text-xs w-full text-center text-gray-500 -mt-3')
ui.label('序列号(Serial number)'+ object_data[1]).classes('text-md w-full text-center -mt-1')
ui.label('物主(Owner)'+ format_phone(object_data[5], private=False)).classes('text-md w-full text-center -mt-3')
ui.label('丢失时间(Lost time)'+ object_data[9]).classes('text-md w-full text-center -mt-3')
ui.space()
try:
ui.label('物主留言(Owner message)'+ object_data[6]) \
.classes('text-md w-full text-center')
except: pass
ui.space()
ui.label('此物品已被物主标记为丢失。您可以通过上面的电话号码来联系物主。').classes('text-md w-full text-center')
ui.label('This item has been marked as lost by the owner. You can contact the owner through the phone number above.').classes('text-xs w-full text-center text-gray-500 -mt-3')
ui.button('联系物主',
on_click=lambda: ui.navigate.to('tel:' + object_data[5])) \
.classes('items-center w-full').props('rounded')
await db.update_object(id=object_data[0], find_ip=str(request.client.host))
else:
# 物品存在, 但未标记为丢失
@@ -67,18 +124,10 @@ def create() -> None:
ui.space()
ui.label('如果你意外捡到了物品,请尽快联系物主。').classes('text-md w-full text-center')
ui.label('If you accidentally picked it up, please contact the owner as soon as possible. ').classes('text-xs w-full text-center text-gray-500 -mt-3')
ui.button('返回首页',
on_click=lambda: ui.navigate.to('/')) \
.classes('items-center w-full').props('rounded')
ui.label('此物品状态信息已丢失。如果您捡到了这个物品,请尽快联系物主。如果你是物主,请修改物品信息状态。').classes('text-md w-full text-center')
ui.label('The item status information has been lost. If you have found this item, please contact the owner as soon as possible. If you are the owner, please modify the item status information.').classes('text-xs w-full text-center text-gray-500 -mt-3')
loading.close()
loading.clear()
return
if __name__ not in {"__main__", "__mp_main__"}:
raise Exception('不支持单测模式请从main.py启动')
return

View File

@@ -54,7 +54,7 @@ def create() -> Optional[RedirectResponse]:
.style('box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1)'):
ui.button(icon='menu').props('flat color=white round')
appBar_appName = ui.button(text="HeyPress" if not unitTest else 'HeyPress 单测模式').classes('text-lg').props('flat color=white no-caps')
appBar_appName = ui.button(text="HeyPress").classes('text-lg').props('flat color=white no-caps')
# 创建一个绝对中心的登录卡片
with ui.card().classes('absolute-center round-lg').style('width: 70%; max-width: 500px'):
@@ -69,7 +69,3 @@ def create() -> Optional[RedirectResponse]:
# 按钮布局
ui.button('登录', on_click=lambda: login()).classes('items-center w-full').props('rounded')
if __name__ not in {"__main__", "__mp_main__"}:
raise Exception('不支持单测模式请从main.py启动')

View File

@@ -70,6 +70,9 @@ class AuthMiddleware(BaseHTTPMiddleware):
# 添加中间件 Add middleware
app.add_middleware(AuthMiddleware)
# 添加静态文件目录
app.add_static_files(url_path='/static', local_directory='static')
# 启动函数 Startup function
def startup():
asyncio.run(model.Database().init_db())

View File

@@ -148,8 +148,3 @@ def create() -> None:
ui.space()
ui.button(icon='open_in_new', on_click=lambda: (ui.navigate.to('https://music.163.com/#/song?id=1863630345'))).props('flat fab-mini')
ui.label('耗时6个月完成的年度纯音乐').classes('text-sm -mt-3')
if __name__ not in {"__main__", "__mp_main__"}:
raise Exception('不支持单测模式请从main.py启动')

View File

@@ -38,6 +38,3 @@ def create() -> None:
ui.button('返回首页',
on_click=lambda: ui.navigate.to('/')) \
.classes('items-center w-full').props('rounded')
if __name__ not in {"__main__", "__mp_main__"}:
raise Exception('不支持单测模式请从main.py启动')