Browse Source

崩溃上报

gaoshuaixing 4 years ago
parent
commit
986b9c5331
4 changed files with 29 additions and 8 deletions
  1. 8 0
      electron/config.js
  2. 8 8
      electron/lib/awaken.js
  3. 9 0
      electron/lib/crashReport.js
  4. 4 0
      electron/setup.js

+ 8 - 0
electron/config.js

@@ -63,6 +63,14 @@ const config = {
   awakeProtocol: {
     protocol: 'electron-egg', // 自定义协议名(默认你的应用名称-英文)
     args: []
+  },
+  crashReport: {
+    submitURL: "",
+    productName: "", 
+    rateLimit: false,
+    uploadToServer: false, 
+    ignoreSystemCrashHandler: true,
+    compress: false
   }
 }
 

+ 8 - 8
electron/lib/awaken.js

@@ -19,14 +19,14 @@ exports.setup = function () {
 	handleArgv(process.argv);
 
 	app.on('second-instance', (event, argv) => {
-			if (process.platform === 'win32') {
-					handleArgv(argv)
-			}
+		if (process.platform === 'win32') {
+			handleArgv(argv)
+		}
 	})
 
 	// 仅用于macOS
 	app.on('open-url', (event, urlStr) => {
-			handleUrl(urlStr)
+		handleUrl(urlStr)
 	})
 
 	// 参数处理
@@ -44,10 +44,10 @@ exports.setup = function () {
 		}
 		const {hostname, pathname, search} = new URL(awakeUrlStr);
 		awakeUrlInfo = {
-				urlStr: awakeUrlStr,
-				urlHost: hostname,
-				urlPath: pathname,
-				urlParams: search && search.slice(1)
+			urlStr: awakeUrlStr,
+			urlHost: hostname,
+			urlPath: pathname,
+			urlParams: search && search.slice(1)
 		}
 		eLogger.info('[awaken] [handleUrl] awakeUrlInfo:', awakeUrlInfo);
 	}

+ 9 - 0
electron/lib/crashReport.js

@@ -0,0 +1,9 @@
+'use strict';
+
+const { crashReporter } = require('electron');
+const config = require('../config');
+
+exports.setup = function () {
+	const options = config.get('crashReport');
+    crashReporter.start(options);
+}

+ 4 - 0
electron/setup.js

@@ -6,6 +6,7 @@ const is = require('electron-is');
 const api = require('./lib/api');
 const ipc = require('./ipc');
 const eLogger = require('./lib/eLogger');
+const crash = require('./lib/crashReport');
 
 module.exports = () => {
   // 存储模块
@@ -22,6 +23,9 @@ module.exports = () => {
 
   // ipc模块
   ipc.setup();
+
+  // 崩溃上报
+  crash.setup();
 }
 
 function loadUpdate () {