diff --git a/AIProofread/AIProofread.csproj b/AIProofread/AIProofread.csproj index 46ddc81..e08abca 100644 --- a/AIProofread/AIProofread.csproj +++ b/AIProofread/AIProofread.csproj @@ -558,6 +558,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -585,6 +588,9 @@ AnyCPU 7.3 + + favicon.ico + diff --git a/AIProofread/Bridge.cs b/AIProofread/Bridge.cs index eb585cf..0449052 100644 --- a/AIProofread/Bridge.cs +++ b/AIProofread/Bridge.cs @@ -7,6 +7,7 @@ using Microsoft.Office.Tools.Word; using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.WinForms; using Newtonsoft.Json; +using NPOI.SS.Formula; using NPOI.XSSF.UserModel; using NPOI.XWPF.UserModel; using Org.BouncyCastle.Asn1.Crmf; @@ -377,6 +378,22 @@ namespace AIProofread return Tools.GetJSONString(data); } + public string GetDocumentInfo(int documentId) + { + Dictionary data = new Dictionary(); + var documentInfo = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument; + var doc = documentInfo.CurrentDocument; + data.Add("code", 0); + data.Add("message", "success"); + data.Add("name", doc.Name); + //data.Add("documentId", Globals.ThisAddIn.ActiveDocument.Id); + data.Add("fullName", doc.FullName); + data.Add("documentId", GeIdBytDocument(doc)); + data.Add("wordsCount", doc.Words.Count); + data.Add("charactersCount", doc.Characters.Count); + return Tools.GetJSONString(data); + } + /// /// 根据位置获取文档区域文本 /// @@ -514,11 +531,21 @@ namespace AIProofread public void ClearCurrentDocumentMarks() => Globals.ThisAddIn.ActiveDocument?.ClearAllProofreadMark(); public void removeBookmark(string markId) => DocumentUtil.RemoveBookmark(markId); + /// + /// 获取设备ID + /// + /// public string GetDeviceId() { return Config.DeviceId; } + /// + /// 设置帮助文档地址 + /// + /// + public void SetHelpUrl(string url) => Config.USER_MANUAL_URL = url; + public string getAllBookmark() { return ToJSON(DocumentUtil.GetAllBookmark()); @@ -715,11 +742,11 @@ namespace AIProofread /// 导出勘误表 /// /// - public string ExportProofreadResult() + public string ExportProofreadResult(string modelType) { try { - Globals.ThisAddIn.ActiveDocument.ExportResult(); + Globals.ThisAddIn.ActiveDocument.ExportResult(modelType); return BridgeResult.Success(); } catch (Exception ex) diff --git a/AIProofread/Config.cs b/AIProofread/Config.cs index 6013db3..d4a1ff1 100644 --- a/AIProofread/Config.cs +++ b/AIProofread/Config.cs @@ -12,12 +12,12 @@ namespace AIProofread public class Config { public static readonly string APP_NAME = "AI校对王"; - public static readonly string APP_VERSION = "2.2.0"; + public static readonly string APP_VERSION = "2.2.1"; public static bool IS_WPS = false; public static bool UpgradeForcedNotice = false; public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory; public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json"; - public static readonly string USER_MANUAL_URL = "https://doc.weixin.qq.com/doc/w3_AMYAMAaTAKQFkUi5WkYT1OPSXFD17?scode=ACQARAe_AAsF7LbNrM"; + public static string USER_MANUAL_URL = "https://aiprhelp.guomai.cn/"; /// /// 文本背景色 /// @@ -31,7 +31,7 @@ namespace AIProofread public static bool RUN_IN_DEBUG = true; public static AppEnvironment APP_ENV = AppEnvironment.Dev; #else - public static string WEB_PATH = "http://gm2-plugin.zverse.group/"; // gm-plugin.gachafun.com pre-gm-plugin.gachafun.com + public static string WEB_PATH = "https://gm-plugin.gachafun.com/"; // gm-plugin.gachafun.com pre-gm-plugin.gachafun.com public static bool RUN_IN_DEBUG = false; public static AppEnvironment APP_ENV = AppEnvironment.Prod; #endif diff --git a/AIProofread/Controls/FormLogin.cs b/AIProofread/Controls/FormLogin.cs index 803d46e..2d003bd 100644 --- a/AIProofread/Controls/FormLogin.cs +++ b/AIProofread/Controls/FormLogin.cs @@ -31,7 +31,8 @@ namespace AIProofread.Controls private void FormLogin_Load(object sender, EventArgs e) { //this.web.Source = new Uri(Config.WebPath("#login")); - InitWebView(web, Config.WebPath("login?action=" + this.action), "login"); + var r = new FormLogin(); + InitWebView(web, Config.WebPath("login?action=" + this.action + "&version=" + Config.APP_VERSION + "&t=" + DateTime.Now.Ticks), "login"); } diff --git a/AIProofread/Model/DocumentInfo.cs b/AIProofread/Model/DocumentInfo.cs index 618cfcf..14d5e56 100644 --- a/AIProofread/Model/DocumentInfo.cs +++ b/AIProofread/Model/DocumentInfo.cs @@ -211,6 +211,7 @@ namespace AIProofread.Model { try { + if(TaskPane.Control.IsDisposed) return; ProofreadMainControl control = (ProofreadMainControl)TaskPane.Control; control.ResetWeb(); @@ -903,11 +904,11 @@ namespace AIProofread.Model } } - public void ExportResult() + public void ExportResult(string modelType) { TaskPane.Control.BeginInvoke(new Action(() => { - DocumentUtil.ExportProofreadResult(); + DocumentUtil.ExportProofreadResult(modelType); })); } diff --git a/AIProofread/Model/ExportDataItem.cs b/AIProofread/Model/ExportDataItem.cs index fd74d96..df15677 100644 --- a/AIProofread/Model/ExportDataItem.cs +++ b/AIProofread/Model/ExportDataItem.cs @@ -1,4 +1,5 @@ using Microsoft.Office.Interop.Word; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; @@ -32,21 +33,24 @@ namespace AIProofread.Model return sentence; } // 截取中间位置 - var middlePosition = MAX_WORD_LENGTH / 2; - var cutStart = item.content.Start - middlePosition; - // 越界了 - if(cutStart < 0) + try { - cutStart = 0; - } - var originText = sentence.Substring(cutStart, MAX_WORD_LENGTH); - Debug.WriteLine($"{cutStart} {originText}"); - if (!isInsert) - { - item.content.Start = item.content.Start - cutStart; - item.content.End = item.content.End - cutStart; - return originText; + var middlePosition = MAX_WORD_LENGTH / 2; + var cutStart = item.content.Start - middlePosition; + // 越界了 + if (cutStart < 0) + { + cutStart = 0; + } + var originText = sentence.Substring(cutStart, Math.Min(sentence.Length, MAX_WORD_LENGTH)); + if (!isInsert) + { + item.content.Start = item.content.Start - cutStart; + item.content.End = item.content.End - cutStart; + return originText; + } } + catch (Exception ex) { } var range = item.mark.Range; // 获取range所在句子 diff --git a/AIProofread/Properties/AssemblyInfo.cs b/AIProofread/Properties/AssemblyInfo.cs index ceed13f..a31bd9c 100644 --- a/AIProofread/Properties/AssemblyInfo.cs +++ b/AIProofread/Properties/AssemblyInfo.cs @@ -7,11 +7,11 @@ using System.Security; // 控制。更改这些特性值可修改 // 与程序集关联的信息。 [assembly: AssemblyTitle("AI校对王")] -[assembly: AssemblyDescription("AI校对王 2.1.2")] +[assembly: AssemblyDescription("AI校对王 2.2.1")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("果麦文化")] -[assembly: AssemblyProduct("AI校对王 2.1.2")] -[assembly: AssemblyCopyright("Copyright © GuoMai 2024")] +[assembly: AssemblyCompany("果麦文化传媒股份有限公司")] +[assembly: AssemblyProduct("AI校对王 2.2.1")] +[assembly: AssemblyCopyright("Copyright © 果麦文化传媒股份有限公司 2025")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -34,5 +34,5 @@ using System.Security; // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0")] -[assembly: AssemblyFileVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.2.1.0")] diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs index 2416803..e6263a9 100644 --- a/AIProofread/ThisAddIn.cs +++ b/AIProofread/ThisAddIn.cs @@ -92,9 +92,9 @@ namespace AIProofread formCommonsenseDetection = null; } - private void ProcessApplicationException(object sender,UnhandledExceptionEventArgs e) + private void ProcessApplicationException(object sender, UnhandledExceptionEventArgs e) { - Logger.Log("UnhandledException",e.ExceptionObject as Exception); + Logger.Log("UnhandledException", e.ExceptionObject as Exception); } private void ProcessApplicationFormException(object sender, System.Threading.ThreadExceptionEventArgs e) @@ -167,15 +167,15 @@ namespace AIProofread } }); } - + public void CheckDocumentClosed(object sender, System.Timers.ElapsedEventArgs e) { var existsList = new List(); - //Logger.Log("检测文档是否关闭 ..."); + Logger.Log("检测文档是否关闭 ..."); try { - if (documentList.Count == 0 || CurrentWordApplication.Documents.Count == documentList.Count) return; + if (documentList.Count == 0) return; existsList.Clear(); @@ -184,12 +184,32 @@ namespace AIProofread existsList.Add(item.FullName); } // 检测文档是否关闭 - foreach (var item in documentList.documentList) + for (int i = documentList.documentList.Count - 1; i >= 0; i--) { + var item = documentList.documentList[i]; if (!existsList.Contains(item.fileName)) { Logger.Log("检测到文档关闭,已移除:" + item.fileName); - documentList.Remove(item); + try + { + item.RunInMainThread(() => + { + item.Dispose(); + }); + } + catch (Exception ext) + { + Logger.Log(ext); + } + + try + { + documentList.Remove(item); + } + catch (Exception ext) + { + Logger.Log(ext); + } } } } @@ -320,6 +340,7 @@ namespace AIProofread // 设置当前文档 ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument); ActiveDocument.CheckBtnStatus(); + CheckDocumentClosed(null,null); Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName); } @@ -378,6 +399,11 @@ namespace AIProofread /// private void Application_DocumentBeforeClose(Document currentDoc, ref bool Cancel) { + var doc = documentList.Get(currentDoc); + if (doc != null) + { + doc.HidePane(); + } Logger.Log("DocumentBeforeClose", currentDoc.FullName); //if (allMarks.ContainsKey(currentDoc)) //{ @@ -531,7 +557,7 @@ namespace AIProofread System.Windows.Forms.Application.ThreadException -= ProcessApplicationFormException; Logger.Log("shutdown"); documentList.Clear(); - if(_timer != null) + if (_timer != null) { _timer.Stop(); } @@ -586,8 +612,8 @@ namespace AIProofread } - //public string LoadCacheByPath() - //{ + //public string LoadCacheByPath() + //{ //} @@ -603,7 +629,7 @@ namespace AIProofread /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// - private void InternalStartup() + private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); diff --git a/AIProofread/core/DocumentUtil.cs b/AIProofread/core/DocumentUtil.cs index 09ebf0f..c336de6 100644 --- a/AIProofread/core/DocumentUtil.cs +++ b/AIProofread/core/DocumentUtil.cs @@ -113,7 +113,8 @@ namespace AIProofread try { // feat(20250305): 清除批注的时候,如果监测到书签位置是空格,把空格给删了吧(无缓冲记录时) - if (mark.Range.Text.Trim().Length == 0) + string text = mark.Range.Text; + if (text != null && text.Trim().Length == 0) { mark.Range.Text = ""; } @@ -576,14 +577,15 @@ namespace AIProofread } - public static void ExportProofreadResult() + public static void ExportProofreadResult(string modelType) { string currentName = Globals.ThisAddIn.Application.ActiveDocument.Name; // 去掉文件名后缀 currentName = currentName.Substring(0, currentName.LastIndexOf(".")); SaveFileDialog sfd = new SaveFileDialog(); + modelType = modelType == "full" ? "查全" : "查准"; // 设置默认文件名 - sfd.FileName = currentName + "_勘误表.xlsx"; + sfd.FileName = currentName + $"_勘误表_优先{modelType}.xlsx"; sfd.Filter = "Excel文件|*.xlsx"; var result = sfd.ShowDialog(); // 如果用户取消选择,则返回 @@ -846,6 +848,10 @@ namespace AIProofread { tag = "黑名单"; } + else if(it.Type == "fallen_officers") + { + tag = "落马官员"; + } else if (it.Tag == "i") { startIndex = it.Text.Length + 1; diff --git a/AIProofread/favicon.ico b/AIProofread/favicon.ico new file mode 100644 index 0000000..cfe55e5 Binary files /dev/null and b/AIProofread/favicon.ico differ diff --git a/updater/Form1.cs b/updater/Form1.cs index b9bf3ac..b6df72f 100644 --- a/updater/Form1.cs +++ b/updater/Form1.cs @@ -30,9 +30,9 @@ namespace updater * gm-plugin.gachafun.com 正式发布 */ #if DEBUG - private static string UpgradeInfoURI = "http://pre-gm-plugin.gachafun.com/"; + private static string UpgradeInfoURI = "http://gm-plugin.gachafun.com/"; #else - private static string UpgradeInfoURI = "https://pre-gm-plugin.gachafun.com/"; + private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/"; #endif private string updateSource;