From 1aa9f82d30614fb13f9518fb32dc12d3fdc3c6cb Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 13 Aug 2020 16:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91:=E4=BD=BF=E7=94=A8=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E8=B7=9F=E8=B8=AA=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/ErrorMonitoring.ts | 36 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Common/ErrorMonitoring.ts b/src/Common/ErrorMonitoring.ts index 5f933a3d7..c8b4c957a 100644 --- a/src/Common/ErrorMonitoring.ts +++ b/src/Common/ErrorMonitoring.ts @@ -50,13 +50,19 @@ export async function ReportError(stack: any, msg: string = "未捕获的错误! let userName = localStorage.getItem(StoreageKeys.UserName); let userPhone = localStorage.getItem(StoreageKeys.UserPhone); - await PostData("https://cf.qcad.cc:25100/monitoring", { - stack, - href: window.location.href, - path: window.location.pathname, - user: userName, - msg: msg + "\n" + browserMsg, - phone: userPhone + await fetch("http://cf.qcad.cc:25111/logs/error", { + method: 'POST', + body: JSON.stringify({ + stack, + href: window.location.href, + path: window.location.pathname, + user: userName, + msg: msg + "\n" + browserMsg, + phone: userPhone + }), + headers: { + 'content-type': 'application/json' + }, }); console.log("上报成功"); } @@ -65,19 +71,3 @@ export async function ReportError(stack: any, msg: string = "未捕获的错误! console.log("上报失败", error); } } - -export async function PostData(url: RequestInfo, data: {}) -{ - return fetch(url, { - body: JSON.stringify(data), - cache: 'no-cache', - credentials: 'include', - headers: { - 'content-type': 'application/json' - }, - method: 'POST', - mode: 'cors', - redirect: 'follow', - referrer: 'no-referrer', - }); -}