Skip to content

Commit 566afbf

Browse files
committed
修复history为0kb时的json读取失败导致的闪退问题
1 parent ed0346c commit 566afbf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

window_monitor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ def get_json(json_filename):
121121
# 检查json文件有没有
122122
if os.path.exists(json_filename):
123123
with open(json_filename, "r", encoding="utf8") as f:
124-
json_obj = json.load(f)
124+
json_text = f.read()
125+
if json_text != "":
126+
json_obj = json.loads(json_text)
127+
else:
128+
print(f"{json_filename}文件为空,get_json读取为[]")
129+
json_obj = []
125130
return json_obj
126131
else:
127132
return []

0 commit comments

Comments
 (0)