diff --git a/.gitignore b/.gitignore index 06ba399..1842436 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ TestConsoleApp obj **/obj/Debug/** **/obj/Release/** -**/obj/Test/** \ No newline at end of file +**/obj/Test/** +**/**/obj/Debug/** +**/**/obj/Release/** +**/**/obj/Test/** \ No newline at end of file diff --git a/.vs/AIProofread/v17/.suo b/.vs/AIProofread/v17/.suo index d4d7a03..4782344 100644 Binary files a/.vs/AIProofread/v17/.suo and b/.vs/AIProofread/v17/.suo differ diff --git a/AIProofread/Bridge.cs b/AIProofread/Bridge.cs index ae17d92..1d10e62 100644 --- a/AIProofread/Bridge.cs +++ b/AIProofread/Bridge.cs @@ -3,23 +3,16 @@ using AIProofread.core; using AIProofread.Model; using AIProofread.Util; using Microsoft.Office.Interop.Word; -using Microsoft.Office.Tools.Word; using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.WinForms; using Newtonsoft.Json; using NPOI; -using NPOI.SS.Formula; -using NPOI.XSSF.UserModel; -using NPOI.XWPF.UserModel; -using Org.BouncyCastle.Asn1.Crmf; using System; using System.Collections.Generic; using System.Diagnostics; -using System.Drawing; using System.IO; using System.Runtime.InteropServices; using System.Text.RegularExpressions; -using System.Threading; using System.Windows.Forms; using UtilLib; using Document = Microsoft.Office.Interop.Word.Document; @@ -336,6 +329,17 @@ namespace AIProofread var documentInfo = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument; var doc = documentInfo.CurrentDocument; + // 判断是否处理修订模式 + if (doc.TrackRevisions) + { + //data.Add("code", 1); + //data.Add("message", "文档存在未处理的修订,请处理后再进行校对"); + var ret = MessageBox.Show("文档当前处于修订模式,是否关闭此模式?","提示",MessageBoxButtons.YesNo); + if(ret == DialogResult.Yes) + { + doc.TrackRevisions = false; + } + } if (ShouldUpgradeForced()) { data.Add("code", 2); diff --git a/AIProofread/Config.cs b/AIProofread/Config.cs index 4172a7b..832c043 100644 --- a/AIProofread/Config.cs +++ b/AIProofread/Config.cs @@ -9,6 +9,30 @@ namespace AIProofread Test, Prod } + + public class AppServer + { + /// + /// 开发环境 + /// + public const string DEV = "http://localhost:5173/"; + /// + /// 测试环境 + /// + public const string TEST = "http://gm2-plugin.zverse.group/"; + /// + /// 果麦预发布-灰度 + /// + public const string PRE = "https://pre-gm-plugin.gachafun.com/"; + /// + /// 果麦生产 + /// + public const string PROD = "https://gm-plugin.gachafun.com/"; + /// + /// 果麦金融 + /// + public const string GM_FN = "https://gm-plugin-fn.gachafun.com/"; + } public class Config { public static readonly string APP_NAME = "AI校对王"; @@ -23,15 +47,16 @@ namespace AIProofread /// public static readonly string TextBackgroundColor = "#E9DABB"; // e9dabb D6AA69 public static string DeviceId = ""; + #if DEBUG /// /// 网页访问地址 /// - public static string WEB_PATH = "http://localhost:5173/"; //pre-gm-plugin.gachafun.com localhost:5173 gm2-plugin.zverse.group + public static string WEB_PATH = AppServer.DEV; //pre-gm-plugin.gachafun.com localhost:5173 gm2-plugin.zverse.group public static bool RUN_IN_DEBUG = true; public static AppEnvironment APP_ENV = AppEnvironment.Dev; #else - public static string WEB_PATH = "https://gm-plugin.gachafun.com/"; // gm-plugin.gachafun.com pre-gm-plugin.gachafun.com + public static string WEB_PATH = AppServer.PROD; // 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/FormCommonsenseDetection.Designer.cs b/AIProofread/Controls/FormCommonsenseDetection.Designer.cs index a333e82..e38ac2e 100644 --- a/AIProofread/Controls/FormCommonsenseDetection.Designer.cs +++ b/AIProofread/Controls/FormCommonsenseDetection.Designer.cs @@ -55,6 +55,7 @@ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "FormCommonsenseDetection"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "常识性检测"; this.Load += new System.EventHandler(this.FormCommonsenseDetection_Load); ((System.ComponentModel.ISupportInitialize)(this.MainWebView)).EndInit(); this.ResumeLayout(false); diff --git a/AIProofread/Controls/FormCommonsenseDetection.cs b/AIProofread/Controls/FormCommonsenseDetection.cs index 3cfcdb9..bee784d 100644 --- a/AIProofread/Controls/FormCommonsenseDetection.cs +++ b/AIProofread/Controls/FormCommonsenseDetection.cs @@ -1,8 +1,8 @@ using AIProofread.core; using Newtonsoft.Json; using System; +using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Threading; using UtilLib; namespace AIProofread.Controls @@ -13,8 +13,7 @@ namespace AIProofread.Controls { private bool initialized = false; - private string action; - private object data; + private List actions = new List(); public FormCommonsenseDetection() { @@ -45,17 +44,24 @@ namespace AIProofread.Controls return; } // 添加到队列 - this.action = action; - this.data = data; + actions.Add(new WebMessage(action, data)); + //this.action = action; + //this.data = data; } public void InitializationCompleted() { - if (!this.initialized && !string.IsNullOrEmpty(this.action)) + if (!this.initialized && actions.Count > 0) // !string.IsNullOrEmpty(this.action) { - SendToWeb(this.action, this.data); - this.action = null; - this.data = null; + actions.ForEach(item => + { + SendToWeb(item.Message, item.Data); + }); + // clear + actions.Clear(); + //SendToWeb(this.action, this.data); + //this.action = null; + //this.data = null; } this.initialized = true; } diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs index 6840c63..4850380 100644 --- a/AIProofread/ThisAddIn.cs +++ b/AIProofread/ThisAddIn.cs @@ -348,6 +348,9 @@ namespace AIProofread ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument); ActiveDocument.CheckBtnStatus(); CheckDocumentClosed(null, null); + if (formCommonsenseDetection != null) { + formCommonsenseDetection.SendMessageToWeb("document-change", null); + } Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName); } diff --git a/AIProofread/core/Tools.cs b/AIProofread/core/Tools.cs index 29c642b..0541279 100644 --- a/AIProofread/core/Tools.cs +++ b/AIProofread/core/Tools.cs @@ -57,7 +57,6 @@ namespace AIProofread // DocumentReader.ReadByVSTO(doc, Globals.ThisAddIn.Application, list); //} } - var map = new Dictionary { { "list", list }, @@ -79,7 +78,11 @@ namespace AIProofread if (bodyElement is XWPFParagraph p) { // 处理普通段落 - list.Add(new DocumentText(p.ParagraphText.Replace("\u0002", ""), paragraphNumber)); + var text = p.ParagraphText.Replace("\u0002", ""); + if(text.Trim().Length > 0) + { + list.Add(new DocumentText(text, paragraphNumber)); + } paragraphNumber++; } // table -- vsto对于每个单元格的分段也会有 diff --git a/updater/Form1.Designer.cs b/updater/Form1.Designer.cs index efab7d7..64c771f 100644 --- a/updater/Form1.Designer.cs +++ b/updater/Form1.Designer.cs @@ -35,24 +35,29 @@ this.panel1 = new System.Windows.Forms.Panel(); this.IconClose = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); + this.panelLog = new System.Windows.Forms.Panel(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit(); + this.panelLog.SuspendLayout(); this.SuspendLayout(); // // LabelLog // - this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.LabelLog.Location = new System.Drawing.Point(40, 57); + this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 10F); + this.LabelLog.Location = new System.Drawing.Point(2, 2); + this.LabelLog.MaximumSize = new System.Drawing.Size(296, 0); + this.LabelLog.MinimumSize = new System.Drawing.Size(296, 0); this.LabelLog.Name = "LabelLog"; - this.LabelLog.Size = new System.Drawing.Size(300, 71); + this.LabelLog.Size = new System.Drawing.Size(296, 21); this.LabelLog.TabIndex = 0; - this.LabelLog.Text = "正在检测。。。"; + this.LabelLog.Text = "版本检测中 ..."; this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.LabelLog.Click += new System.EventHandler(this.LabelLog_Click); // // progressBar1 // - this.progressBar1.Location = new System.Drawing.Point(40, 136); + this.progressBar1.Location = new System.Drawing.Point(40, 180); this.progressBar1.Name = "progressBar1"; this.progressBar1.Size = new System.Drawing.Size(300, 14); this.progressBar1.TabIndex = 3; @@ -64,7 +69,7 @@ this.ButtonProcess.DefaultBack = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(160)))), ((int)(((byte)(99))))); this.ButtonProcess.Font = new System.Drawing.Font("微软雅黑", 10F); this.ButtonProcess.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.ButtonProcess.Location = new System.Drawing.Point(122, 158); + this.ButtonProcess.Location = new System.Drawing.Point(122, 202); this.ButtonProcess.Name = "ButtonProcess"; this.ButtonProcess.Radius = 4; this.ButtonProcess.Size = new System.Drawing.Size(136, 44); @@ -107,19 +112,40 @@ this.label1.TabIndex = 0; this.label1.Text = "温馨提示"; // + // panelLog + // + this.panelLog.AutoScroll = true; + this.panelLog.Controls.Add(this.LabelLog); + this.panelLog.Location = new System.Drawing.Point(40, 58); + this.panelLog.Name = "panelLog"; + this.panelLog.Size = new System.Drawing.Size(300, 114); + this.panelLog.TabIndex = 8; + // + // richTextBox1 + // + this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBox1.Location = new System.Drawing.Point(237, 149); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; + this.richTextBox1.Size = new System.Drawing.Size(100, 96); + this.richTextBox1.TabIndex = 9; + this.richTextBox1.Text = ""; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(380, 216); + this.ClientSize = new System.Drawing.Size(380, 260); + this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.panelLog); this.Controls.Add(this.panel1); this.Controls.Add(this.ButtonProcess); this.Controls.Add(this.progressBar1); - this.Controls.Add(this.LabelLog); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(380, 216); + this.MaximumSize = new System.Drawing.Size(380, 260); this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(380, 216); this.Name = "Form1"; @@ -129,6 +155,7 @@ this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.IconClose)).EndInit(); + this.panelLog.ResumeLayout(false); this.ResumeLayout(false); } @@ -141,6 +168,8 @@ private System.Windows.Forms.PictureBox IconClose; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panelLog; + private System.Windows.Forms.RichTextBox richTextBox1; } } diff --git a/updater/Form1.cs b/updater/Form1.cs index 91b3cd1..ab9bf1c 100644 --- a/updater/Form1.cs +++ b/updater/Form1.cs @@ -159,6 +159,7 @@ namespace updater | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(UpgradeInfoURI + "api/v1/common/download/version"); + httpWebRequest.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse(); // 获取响应内容 if (resp.StatusCode == HttpStatusCode.OK) @@ -174,18 +175,27 @@ namespace updater resp.Close(); UpgradeModel update = JsonConvert.DeserializeObject(updateSource); ProcessUpdate(update); + return; } } catch (Exception) { - LabelLog.Text = "获取更新信息失败,请稍后重试"; } + LabelLog.Text = "获取更新信息失败,请稍后重试"; } private void ProcessUpdate(UpgradeModel update) { this.upgradeInfo = update.Info; - LabelLog.Text = update.Info.Message; + //richTextBox1.Text + richTextBox1.Text = update.Info.Message + + @"Com加载项勾选 +重新安装插件 +升级office或wps的版本 +注册表检测 +Com加载项勾选 +重新安装插件 +补充:无论windowS10或11。在安装插件时,需要先装wps在安装插件,在安装插件。否则菜单中不会显示校对王插件入口"; if (localVersion == null || update.Info.NeedUpgrade(localVersion.Version)) {