diff --git a/src/Add-on/Fillet.ts b/src/Add-on/Fillet.ts index 6acf05d24..944bf653e 100644 --- a/src/Add-on/Fillet.ts +++ b/src/Add-on/Fillet.ts @@ -1,11 +1,9 @@ import { end } from 'xaop'; import { app } from '../ApplicationServices/Application'; -import { ReportError } from '../Common/ErrorMonitoring'; import { safeEval } from '../Common/eval'; import { KeyWord } from '../Common/InputState'; import { KeyCode } from '../Common/KeyEnum'; import { FixedNotZero } from '../Common/Utils'; -import { CADFiler } from '../DatabaseServices/CADFiler'; import { Board } from '../DatabaseServices/Entity/Board'; import { Curve } from '../DatabaseServices/Entity/Curve'; import { Polyline } from '../DatabaseServices/Entity/Polyline'; @@ -67,27 +65,15 @@ export class CommandFillet implements Command res2.Entity.UpdateJigMaterial(); lastCu = res2.Entity as Curve; - try + let fres = this.m_FilletUtils.Fillet(enRes1, res2); + if (fres) { - let fres = this.m_FilletUtils.Fillet(enRes1, res2); - if (fres) - { - if (fres.arc) - JigUtils.Draw(fres.arc); - if (fres.cu1) - JigUtils.Draw(fres.cu1); - if (fres.cu2) - JigUtils.Draw(fres.cu2); - } - } - catch (error) - { - let f = new CADFiler; - f.WriteObject(enRes1.Entity); - f.Write(enRes1.Point.toArray()); - f.WriteObject(enRes2.Entity); - f.Write(enRes2.Point.toArray()); - ReportError(f.ToString(), "倒角失败"); + if (fres.arc) + JigUtils.Draw(fres.arc); + if (fres.cu1) + JigUtils.Draw(fres.cu1); + if (fres.cu2) + JigUtils.Draw(fres.cu2); } app.Editor.UpdateScreen(); diff --git a/src/Add-on/Save.ts b/src/Add-on/Save.ts index a7d39c85b..2ccb604be 100644 --- a/src/Add-on/Save.ts +++ b/src/Add-on/Save.ts @@ -233,14 +233,14 @@ export class SaveAsBinary implements Command } //有时候打开的图纸我们无法撤销,这是预期内的,因为我们备份的文件是PU过的,此时我们的历史记录尝试去还原这个操作的时候就会出错 -function UploadFileHistory(file: any) +export function UploadFileHistory(file: any, historyCount = 3) { let fileServer = FileServer.GetInstance() as FileServer; let fileId = fileServer.m_CurFileId; let userName = localStorage.getItem(StoreageKeys.UserName); //记录历史记录 - let hisStart = app.Database.hm.curIndex - 3 + 1;//前n条历史记录 + let hisStart = app.Database.hm.curIndex - historyCount + 1;//前n条历史记录 let hisIndex = app.Database.hm.curIndex; //修正当前开始位置 if (hisStart < 0) @@ -248,7 +248,7 @@ function UploadFileHistory(file: any) else hisIndex -= hisStart; - let hisEnd = Math.min(app.Database.hm.historyRecord.length, app.Database.hm.curIndex + 3 + 1);//后n条历史记录 + let hisEnd = Math.min(app.Database.hm.historyRecord.length, app.Database.hm.curIndex + historyCount + 1);//后n条历史记录 let hisf = new CADFiler(); //参考HistoryManager的序列化 diff --git a/src/Common/ErrorMonitoring.ts b/src/Common/ErrorMonitoring.ts index 1ee497d74..a13fd38af 100644 --- a/src/Common/ErrorMonitoring.ts +++ b/src/Common/ErrorMonitoring.ts @@ -1,4 +1,7 @@ +import { UploadFileHistory } from "../Add-on/Save"; +import { app } from "../ApplicationServices/Application"; import { FileServer } from "../DatabaseServices/FileServer"; +import { deflate } from "./SerializeMaterial"; import { StoreageKeys } from "./StoreageKeys"; const { detect } = require('detect-browser'); @@ -70,10 +73,34 @@ export async function ReportError(stack: any, msg: string = "未捕获的错误! 'content-type': 'application/json' }, }); + + //将图纸上传到备份文件 + // if (CURRENT_HOST === "https://chenfeng.tech:7779") + ReportFile(); + console.log("上报成功"); } catch (error) { console.log("上报失败", error); } + + function ReportFile() + { + //备份,清理 + let hrBak = app.Database.hm.historyRecord; + let hrIndex = app.Database.hm.curIndex; + app.Database.hm.historyRecord = []; + app.Database.hm.curIndex = -1; + + let fileData = app.FileOut().Data; + + //还原 + app.Database.hm.historyRecord = hrBak; + app.Database.hm.curIndex = hrIndex; + + let file = JSON.stringify(fileData); + file = deflate(file); + UploadFileHistory(file, 50); + } }