临时提交
This commit is contained in:
@@ -2,14 +2,20 @@ import json
|
||||
import os
|
||||
import socket
|
||||
import threading
|
||||
import warnings
|
||||
from queue import Queue
|
||||
from typing import Any, Dict
|
||||
|
||||
import tidevice
|
||||
import wda
|
||||
from flask import Flask, request
|
||||
from flask_cors import CORS
|
||||
from Entity.ResultData import ResultData
|
||||
from Utils.ControlUtils import ControlUtils
|
||||
from Utils.ThreadManager import ThreadManager
|
||||
from script.ScriptManager import ScriptManager
|
||||
from Entity.AnchorModel import AnchorModel
|
||||
from Entity.Variables import anchorList, addModelToAnchorList
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
@@ -81,21 +87,8 @@ def deviceList():
|
||||
def deviceAppList():
|
||||
param = request.get_json()
|
||||
udid = param["udid"]
|
||||
t = tidevice.Device(udid)
|
||||
|
||||
# 获取已安装的应用列表
|
||||
apps = []
|
||||
for app in t.installation.iter_installed():
|
||||
apps.append({
|
||||
"name": app.get("CFBundleDisplayName", "Unknown"),
|
||||
"bundleId": app.get("CFBundleIdentifier", "Unknown"),
|
||||
"version": app.get("CFBundleShortVersionString", "Unknown"),
|
||||
"path": app.get("Path", "Unknown")
|
||||
})
|
||||
|
||||
# 筛选非系统级应用(过滤掉以 com.apple 开头的系统应用)
|
||||
non_system_apps = [app for app in apps if not app["bundleId"].startswith("com.apple")]
|
||||
return ResultData(data=non_system_apps).toJson()
|
||||
apps = ControlUtils.getDeviceAppList(udid)
|
||||
return ResultData(data=apps).toJson()
|
||||
|
||||
# 打开指定app
|
||||
@app.route('/launchApp', methods=['POST'])
|
||||
@@ -188,12 +181,36 @@ def stopScript():
|
||||
ThreadManager.stop(udid)
|
||||
return ResultData(data="").toJson()
|
||||
|
||||
# AI聊天
|
||||
@app.route('/aiChat', methods=['POST'])
|
||||
def aiChat():
|
||||
body = request.get_json()
|
||||
udid = body.get("udid")
|
||||
|
||||
# 传递主播数据
|
||||
@app.route('/passAnchorData', methods=['POST'])
|
||||
def passAnchorData():
|
||||
data: Dict[str, Any] = request.get_json()
|
||||
# 设备列表
|
||||
idList = data.get("deviceList", [])
|
||||
# 主播列表
|
||||
acList = data.get("anchorList", [])
|
||||
# 是否需要回复
|
||||
needReply = data.get("needReply", False)
|
||||
# 添加主播数据
|
||||
addModelToAnchorList(acList)
|
||||
# 启动线程,执行脚本
|
||||
for udid in idList:
|
||||
manager = ScriptManager()
|
||||
event = threading.Event()
|
||||
# 启动脚本
|
||||
thread = threading.Thread(target=manager.greetNewFollowers, args=(udid, needReply, event))
|
||||
thread.start()
|
||||
# 添加到线程管理
|
||||
ThreadManager.add(udid, thread, event)
|
||||
return ResultData(data="").toJson()
|
||||
|
||||
# 添加临时数据
|
||||
@app.route("/addTempAnchorData", methods=['POST'])
|
||||
def addTempAnchorData():
|
||||
data = request.get_json()
|
||||
addModelToAnchorList(data)
|
||||
return ResultData(data="").toJson()
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
|
||||
|
||||
Reference in New Issue
Block a user