diff --git a/.vs/AIProofread/v17/.suo b/.vs/AIProofread/v17/.suo index f2591a0..c92fe28 100644 Binary files a/.vs/AIProofread/v17/.suo and b/.vs/AIProofread/v17/.suo differ diff --git a/AIProofread/AIProofread.csproj b/AIProofread/AIProofread.csproj index 87f58d3..d6ed545 100644 --- a/AIProofread/AIProofread.csproj +++ b/AIProofread/AIProofread.csproj @@ -362,6 +362,12 @@ FormMessage.cs + + Form + + + FormReadme.cs + Form @@ -450,6 +456,9 @@ FormMessage.cs + + FormReadme.cs + FormSetting.cs diff --git a/AIProofread/Bridge.cs b/AIProofread/Bridge.cs index 66c806f..eff974e 100644 --- a/AIProofread/Bridge.cs +++ b/AIProofread/Bridge.cs @@ -750,7 +750,6 @@ namespace AIProofread public void SelectMarkById(int proofreadId, int documentId) { - Globals.ThisAddIn.ActiveDocument?.SelectMarkById(proofreadId, false); } diff --git a/AIProofread/Config.cs b/AIProofread/Config.cs index 539c558..19057cf 100644 --- a/AIProofread/Config.cs +++ b/AIProofread/Config.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Text.RegularExpressions; namespace AIProofread @@ -36,8 +37,8 @@ namespace AIProofread public class Config { public static readonly string APP_NAME = "AI校对王"; - public static readonly string APP_VERSION = "2.2.5"; - public static readonly string BuildVersion = "20250620_1532"; + public static readonly string APP_VERSION = "2.2.6"; + public static readonly string BuildVersion = "20250623_1757"; public static bool IS_WPS = false; public static bool UpgradeForcedNotice = false; public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory; @@ -65,6 +66,7 @@ namespace AIProofread public static readonly string APP_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread"; public static readonly string APP_LOG_PATH = APP_DATA_PATH + "\\logs\\"; + public static readonly string APP_README_PATH = APP_DATA_PATH + "\\readme\\"; public static readonly string WEB_DATA_PATH = APP_DATA_PATH + "\\userdata"; /// @@ -73,6 +75,14 @@ namespace AIProofread public static readonly string BOOKMARK_NAME_PREFIX = "ai_proofread_"; private static readonly Regex regex = new Regex("^ai_proofread_\\d+$"); + public static string GetCurrentVersionReadmeCacheFile() + { + if (!Directory.Exists(APP_README_PATH)) + { + Directory.CreateDirectory(APP_README_PATH); + } + return Path.Combine(APP_README_PATH, APP_VERSION + ".txt"); + } public static bool IsProofreadMark(string name) { diff --git a/AIProofread/Controls/FormReadme.Designer.cs b/AIProofread/Controls/FormReadme.Designer.cs new file mode 100644 index 0000000..8a080ab --- /dev/null +++ b/AIProofread/Controls/FormReadme.Designer.cs @@ -0,0 +1,68 @@ +namespace AIProofread.Controls +{ + partial class FormReadme + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.WebView_ReadMe = new Microsoft.Web.WebView2.WinForms.WebView2(); + ((System.ComponentModel.ISupportInitialize)(this.WebView_ReadMe)).BeginInit(); + this.SuspendLayout(); + // + // WebView_ReadMe + // + this.WebView_ReadMe.AllowExternalDrop = true; + this.WebView_ReadMe.CreationProperties = null; + this.WebView_ReadMe.DefaultBackgroundColor = System.Drawing.Color.White; + this.WebView_ReadMe.Dock = System.Windows.Forms.DockStyle.Fill; + this.WebView_ReadMe.Location = new System.Drawing.Point(0, 0); + this.WebView_ReadMe.Name = "WebView_ReadMe"; + this.WebView_ReadMe.Size = new System.Drawing.Size(600, 480); + this.WebView_ReadMe.TabIndex = 0; + this.WebView_ReadMe.ZoomFactor = 1D; + // + // FormReadme + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(600, 480); + this.Controls.Add(this.WebView_ReadMe); + this.Name = "FormReadme"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "版本更新说明"; + this.TopMost = true; + this.Load += new System.EventHandler(this.FormReadme_Load); + ((System.ComponentModel.ISupportInitialize)(this.WebView_ReadMe)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Microsoft.Web.WebView2.WinForms.WebView2 WebView_ReadMe; + } +} \ No newline at end of file diff --git a/AIProofread/Controls/FormReadme.cs b/AIProofread/Controls/FormReadme.cs new file mode 100644 index 0000000..771a34d --- /dev/null +++ b/AIProofread/Controls/FormReadme.cs @@ -0,0 +1,55 @@ +using AIProofread.core; +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace AIProofread.Controls +{ + [ClassInterface(ClassInterfaceType.AutoDual)] + [ComVisible(true)] + public partial class FormReadme : BaseWinForm + { + /// + /// 单例实例。 + /// + private static FormReadme INSTANCE = null; + public FormReadme() + { + InitializeComponent(); + // 写入缓存 + File.WriteAllText(Config.GetCurrentVersionReadmeCacheFile(), DateTime.Now.ToString("yyyy-M-d")); + } + + /// + /// 获取单例对象。 + /// + public static FormReadme GetInstance(bool newInstance = true) + { + if (newInstance && (INSTANCE == null || INSTANCE.IsDisposed)) + { + INSTANCE = new FormReadme(); + } + return INSTANCE; + } + + public void CloseAndDispose() + { + if (INSTANCE != null && !INSTANCE.IsDisposed) + { + INSTANCE.Close(); + INSTANCE = null; + } + } + + private void FormReadme_Load(object sender, EventArgs e) + { + // 初始化 + InitWebView(WebView_ReadMe, Config.WebPath("version-readme"), "version-readme", () => + { + WebView_ReadMe.CoreWebView2.AddHostObjectToScript("readme", this); + }); + } + + + } +} diff --git a/AIProofread/Controls/FormReadme.resx b/AIProofread/Controls/FormReadme.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AIProofread/Controls/FormReadme.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AIProofread/Properties/AssemblyInfo.cs b/AIProofread/Properties/AssemblyInfo.cs index fdb10ef..03af65e 100644 --- a/AIProofread/Properties/AssemblyInfo.cs +++ b/AIProofread/Properties/AssemblyInfo.cs @@ -7,10 +7,10 @@ using System.Security; // 控制。更改这些特性值可修改 // 与程序集关联的信息。 [assembly: AssemblyTitle("AI校对王")] -[assembly: AssemblyDescription("AI校对王 2.2.5")] +[assembly: AssemblyDescription("AI校对王 2.2.6")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("果麦文化传媒股份有限公司")] -[assembly: AssemblyProduct("AI校对王 2.2.5")] +[assembly: AssemblyProduct("AI校对王 2.2.6")] [assembly: AssemblyCopyright("Copyright © 果麦文化传媒股份有限公司 2025")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -33,6 +33,6 @@ using System.Security; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0")] -[assembly: AssemblyFileVersion("2.2.5.0")] +[assembly: AssemblyVersion("2.2.6.0")] +[assembly: AssemblyFileVersion("2.2.6.0")] diff --git a/AIProofread/Ribbon1.Designer.cs b/AIProofread/Ribbon1.Designer.cs index 28810f1..e350492 100644 --- a/AIProofread/Ribbon1.Designer.cs +++ b/AIProofread/Ribbon1.Designer.cs @@ -132,7 +132,7 @@ namespace AIProofread // this.BtnExportProofreadResult.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge; this.BtnExportProofreadResult.Image = global::AIProofread.Properties.Resources.icon_export; - this.BtnExportProofreadResult.Label = "导出勘误表\r\n"; + this.BtnExportProofreadResult.Label = "勘误表导出\r\n"; this.BtnExportProofreadResult.Name = "BtnExportProofreadResult"; this.BtnExportProofreadResult.ShowImage = true; this.BtnExportProofreadResult.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnExportProofreadResult_Click); @@ -162,7 +162,7 @@ namespace AIProofread this.menuSencenDect.Items.Add(this.btnDetectionAll); this.menuSencenDect.Items.Add(this.btnDetectionParagraph); this.menuSencenDect.Items.Add(this.btnDetectionHistory); - this.menuSencenDect.Label = "常识性检测\r\n"; + this.menuSencenDect.Label = "常识性校对助手\r\n"; this.menuSencenDect.Name = "menuSencenDect"; this.menuSencenDect.ShowImage = true; // diff --git a/AIProofread/Ribbon1.cs b/AIProofread/Ribbon1.cs index eba7bdf..39c8f6a 100644 --- a/AIProofread/Ribbon1.cs +++ b/AIProofread/Ribbon1.cs @@ -142,6 +142,7 @@ namespace AIProofread /// public void ProcessLogout() { + Globals.ThisAddIn.CloseReadmeIfShown(); IS_LOGIN = false; currentLoginUserinfo = null; ToggleLogin(); @@ -162,12 +163,14 @@ namespace AIProofread // 弹出登录窗口 private void btnLogin_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Bridge.bridge.ShowLoginForm(null); } // 注销登录 private void btnLogout_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.ActiveDocument.ShowDialog(currentLoginUserinfo.phone + " 退出AI校对王?", "确定", "logout"); //Globals.ThisAddIn.ShowDialog("退出AI校对王",) @@ -180,23 +183,27 @@ namespace AIProofread public void ShowNewVersionIcon() { + Globals.ThisAddIn.CloseReadmeIfShown(); BtnUpdate.Image = Globals.ThisAddIn.IsWPS? Resources.icon_update_new_wps : Resources.icon_update_new; } private void btnOpenLexicon_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("show-lexicon", null); //(new FormLexicon()).Show(); } private void btnSetting_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("show-setting", null); } private void BtnGetContact_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); var frm = new FormContact(); Globals.ThisAddIn.ActiveDocument.RunInMainThread(() => { @@ -206,6 +213,7 @@ namespace AIProofread private void BtnUpdate_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); //System.Windows.Forms.MessageBox.Show("当前插件是最新版本"); //Globals.ThisAddIn.SendMessageToWeb("upgrade", Config.APP_VERSION); Bridge.bridge.ShowUpgradeView(); @@ -213,6 +221,7 @@ namespace AIProofread private void btnClear_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); //DocumentUtil.ClearProofreadMarks(); Globals.ThisAddIn.ActiveDocument.ShowDialog("请确认是否清除此文档的所有校对标注?", "确定", "clear-tips"); @@ -225,11 +234,13 @@ namespace AIProofread private void btnShowPane_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.ShowPanel(); } private void btnHidePane_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.HidePanel(); } @@ -553,16 +564,19 @@ namespace AIProofread private void ButtonLoadCache_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.ShowDialog("即将加载最近保存的进度,新的修改可能会丢失!", "确定", "load-cache"); } private void BtnShowPanel_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("show-panel", ""); } private void BtnOpenAppDir_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); // 打开日志目录 Process.Start(AppDomain.CurrentDomain.BaseDirectory); } @@ -571,11 +585,13 @@ namespace AIProofread private void BtnExportProofreadResult_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("export-result", ""); } private void BtnShowVersion_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("show-version", ""); } @@ -583,11 +599,13 @@ namespace AIProofread private void btnDetectionAll_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("show-check-all", ""); } private void btnDetectionParagraph_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); // 获取当前选中的选区的首尾段落起始与结束位置 var start = currectSelectRange.Start; // .Paragraphs.First.Range var end = currectSelectRange.End; // .Paragraphs.Last.Range @@ -598,6 +616,7 @@ namespace AIProofread private void btnDetectionHistory_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.SendMessageToWeb("show-check-history", ""); } @@ -625,6 +644,7 @@ namespace AIProofread private void BtnShowManual_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); try { Process.Start(Config.USER_MANUAL_URL); @@ -635,6 +655,7 @@ namespace AIProofread private void BtnProofreadExact_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); // Globals.ThisAddIn.ActiveDocument.CheckPanel(); Globals.ThisAddIn.SendMessageToWeb("start", "exact"); @@ -642,12 +663,14 @@ namespace AIProofread private void BtnProofreadFull_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Globals.ThisAddIn.ActiveDocument.CheckPanel(); Globals.ThisAddIn.SendMessageToWeb("start", "full"); } private void button2_Click(object sender, RibbonControlEventArgs e) { + Globals.ThisAddIn.CloseReadmeIfShown(); Bridge.bridge.ShowLoginForm(null); } } diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs index b1abba3..fa23ea7 100644 --- a/AIProofread/ThisAddIn.cs +++ b/AIProofread/ThisAddIn.cs @@ -9,8 +9,6 @@ using UtilLib; using AIProofread.Model; using System.Collections.Generic; using log4net; -using System.Threading.Tasks; -using DocumentFormat.OpenXml.EMMA; namespace AIProofread @@ -36,6 +34,7 @@ namespace AIProofread /// 校对面板 /// public ProofreadMainControl proofreadPanel; + private bool alreadyShowReadme = false; /// /// 工具栏 /// @@ -140,6 +139,7 @@ namespace AIProofread //CheckPluginUpgradeInfo(); // CheckDocumentClosedTick(); + // 定时检测文档是否关闭 //_timer = new System.Timers.Timer(10000); //_timer.Elapsed += CheckDocumentClosed; @@ -376,6 +376,7 @@ namespace AIProofread private void Application_DocumentChange() { + ShowVersionReadme(); // 检测是否存在打开的文档 if (CurrentWordApplication.Documents.Count == 0) { @@ -434,6 +435,7 @@ namespace AIProofread /// private void Application_WindowActivate(Document activeDoc, Window Wn) { + ShowVersionReadme(); Logger.Debug("WindowActivate -- " + activeDoc.Name); if (activeDoc != null && InDocumentInList(activeDoc)) { @@ -442,6 +444,7 @@ namespace AIProofread + ActiveDocument?.CurrentDocument?.Name + "==》" + activeDoc.Name); documentList.SetActiveDocument(activeDoc); + //// 设置当前文档 //ActiveDocument = document; } @@ -501,9 +504,38 @@ namespace AIProofread //LogHelper.Log("NewDocument" + doc.Name); } + private void ShowVersionReadme() + { + if (alreadyShowReadme || File.Exists(Config.GetCurrentVersionReadmeCacheFile())) + { + return; + } + alreadyShowReadme = true; + FormReadme.GetInstance().Show(); + //ActiveDocument?.RunInMainThread(() => + //{ + //}); + } + + /// + /// 如果Readme显示 则关闭 + /// + public void CloseReadmeIfShown() + { + try + { + FormReadme.GetInstance(false).CloseAndDispose(); + } + catch (Exception ex) + { + Logger.Error("CloseReadme Error", ex); + } + } + private void Application_DocumentOpen(Document doc) { //LogHelper.Log("DocumentOpen " + doc.Name); + ShowVersionReadme(); } diff --git a/updater/Form1.cs b/updater/Form1.cs index 168a44d..f9d0a70 100644 --- a/updater/Form1.cs +++ b/updater/Form1.cs @@ -115,11 +115,11 @@ namespace updater } string updateFileName = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl); // 判断是否已经存在升级包 - if (File.Exists(updateFileName)) - { - ExtractUpdatePackage(); - return; - } + //if (File.Exists(updateFileName)) + //{ + // ExtractUpdatePackage(); + // return; + //} DownLoadFile(upgradeInfo.DownloadUrl, updateFileName); }