diff --git a/src/Common/ErrorMonitoring.ts b/src/Common/ErrorMonitoring.ts index c90e15ac7..5adfaaac4 100644 --- a/src/Common/ErrorMonitoring.ts +++ b/src/Common/ErrorMonitoring.ts @@ -11,40 +11,43 @@ export class ErrorMonitoring { reportError(e.reason.stack); }); + } +} - async function reportError(stack: any) - { - try - { - console.log(stack); - await postData("http://192.168.1.251:25100/monitoring", { - stack, - href: window.location.href, - path: window.location.pathname - }); - console.log("上报成功"); - } - catch (error) - { - console.log("上报失败", error); - } - } +export async function reportError(stack: any) +{ + try + { + if (window.location.hostname !== "t.qcad.cc") + return; - function postData(url: RequestInfo, data: {}) - { - return fetch(url, { - body: JSON.stringify(data), - cache: 'no-cache', - credentials: 'same-origin', - headers: { - 'user-agent': 'Mozilla/4.0 MDN Example', - 'content-type': 'application/json' - }, - method: 'POST', - mode: 'cors', - redirect: 'follow', - referrer: 'no-referrer', - }); - } + console.log(stack); + await postData("http://192.168.1.251:25100/monitoring", { + stack, + href: window.location.href, + path: window.location.pathname + }); + console.log("上报成功"); + } + catch (error) + { + console.log("上报失败", error); } } + +function postData(url: RequestInfo, data: {}) +{ + return fetch(url, { + body: JSON.stringify(data), + cache: 'no-cache', + credentials: 'same-origin', + headers: { + 'user-agent': 'Mozilla/4.0 MDN Example', + 'content-type': 'application/json' + }, + method: 'POST', + mode: 'cors', + redirect: 'follow', + referrer: 'no-referrer', + }); +} diff --git a/src/Editor/CommandMachine.ts b/src/Editor/CommandMachine.ts index ea395efc1..4be4ce3c8 100644 --- a/src/Editor/CommandMachine.ts +++ b/src/Editor/CommandMachine.ts @@ -1,7 +1,8 @@ import { app } from '../ApplicationServices/Application'; -import { JigUtils } from './JigUtils'; -import { CommandState } from './CommandState'; import { arrayRemoveOnce } from '../Common/ArrayExt'; +import { reportError } from '../Common/ErrorMonitoring'; +import { CommandState } from './CommandState'; +import { JigUtils } from './JigUtils'; export interface Command { exec: Function;//函数可以返回true,实现放弃命令的任何操作. @@ -40,6 +41,7 @@ class CommandMachine catch (error) { console.error(error.stack); + reportError(error.stack); app.m_Editor.Prompt("抱歉,命令造成了错误,请联系开发人员."); } this.CommandEnd(abort);