20250904-初步功能已完成
This commit is contained in:
@@ -30,6 +30,7 @@ listLock = threading.Lock()
|
||||
|
||||
dataQueue = Queue()
|
||||
|
||||
|
||||
def start_socket_listener():
|
||||
port = int(os.getenv('FLASK_COMM_PORT', 0))
|
||||
LogManager.info(f"Received port from environment: {port}")
|
||||
@@ -85,11 +86,12 @@ def start_socket_listener():
|
||||
listener_thread = threading.Thread(target=start_socket_listener, daemon=True)
|
||||
listener_thread.start()
|
||||
|
||||
|
||||
# 获取设备列表
|
||||
@app.route('/deviceList', methods=['GET'])
|
||||
def deviceList():
|
||||
try:
|
||||
with listLock: # 1. 加锁
|
||||
with listLock: # 1. 加锁
|
||||
# 先一次性把队列全部消费完
|
||||
while not dataQueue.empty():
|
||||
obj = dataQueue.get()
|
||||
@@ -100,14 +102,15 @@ def deviceList():
|
||||
for i in range(len(listData) - 1, -1, -1):
|
||||
d = listData[i]
|
||||
if d.get("deviceId") == obj.get("deviceId") and \
|
||||
d.get("screenPort") == obj.get("screenPort"):
|
||||
d.get("screenPort") == obj.get("screenPort"):
|
||||
listData.pop(i)
|
||||
break # 同一端口同一设备只删一次
|
||||
break # 同一端口同一设备只删一次
|
||||
return ResultData(data=listData.copy()).toJson() # 2. 返回副本
|
||||
except Exception as e:
|
||||
LogManager.error("获取设备列表失败:", e)
|
||||
return ResultData(data=[]).toJson()
|
||||
|
||||
|
||||
# 获取设备应用列表
|
||||
@app.route('/deviceAppList', methods=['POST'])
|
||||
def deviceAppList():
|
||||
@@ -116,6 +119,7 @@ def deviceAppList():
|
||||
apps = ControlUtils.getDeviceAppList(udid)
|
||||
return ResultData(data=apps).toJson()
|
||||
|
||||
|
||||
# 打开指定app
|
||||
@app.route('/launchApp', methods=['POST'])
|
||||
def launchApp():
|
||||
@@ -225,9 +229,6 @@ def stopScript():
|
||||
return ResultData(code=code, data="", msg=msg).toJson()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 关注打招呼
|
||||
@app.route('/passAnchorData', methods=['POST'])
|
||||
def passAnchorData():
|
||||
@@ -259,12 +260,14 @@ def passAnchorData():
|
||||
except Exception as e:
|
||||
LogManager.error(e)
|
||||
|
||||
|
||||
# 获取私信数据
|
||||
@app.route("/getPrologueList", methods=['GET'])
|
||||
def getPrologueList():
|
||||
import Entity.Variables as Variables
|
||||
return ResultData(data=Variables.prologueList).toJson()
|
||||
|
||||
|
||||
# 添加临时数据
|
||||
# 批量追加主播到 JSON 文件
|
||||
@app.route("/addTempAnchorData", methods=['POST'])
|
||||
@@ -295,6 +298,9 @@ def getChatTextInfo():
|
||||
print(result)
|
||||
return ResultData(data=result).toJson()
|
||||
except Exception as e:
|
||||
|
||||
LogManager.error(f"获取屏幕翻译出现错误:{e}", "获取屏幕翻译")
|
||||
|
||||
data = [
|
||||
{
|
||||
'type': 'msg',
|
||||
@@ -336,6 +342,7 @@ def upLoadLogLogs():
|
||||
else:
|
||||
return ResultData(data="", msg="日志上传失败").toJson()
|
||||
|
||||
|
||||
# 获取当前的主播列表数据
|
||||
@app.route("/anchorList", methods=['POST'])
|
||||
def queryAnchorList():
|
||||
@@ -360,6 +367,5 @@ def deleteAnchorWithIds():
|
||||
return ResultData(data={"deleted": deleted}).toJson()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
|
||||
|
||||
Reference in New Issue
Block a user