Add some interfaces in backend to send message and progress

This commit is contained in:
LASER-Yi 2021-05-09 02:17:07 +08:00
parent 24cb712ad7
commit 8fcffaf339
1 changed files with 12 additions and 0 deletions

View File

@ -17,3 +17,15 @@ def event_stream(type, action="update", payload=None):
except (ValueError, TypeError): except (ValueError, TypeError):
pass pass
socketio.emit("data", {"type": type, "action": action, "payload": payload}) socketio.emit("data", {"type": type, "action": action, "payload": payload})
def show_message(msg):
event_stream(type="message", payload=msg)
def show_progress(name, percent):
event_stream(type="progress", payload={"name": name, "percent": percent})
def hide_progress(name):
event_stream(type="progress", action="delete", payload={"name": name, "percent": 0})