1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2026-03-23 09:29:44 +08:00

feat: 移除第三方设备播放功能

This commit is contained in:
涵曦
2026-01-05 13:16:16 +08:00
parent b436870dcd
commit d00e8a2cbc
8 changed files with 13 additions and 608 deletions

View File

@@ -14,7 +14,6 @@ from typing import TYPE_CHECKING, Annotated
from urllib.parse import urlparse
import jwt
import socketio
from fastapi import WebSocket, WebSocketDisconnect
if TYPE_CHECKING:
@@ -128,47 +127,6 @@ app = FastAPI(
openapi_url=None,
)
# 创建Socket.IO实例
sio = socketio.AsyncServer(
async_mode="asgi",
cors_allowed_origins="*", # 允许所有跨域请求,生产环境应限制
)
# 将Socket.IO挂载到FastAPI应用
socketio_app = socketio.ASGIApp(
socketio_server=sio, other_asgi_app=app, socketio_path="/socket.io"
)
# Socket.IO事件处理
@sio.event
async def connect(sid, environ, auth):
global onlines
print(f"客户端连接: {sid}")
onlines.update([sid])
await sio.emit("message", {"data": "欢迎连接"}, room=sid)
@sio.event
async def disconnect(sid):
print(f"客户端断开: {sid}")
onlines.discard(sid)
@sio.on("message")
async def custom_event(sid, data):
log.info(f"收到来自 {sid} 的数据: {data}")
await sio.emit("response", {"action": "切歌", "status": data})
@app.post("/thdaction")
async def thdaction(item: Item):
await sio.emit(
"response",
{"action": item.action, "args": item.args, "status": item.args},
)
return onlines
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 允许访问的源