diff --git a/.vs/AIProofread/v17/.suo b/.vs/AIProofread/v17/.suo
index 0ced480..d621e15 100644
Binary files a/.vs/AIProofread/v17/.suo and b/.vs/AIProofread/v17/.suo differ
diff --git a/AIProofread/Config.cs b/AIProofread/Config.cs
index 2cd8a17..259729c 100644
--- a/AIProofread/Config.cs
+++ b/AIProofread/Config.cs
@@ -36,7 +36,7 @@ namespace AIProofread
public class Config
{
public static readonly string APP_NAME = "AI校对王(公告版)";
- public static readonly string APP_VERSION = "2.2.3";
+ public static readonly string APP_VERSION = "3.1.0";
public static bool IS_WPS = false;
public static bool UpgradeForcedNotice = false;
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;
@@ -52,9 +52,9 @@ namespace AIProofread
///
/// 网页访问地址
///
- public static string WEB_PATH = AppServer.DEV; //pre-gm-plugin.gachafun.com localhost:5173 gm2-plugin.zverse.group
+ public static string WEB_PATH = AppServer.TEST; //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;
+ public static AppEnvironment APP_ENV = AppEnvironment.Prod;
#else
public static string WEB_PATH = AppServer.TEST; // gm-plugin.gachafun.com pre-gm-plugin.gachafun.com
public static bool RUN_IN_DEBUG = false;
diff --git a/AIProofread/Logger.cs b/AIProofread/Logger.cs
index 0cb4d3c..02a8f33 100644
--- a/AIProofread/Logger.cs
+++ b/AIProofread/Logger.cs
@@ -1,4 +1,5 @@
using AIProofread.Controls;
+using SixLabors.Fonts.Tables.AdvancedTypographic;
using System;
using System.Collections.Generic;
using System.IO;
@@ -59,5 +60,15 @@ namespace AIProofread
Globals.ThisAddIn.SendMessageToWeb("DEBUG-LOG", msg);
}
}
+
+ public static void Error(string v, Exception e)
+ {
+ Log("ERROR", v + "\n" + e.Message + "\n" + e.StackTrace);
+ }
+
+ internal static void Info(string v)
+ {
+ Log("INFO", v);
+ }
}
}
diff --git a/AIProofread/Model/DocumentInfo.cs b/AIProofread/Model/DocumentInfo.cs
index 65176a7..2bccb6f 100644
--- a/AIProofread/Model/DocumentInfo.cs
+++ b/AIProofread/Model/DocumentInfo.cs
@@ -1029,5 +1029,22 @@ namespace AIProofread.Model
Logger.Log(CurrentDocument.FullName + $" TaskPane visible {PaneVisible} has " + (TaskPane == null ? "null" : "exists"));
if (TaskPane == null) CreateTaskPane();
}
+
+ public void GlobalCallback(string callbackId, string result)
+ {
+ ProofreadMainControl control = (ProofreadMainControl)TaskPane.Control;
+ try
+ {
+ if (control.web.CoreWebView2 == null)
+ {
+ Thread.Sleep(1000);
+ }
+ control.web.CoreWebView2.ExecuteScriptAsync($"window.__global_callback_function('{callbackId}','{result}');");
+ }
+ catch (Exception ex)
+ {
+ Logger.Log("GlobalCallback", "call web global function error \n" + ex.Message + "\n" + callbackId + result);
+ }
+ }
}
}
diff --git a/AIProofread/Model/DocumentList.cs b/AIProofread/Model/DocumentList.cs
index 4a8354c..d9d890d 100644
--- a/AIProofread/Model/DocumentList.cs
+++ b/AIProofread/Model/DocumentList.cs
@@ -142,5 +142,6 @@ namespace AIProofread.Model
{
documentList.ForEach(d => d.HidePane());
}
+
}
}
diff --git a/AIProofread/Properties/AssemblyInfo.cs b/AIProofread/Properties/AssemblyInfo.cs
index 3907dd9..cf99869 100644
--- a/AIProofread/Properties/AssemblyInfo.cs
+++ b/AIProofread/Properties/AssemblyInfo.cs
@@ -7,10 +7,10 @@ using System.Security;
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AI校对王(公告版)")]
-[assembly: AssemblyDescription("AI校对王(公告版) 1.0.0")]
+[assembly: AssemblyDescription("AI校对王(公告版) 1.1.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("果麦文化传媒股份有限公司")]
-[assembly: AssemblyProduct("AI校对王(公告版) 1.0.0")]
+[assembly: AssemblyProduct("AI校对王(公告版) 1.1.0")]
[assembly: AssemblyCopyright("Copyright © 果麦文化传媒股份有限公司 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -33,6 +33,6 @@ using System.Security;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs
index 7c6aa65..5180ac8 100644
--- a/AIProofread/ThisAddIn.cs
+++ b/AIProofread/ThisAddIn.cs
@@ -8,19 +8,15 @@ using AIProofread.Controls;
using UtilLib;
using AIProofread.Model;
using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-using System.Text;
-//using CustomTaskPane = Microsoft.Office.Core.CustomTaskPane;
-//using CustomTaskPane = Microsoft.Office.Tools.CustomTaskPane;
-//using NPOI.SS.Formula.Functions;
+
namespace AIProofread
{
public partial class ThisAddIn
{
-
+ // LogManager.GetLogger(typeof(ThisAddIn))
+ //public ILog Logger = LogHelper.GetLogger(typeof(ThisAddIn));
public static SynchronizationContext FmainThreadContext;
public string AddinName = " ";
@@ -98,7 +94,7 @@ namespace AIProofread
{
if (fromLawQuery == null || fromLawQuery.IsDisposed)
{
- fromLawQuery = new FormWebView(Config.WebPath("laws-query?app_v=101"), 1300, 750);
+ fromLawQuery = new FormWebView(Config.WebPath("laws-query?app_v=101"), 1300,800);
}
fromLawQuery.Show();
// 显示在最前面
@@ -139,7 +135,7 @@ namespace AIProofread
//formCommonsenseDetection.ShowInTaskbar = false;
//formCommonsenseDetection.Show();
- Logger.Log("ThisAddIn_Startup IS_WPS --> " + IsWPS);
+ Logger.Log("ThisAddIn_Startup Platform --> " + (IsWPS?"WPS":"WORD"));
// 捕获全局异常
AppDomain.CurrentDomain.UnhandledException += ProcessApplicationException;
System.Windows.Forms.Application.ThreadException += ProcessApplicationFormException;
@@ -217,7 +213,7 @@ namespace AIProofread
// 可能出现另存问题 所以需要更新文件名称
var oldName = item.fileName;
var currentName = item.CurrentDocument.FullName;
- if(oldName != currentName)
+ if (oldName != currentName)
{
item.fileName = currentName;
}
@@ -281,7 +277,7 @@ namespace AIProofread
private void Application_DocumentBeforeSave(Document originDocument, ref bool SaveAsUI, ref bool Cancel)
{
- Logger.Log("DocumentSave", originDocument.Name + "\r\n");
+ //LogHelper.Log("DocumentSave", originDocument.Name + "\r\n");
if (CurrentWordApplication.Documents.Count == 0)
{
return;
@@ -317,27 +313,24 @@ namespace AIProofread
}
catch (Exception ex)
{
- Logger.Log("Init WPS Error " + ex.Message);
+ Logger.Log("Init WPS Error ",ex);
}
}
- // 如果启用直接有文档打开
- // 初始化面板
try
{
- var docList = CurrentWordApplication.Documents;
- if(docList.Count > 0)
- {
- foreach (Document item in docList)
+ // 默认已经打开了文档 直接初始化
+ if(CurrentWordApplication.Documents.Count > 0){
+ foreach (Document item in CurrentWordApplication.Documents)
{
- Logger.Log("Init Documentinfo ==> " + item.Name);
- var info = documentList.InitDocument(item);
+ var info = documentList.InitDocument(item);
+ // 直接初始化面板
info.CheckPanel();
}
}
}
catch (Exception ex)
{
- Logger.Log("Init Documentinfo Error " + ex.Message);
+ Logger.Error("Initialize documentlist Error ", ex);
}
string verTextFile = Config.APP_BASE_DIR + Path.GetFileName("app_version.txt");
try
@@ -348,7 +341,6 @@ namespace AIProofread
{
Logger.Log("Write App Version Error " + ex.Message);
}
-
}
private void InitAppByConfig()
@@ -358,7 +350,7 @@ namespace AIProofread
if (File.Exists(Config.CONFIG_FILE))
{
string content = File.ReadAllText(Config.CONFIG_FILE);
- Logger.Log("INIT", "Found app.json " + content);
+ //LogHelper.Log("INIT", "Found app.json " + content);
if (content == null || content.Length == 0) return;
AppConfig config = JsonConvert.DeserializeObject(content);
@@ -396,10 +388,11 @@ namespace AIProofread
ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument);
ActiveDocument.CheckBtnStatus();
CheckDocumentClosed(null, null);
- if (formCommonsenseDetection != null) {
+ if (formCommonsenseDetection != null)
+ {
formCommonsenseDetection.SendMessageToWeb("document-change", null);
}
- Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName);
+ //LogHelper.Log("Application_DocumentChange -- " + ActiveDocument.fileName + " track is " + ActiveDocument.CurrentDocument.TrackRevisions);
}
public void SetActiveDocument(Document doc)
@@ -424,8 +417,11 @@ namespace AIProofread
///
private void Application_WindowActivate(Document activeDoc, Window Wn)
{
- ActiveDocument = documentList.SetActiveDocument(activeDoc);
- Logger.Log("Application_WindowActivate -- " + ActiveDocument.fileName);
+ if (activeDoc != null && (ActiveDocument == null || activeDoc != ActiveDocument.CurrentDocument))
+ {
+ ActiveDocument = documentList.SetActiveDocument(activeDoc);
+ Logger.Info("Application_WindowActivate -- " + ActiveDocument.fileName);
+ }
//// 当前文档添加书签集合
//if (!allMarks.ContainsKey(activeDoc))
//{
@@ -462,7 +458,7 @@ namespace AIProofread
{
doc.HidePane();
}
- Logger.Log("DocumentBeforeClose", currentDoc.FullName);
+ //LogHelper.Log("DocumentBeforeClose", currentDoc.FullName);
//if (allMarks.ContainsKey(currentDoc))
//{
// allMarks.Remove(currentDoc);
@@ -484,12 +480,12 @@ namespace AIProofread
private void Application_NewDocument(Document doc)
{
- Logger.Log("NewDocument" + doc.Name);
+ //LogHelper.Log("NewDocument" + doc.Name);
}
private void Application_DocumentOpen(Document doc)
{
- Logger.Log("DocumentOpen " + doc.Name);
+ //LogHelper.Log("DocumentOpen " + doc.Name);
}
@@ -552,6 +548,11 @@ namespace AIProofread
ActiveDocument?.SendMessageToWeb(msg, data);
}
+ public void GlobalCallback(string callbackId, string result)
+ {
+ ActiveDocument?.GlobalCallback(callbackId, result);
+ }
+
// 显示面板
public void ShowPanel()
{
diff --git a/AIProofread/core/DocumentUtil.cs b/AIProofread/core/DocumentUtil.cs
index e418f2d..4bb6b8a 100644
--- a/AIProofread/core/DocumentUtil.cs
+++ b/AIProofread/core/DocumentUtil.cs
@@ -391,7 +391,7 @@ namespace AIProofread
return bookmark;
}
- private static Range FindBySentence(Range paraRange, CorrectContext c, CorrectItem item, Microsoft.Office.Interop.Word.Document document)
+ private static Range FindBySentence(Range paraRange, CorrectContext c, CorrectItem item, Microsoft.Office.Interop.Word.Document document,int prevOffset)
{
try
{
@@ -409,6 +409,7 @@ namespace AIProofread
}
//int count = 0;
var range = document.Range(offset + item.Start, offset + item.End + 1);
+ #region
//while (true && count++ < 10)
//{
// //
@@ -433,6 +434,7 @@ namespace AIProofread
// Logger.Log(dce);
// }
//}
+ #endregion
// 比对原始内容与校对原文是否一致
if (range.Text == item.Origin)
{
@@ -442,7 +444,7 @@ namespace AIProofread
// 直接找
var range1 = document.Range(offset + item.Start, offset + item.End + 1);
// 兼容空格的全角与半角
- if(item.Origin == " " && (range1.Text == " " || range1.Text == " " || range1.Text.Trim().Length == 0))
+ if (item.Origin == " " && (range1.Text == " " || range1.Text == " " || range1.Text.Trim().Length == 0))
{
return range1;
}
@@ -452,7 +454,7 @@ namespace AIProofread
return range1;
}
// 执行查找
- return FindTextInRange(sentence, item.Origin);
+ return FindTextInRange(sentence, item.Origin, prevOffset);
}
catch (Exception)
{
@@ -461,10 +463,15 @@ namespace AIProofread
return null;
}
- public static Range FindTextInRange(Range range, string searchText)
+ public static Range FindTextInRange(Range range, string searchText,int findStart = -1)
{
try
{
+ // 设置起始位置
+ if (findStart > 0)
+ {
+ range.Start = range.Start + findStart;
+ }
Find find = range.Find;
if (range.Comments.Count > 0)
{
@@ -477,7 +484,8 @@ namespace AIProofread
find.Wrap = WdFindWrap.wdFindContinue;
find.Execute();
if (find.Found) return range;
- } catch (Exception) { }
+ }
+ catch (Exception) { }
return null;
}
@@ -493,7 +501,7 @@ namespace AIProofread
//var offset = paraStart + c.SentenceOffset;
////var cutLength = Math.Min(c.InsertLen, paraText.Length - offset);
- var originFindRange = FindBySentence(paraRange, c, item, document);
+ var originFindRange = FindBySentence(paraRange, c, item, document, prevOffset);
if (originFindRange != null) return originFindRange;
// 如果是新增 则查找定位
@@ -616,7 +624,7 @@ namespace AIProofread
}
- private static NPOI.SS.UserModel.ICell CreateCell(IRow row, int colIndex, IFont font, string text,ICellStyle style = null)
+ private static NPOI.SS.UserModel.ICell CreateCell(IRow row, int colIndex, IFont font, string text, ICellStyle style = null)
{
var cell = row.CreateCell(colIndex);
if (font != null)
@@ -629,7 +637,7 @@ namespace AIProofread
{
cell.SetCellValue(text);
}
- if(style != null)
+ if (style != null)
{
cell.CellStyle = style;
@@ -674,7 +682,7 @@ namespace AIProofread
};
// 设置表头筛选及冻结 2.0.5 2024-12-30修改
- sheet.CreateFreezePane(0, 1,0,1);
+ sheet.CreateFreezePane(0, 1, 0, 1);
sheet.SetAutoFilter(CellRangeAddress.ValueOf("A1:G1"));
// 设置表头为白色
@@ -683,13 +691,13 @@ namespace AIProofread
headerFont.FontName = "黑体"; // 设置字体
headerFont.FontHeightInPoints = 11; // 字体大小
var themeColor = new XSSFColor(new byte[] { 214, 170, 105 }); // 首行背景色黑色,字体用主题金色
- ((XSSFFont)headerFont).SetColor(themeColor);
+ ((XSSFFont)headerFont).SetColor(themeColor);
headerStyle.SetFont(headerFont); // 应用字体
// 设置背景颜色为黑色
headerStyle.FillForegroundColor = HSSFColor.Black.Index; // 设置前景色
headerStyle.FillPattern = FillPattern.SolidForeground; // 使用实心填充模式
-
+
// 对齐方式
headerStyle.VerticalAlignment = VerticalAlignment.Center; // 垂直居中
headerStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; // 水平居中
@@ -848,7 +856,7 @@ namespace AIProofread
{
tag = "黑名单";
}
- else if(it.Type == "fallen_officers")
+ else if (it.Type == "fallen_officers")
{
tag = "落马官员";
}