feat: 增加设置页和托盘,登录后关闭窗口留在托盘

This commit is contained in:
2026-10-26 08:28:16 +08:00
parent e78b8897fc
commit 331e316fd9
16 changed files with 501 additions and 52 deletions
+24 -1
View File
@@ -10,7 +10,7 @@ import uuid
from fastapi import APIRouter, HTTPException
from app.platform.client import NqiError, needs_captcha
from app.platform.sessions import available_accounts, remember_account, resume
from app.platform.sessions import available_accounts, clear_accounts, forget_account, list_local_accounts, remember_account, resume
from app.shared.state import state
logger = logging.getLogger("nqi.auth")
@@ -166,6 +166,29 @@ async def saved() -> dict:
return {"accounts": await available_accounts()}
@router.get("/accounts")
async def accounts() -> dict:
state.require_client()
return {"accounts": list_local_accounts()}
@router.delete("/accounts/{login_id}")
async def remove_account(login_id: str) -> dict:
state.require_client()
await forget_account(login_id)
return {"accounts": list_local_accounts()}
@router.delete("/accounts")
async def remove_accounts() -> dict:
state.require_client()
try:
await clear_accounts()
except NqiError as exc:
raise _bad(str(exc)) from exc
return {"accounts": []}
@router.post("/resume")
async def resume_saved(body: dict) -> dict:
login_id = str(body.get("loginId") or "").strip()