fixed: ✨️修复文档关闭后再次打开展示多个面板
This commit is contained in:
parent
a296604f2c
commit
d16d6d4671
@ -558,6 +558,9 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\icon-manual-wps.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="favicon.ico" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
@ -585,6 +588,9 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<!-- Include the build rules for a C# project. -->
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- Include additional build rules for an Office application add-in. -->
|
||||
|
@ -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<string, object> data = new Dictionary<string, object>();
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据位置获取文档区域文本
|
||||
/// </summary>
|
||||
@ -514,11 +531,21 @@ namespace AIProofread
|
||||
public void ClearCurrentDocumentMarks() => Globals.ThisAddIn.ActiveDocument?.ClearAllProofreadMark();
|
||||
public void removeBookmark(string markId) => DocumentUtil.RemoveBookmark(markId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetDeviceId()
|
||||
{
|
||||
return Config.DeviceId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置帮助文档地址
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public void SetHelpUrl(string url) => Config.USER_MANUAL_URL = url;
|
||||
|
||||
public string getAllBookmark()
|
||||
{
|
||||
return ToJSON(DocumentUtil.GetAllBookmark());
|
||||
@ -715,11 +742,11 @@ namespace AIProofread
|
||||
/// 导出勘误表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ExportProofreadResult()
|
||||
public string ExportProofreadResult(string modelType)
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.ThisAddIn.ActiveDocument.ExportResult();
|
||||
Globals.ThisAddIn.ActiveDocument.ExportResult(modelType);
|
||||
return BridgeResult.Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -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/";
|
||||
/// <summary>
|
||||
/// 文本背景色
|
||||
/// </summary>
|
||||
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -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所在句子
|
||||
|
@ -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")]
|
||||
|
||||
|
@ -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<string>();
|
||||
//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
|
||||
/// <param name="Cancel"></param>
|
||||
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.
|
||||
/// </summary>
|
||||
private void InternalStartup()
|
||||
private void InternalStartup()
|
||||
{
|
||||
this.Startup += new System.EventHandler(ThisAddIn_Startup);
|
||||
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
|
||||
|
@ -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;
|
||||
|
BIN
AIProofread/favicon.ico
Normal file
BIN
AIProofread/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user