diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a3a88ba..cd899f8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,19 +4,12 @@
-
-
-
-
-
-
+
+
-
-
-
@@ -73,7 +66,7 @@
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "com.gitee.ui.GiteeSettingsConfigurable",
+ "settings.editor.selected.configurable": "vcs.Git",
"vue.rearranger.settings.migration": "true"
}
}
@@ -188,7 +181,9 @@
-
+
+
+
@@ -198,7 +193,15 @@
1756303135240
-
+
+
+ 1756985736631
+
+
+
+ 1756985736631
+
+
@@ -221,7 +224,8 @@
-
+
+
@@ -229,10 +233,10 @@
-
+
-
+
\ No newline at end of file
diff --git a/Module/FlaskService.py b/Module/FlaskService.py
index d267a95..c464536 100644
--- a/Module/FlaskService.py
+++ b/Module/FlaskService.py
@@ -17,8 +17,7 @@ from Entity.ResultData import ResultData
from Utils.ControlUtils import ControlUtils
from Utils.ThreadManager import ThreadManager
from script.ScriptManager import ScriptManager
-from Entity.Variables import anchorList, addModelToAnchorList
-import Entity.Variables
+from Entity.Variables import anchorList, addModelToAnchorList,prologueList
app = Flask(__name__)
CORS(app)
@@ -278,6 +277,7 @@ def getChatTextInfo():
session = client.session()
xml = session.source()
try:
+ print(xml)
result = AiUtils.extract_messages_from_xml(xml)
print(result)
return ResultData(data=result).toJson()
@@ -318,12 +318,18 @@ def upLoadLogFile():
userId = data.get("userId")
tenantId = data.get("tenantId")
ok = LogManager.upload_all_logs("http://47.79.98.113:8101/api/log/upload", token, userId, tenantId)
+
if ok:
- print(123)
return ResultData(data="日志上传成功").toJson()
else:
return ResultData(data="", msg="日志上传失败").toJson()
+# @app.route("/", methods=['POST'])
+# def upLoadLogFile():
+# datas = request.get_json() # 解析 JSON
+# # 先清空打招呼语
+# prologueList.clear()
+# # 添加新的打招呼语句
+# for data in datas:
+# prologueList.append(data)
-if __name__ == '__main__':
- app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
diff --git a/Utils/AiUtils.py b/Utils/AiUtils.py
index d43a400..1550cf5 100644
--- a/Utils/AiUtils.py
+++ b/Utils/AiUtils.py
@@ -294,109 +294,6 @@ class AiUtils(object):
print(f"btn:{btn}")
return cls.findNumber(btn.label)
- # 获取聊天页面的聊天信息
- # @classmethod
- # def extract_messages_from_xml(cls, xml: str):
- # """
- # 仅返回当前屏幕中“可见的”聊天内容(含时间分隔)
- # """
- # from lxml import etree
- # root = etree.fromstring(xml.encode("utf-8"))
- # items = []
- #
- # # 判断是否是聊天页面
- # is_chat_page = False
- # if root.xpath('//XCUIElementTypeStaticText[contains(@traits, "Header")]'):
- # is_chat_page = True
- # elif root.xpath('//XCUIElementTypeCell//XCUIElementTypeOther[@name or @label]'):
- # is_chat_page = True
- #
- # if not is_chat_page:
- # raise Exception("请先进入聊天页面")
- #
- # # 屏幕宽度
- # app = root.xpath('/XCUIElementTypeApplication')
- #
- # screen_w = cls.parse_float(app[0], 'width', 414.0) if app else 414.0
- #
- # # 找 Table 的可见范围
- # table = root.xpath('//XCUIElementTypeTable')
- # if table:
- # table = table[0]
- # table_top = cls.parse_float(table, 'y', 0.0)
- # table_h = cls.parse_float(table, 'height', 0.0)
- # table_bottom = table_top + table_h
- # else:
- # table_top, table_bottom = 0.0, cls.parse_float(app[0], 'height', 736.0) if app else 736.0
- #
- # def in_view(el) -> bool:
- # """元素在聊天区内并且可见"""
- # if el.get('visible') != 'true':
- # return False
- # y = cls.parse_float(el, 'y', -1e9)
- # h = cls.parse_float(el, 'height', 0.0)
- # by = y + h
- # return not (by <= table_top or y >= table_bottom)
- #
- # # 时间分隔
- # for t in root.xpath('//XCUIElementTypeStaticText[contains(@traits, "Header")]'):
- # if not in_view(t):
- # continue
- # txt = (t.get('label') or t.get('name') or t.get('value') or '').strip()
- # if txt:
- # items.append({'type': 'time', 'text': txt, 'y': cls.parse_float(t, 'y')})
- #
- # # 消息气泡
- # EXCLUDES = {'Heart', 'Lol', 'ThumbsUp', '分享发布内容', '视频贴纸标签页', '双击发送表情'}
- #
- # msg_nodes = table.xpath(
- # './/XCUIElementTypeCell[@visible="true"]'
- # '//XCUIElementTypeOther[@visible="true" and (@name or @label) and not(ancestor::XCUIElementTypeCollectionView)]'
- # ) if table is not None else []
- #
- # for o in msg_nodes:
- # text = (o.get('label') or o.get('name') or '').strip()
- # if not text or text in EXCLUDES:
- # continue
- # if not in_view(o):
- # continue
- #
- # # 找所在 Cell
- # cell = o.getparent()
- # while cell is not None and cell.get('type') != 'XCUIElementTypeCell':
- # cell = cell.getparent()
- #
- # x = cls.parse_float(o, 'x')
- # y = cls.parse_float(o, 'y')
- # w = cls.parse_float(o, 'width')
- # right_edge = x + w
- #
- # direction = None
- # # 头像位置判定
- # if cell is not None:
- # avatar_btns = cell.xpath(
- # './/XCUIElementTypeButton[@visible="true" and (@name="图片头像" or @label="图片头像")]')
- # if avatar_btns:
- # ax = cls.parse_float(avatar_btns[0], 'x')
- # direction = 'in' if ax < (screen_w / 2) else 'out'
- # # 右对齐兜底
- # if direction is None:
- # direction = 'out' if right_edge > (screen_w - 20) else 'in'
- #
- # items.append({'type': 'msg', 'dir': direction, 'text': text, 'y': y})
- #
- # # 排序 & 清理
- # items.sort(key=lambda i: i['y'])
- # for it in items:
- # it.pop('y', None)
- # return items
- #
- # @classmethod
- # def parse_float(cls, el, attr, default=0.0):
- # try:
- # return float(el.get(attr, default))
- # except Exception:
- # return default
@classmethod
def extract_messages_from_xml(cls, xml: str):
@@ -407,15 +304,6 @@ class AiUtils(object):
root = etree.fromstring(xml.encode("utf-8"))
items = []
- # 判断是否是聊天页面
- is_chat_page = False
- if root.xpath('//XCUIElementTypeStaticText[contains(@traits, "Header")]'):
- is_chat_page = True
- elif root.xpath('//XCUIElementTypeCell//XCUIElementTypeOther[@name or @label]'):
- is_chat_page = True
-
- if not is_chat_page:
- raise Exception("请先进入聊天页面")
# 屏幕宽度
app = root.xpath('/XCUIElementTypeApplication')
@@ -571,5 +459,3 @@ class AiUtils(object):
return t
return ""
-
-# AiUtils.getCurrentScreenSource()
diff --git a/Utils/LogManager.py b/Utils/LogManager.py
index 7233acd..afb11f3 100644
--- a/Utils/LogManager.py
+++ b/Utils/LogManager.py
@@ -267,9 +267,9 @@ class LogManager:
print("[upload_all_logs] 日志目录不存在")
return False
- timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
+ timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
filename = f"{timestamp}_logs.zip"
-
+ print(filename)
zip_buf = io.BytesIO()
with zipfile.ZipFile(zip_buf, "w", compression=zipfile.ZIP_DEFLATED) as zf:
for p in log_path.rglob("*"):
diff --git a/tidevice_entry.py b/tidevice_entry.py
new file mode 100644
index 0000000..9d5855b
--- /dev/null
+++ b/tidevice_entry.py
@@ -0,0 +1,45 @@
+# from Utils.Requester import Requester
+#
+#
+# # 获取主播的名称
+# anchor_name = "123"
+#
+# anchorWithSession = {}
+#
+#
+# while True:
+# # 向ai发送信息
+# last_msg_text = input("请输入:")
+#
+#
+# if anchor_name not in anchorWithSession:
+# # 如果是第一次发消息(没有sessionId的情况)
+# response = Requester.chatToAi({"msg": last_msg_text})
+# aiResult = response['result']
+# sessionId = response['session_id']
+#
+# anchorWithSession[anchor_name] = sessionId
+# # 找到输入框,输入ai返回出来的消息
+# print(aiResult)
+#
+# else:
+# # 如果不是第一次发消息(证明存储的有sessionId)
+# sessionId = anchorWithSession[anchor_name]
+# response = Requester.chatToAi({"msg": last_msg_text, "sid": sessionId})
+# aiResult = response['result']
+# print(aiResult)
+import datetime
+
+import wda
+
+udid = "e5ab9d3c548302dca3b1383589ac43eedd41f24e"
+
+client = wda.USBClient(udid)
+session = client.session()
+session.appium_settings({"snapshotMaxDepth": 15})
+
+print(session.source())
+
+
+
+