修复一些问题
This commit is contained in:
@@ -393,9 +393,12 @@ def upLoadLogLogs():
|
||||
# 获取当前的主播列表数据
|
||||
@app.route("/anchorList", methods=['POST'])
|
||||
def queryAnchorList():
|
||||
file_path = "log/acList.json"
|
||||
# 项目根目录(当前文件在 infos 下,回退两层到根目录)
|
||||
root_dir = Path(__file__).resolve().parent.parent
|
||||
file_path = root_dir / "log" / "acList.json"
|
||||
|
||||
data = []
|
||||
if Path(file_path).exists():
|
||||
if file_path.exists():
|
||||
try:
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
@@ -421,14 +424,14 @@ def updateAnchorList():
|
||||
new_status = 1 if state else 0
|
||||
|
||||
# 用工具类解析路径,避免 cwd 影响
|
||||
file_path = AiUtils._resolve_path("Module/log/acList.json")
|
||||
file_path = AiUtils._resolve_path("log/acList.json")
|
||||
|
||||
# 加载 JSON
|
||||
try:
|
||||
doc = json.loads(file_path.read_text(encoding="utf-8-sig"))
|
||||
except Exception as e:
|
||||
LogManager.error(f"[updateAnchorList] 读取失败: {e}")
|
||||
return ResultData(code=500, massage=f"读取失败: {e}").toJson()
|
||||
return ResultData(code=1001, message=f"暂无数据").toJson()
|
||||
|
||||
# 定位 anchorList
|
||||
if isinstance(doc, list):
|
||||
@@ -438,7 +441,7 @@ def updateAnchorList():
|
||||
acList = doc["anchorList"]
|
||||
wrapper = doc
|
||||
else:
|
||||
return ResultData(code=500, massage="文件格式不合法").toJson()
|
||||
return ResultData(code=500, message="文件格式不合法").toJson()
|
||||
|
||||
# 遍历并更新
|
||||
updated = 0
|
||||
@@ -454,19 +457,12 @@ def updateAnchorList():
|
||||
file_path.write_text(json.dumps(to_write, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
except Exception as e:
|
||||
LogManager.error(f"[updateAnchorList] 写入失败: {e}")
|
||||
return ResultData(code=500, massage=f"写入失败: {e}").toJson()
|
||||
return ResultData(code=500, message=f"写入失败: {e}").toJson()
|
||||
|
||||
if updated:
|
||||
return ResultData(data=updated, massage=f"已更新 {updated} 条记录").toJson()
|
||||
return ResultData(data=updated, message=f"已更新 {updated} 条记录").toJson()
|
||||
else:
|
||||
return ResultData(data=0, massage="未找到符合条件的记录").toJson()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ResultData(data=0, message="未找到符合条件的记录").toJson()
|
||||
|
||||
|
||||
# 删除主播
|
||||
@@ -538,6 +534,12 @@ def delete_last_message():
|
||||
return ResultData(data=updated_count, message="修改成功").toJson()
|
||||
return ResultData(data=updated_count, message="修改失败").toJson()
|
||||
|
||||
#的停止所有任务
|
||||
@app.route("/stopAllTask", methods=['POST'])
|
||||
def stopAllTask():
|
||||
idList = request.get_json()
|
||||
code, data , msg = ThreadManager.batch_stop(idList)
|
||||
return ResultData(code, data, msg).toJson()
|
||||
|
||||
# @app.route("/killWda", methods=['POST'])
|
||||
# def killWda():
|
||||
|
||||
Reference in New Issue
Block a user