perf: 📜️强化常识性检测数据结构优化

This commit is contained in:
LittleBoy 2025-03-28 09:34:03 +08:00
parent 342e32f49f
commit e8c18e6eb8
10 changed files with 116 additions and 32 deletions

5
.gitignore vendored
View File

@ -6,4 +6,7 @@ TestConsoleApp
obj
**/obj/Debug/**
**/obj/Release/**
**/obj/Test/**
**/obj/Test/**
**/**/obj/Debug/**
**/**/obj/Release/**
**/**/obj/Test/**

Binary file not shown.

View File

@ -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);

View File

@ -9,6 +9,30 @@ namespace AIProofread
Test,
Prod
}
public class AppServer
{
/// <summary>
/// 开发环境
/// </summary>
public const string DEV = "http://localhost:5173/";
/// <summary>
/// 测试环境
/// </summary>
public const string TEST = "http://gm2-plugin.zverse.group/";
/// <summary>
/// 果麦预发布-灰度
/// </summary>
public const string PRE = "https://pre-gm-plugin.gachafun.com/";
/// <summary>
/// 果麦生产
/// </summary>
public const string PROD = "https://gm-plugin.gachafun.com/";
/// <summary>
/// 果麦金融
/// </summary>
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
/// </summary>
public static readonly string TextBackgroundColor = "#E9DABB"; // e9dabb D6AA69
public static string DeviceId = "";
#if DEBUG
/// <summary>
/// 网页访问地址
/// </summary>
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

View File

@ -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);

View File

@ -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<WebMessage> actions = new List<WebMessage>();
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