2022-05-26 15:18:53 +08:00
|
|
|
import {openMobileFileById} from "../editor";
|
2022-08-28 12:41:49 +08:00
|
|
|
import {progressLoading, progressStatus, transactionError} from "../../dialog/processSystem";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
|
|
|
|
export const onMessage = (data: IWebSocketData) => {
|
|
|
|
|
if (data) {
|
|
|
|
|
switch (data.cmd) {
|
|
|
|
|
case"progress":
|
|
|
|
|
progressLoading(data);
|
|
|
|
|
break;
|
|
|
|
|
case"syncing":
|
|
|
|
|
if (document.querySelector("#menuSyncNow")) {
|
|
|
|
|
if (data.code === 0) {
|
|
|
|
|
document.querySelector("#menuSyncNow svg").classList.add("fn__rotate");
|
|
|
|
|
} else {
|
|
|
|
|
document.querySelector("#menuSyncNow svg").classList.remove("fn__rotate");
|
2023-01-19 11:49:31 +08:00
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-19 11:49:31 +08:00
|
|
|
if (data.code !== 0) {
|
|
|
|
|
document.getElementById("transactionTip").classList.add("fn__none")
|
|
|
|
|
}
|
2022-05-26 15:18:53 +08:00
|
|
|
break;
|
|
|
|
|
case "create":
|
|
|
|
|
case "createdailynote":
|
|
|
|
|
openMobileFileById(data.data.id);
|
|
|
|
|
break;
|
|
|
|
|
case"txerr":
|
|
|
|
|
transactionError(data);
|
|
|
|
|
break;
|
2022-08-28 12:41:49 +08:00
|
|
|
case"statusbar":
|
|
|
|
|
progressStatus(data);
|
|
|
|
|
break;
|
2022-05-26 15:18:53 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|