|
@@ -74,3 +74,115 @@ export function createLog(logs) {
|
|
|
window._hmt.push(["_trackEvent", "创建用户日志出错-2"]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+export function createEncryptLog() {
|
|
|
+ const isElectron = typeof nodeRequire != "undefined";
|
|
|
+
|
|
|
+ if (!isElectron) return;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const user = store.state.user;
|
|
|
+ const uuidForEcs = localStorage.getItem("uuidForEcs");
|
|
|
+ if (uuidForEcs) {
|
|
|
+ logger.push("uuidForEcs", uuidForEcs);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (user) {
|
|
|
+ logger.push("userId", user.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ let log = null;
|
|
|
+ try {
|
|
|
+ let lastLogIndex = (localStorage.getItem("lastLogIndex") || 0) - 0;
|
|
|
+ log = window.nodeRequire("electron-log");
|
|
|
+
|
|
|
+ const filePath = log.transports.file.findLogPath();
|
|
|
+ const fs = window.nodeRequire("fs");
|
|
|
+ const content = fs.readFileSync(filePath, "utf-8");
|
|
|
+ const ary = content
|
|
|
+ .toString()
|
|
|
+ .split("\r\n")
|
|
|
+ .join("\n")
|
|
|
+ .split("\n");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (ary.length < lastLogIndex) {
|
|
|
+ lastLogIndex = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ let logLen = 10;
|
|
|
+ const newAry = ary
|
|
|
+ .slice(lastLogIndex, lastLogIndex + logLen)
|
|
|
+ .filter(v => v);
|
|
|
+
|
|
|
+ if (!newAry.length) return;
|
|
|
+ lastLogIndex = lastLogIndex + newAry.length;
|
|
|
+
|
|
|
+ localStorage.setItem("lastLogIndex", lastLogIndex);
|
|
|
+ logger.push("encryptLog", newAry.join("\n"));
|
|
|
+ } catch (error) {
|
|
|
+ console.debug(error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.push("clientDate", moment().format("hh:mm:ss.SSS"));
|
|
|
+ logger.logger();
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ window._hmt.push(["_trackEvent", "创建用户日志出错-3"]);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|