添加版本
This commit is contained in:
parent
2bebf743ba
commit
1644a1591f
Binary file not shown.
@ -401,6 +401,7 @@
|
|||||||
<Compile Include="core\Tools.cs" />
|
<Compile Include="core\Tools.cs" />
|
||||||
<Compile Include="core\MainPanelWebMessage.cs" />
|
<Compile Include="core\MainPanelWebMessage.cs" />
|
||||||
<Compile Include="core\ExportConfig.cs" />
|
<Compile Include="core\ExportConfig.cs" />
|
||||||
|
<Compile Include="core\WebView2EventHandler.cs" />
|
||||||
<Compile Include="LogHelper.cs" />
|
<Compile Include="LogHelper.cs" />
|
||||||
<Compile Include="Model\BridgeResult.cs" />
|
<Compile Include="Model\BridgeResult.cs" />
|
||||||
<Compile Include="Model\CommonsenseDetectionItem.cs" />
|
<Compile Include="Model\CommonsenseDetectionItem.cs" />
|
||||||
|
@ -52,7 +52,7 @@ namespace AIProofread
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网页访问地址
|
/// 网页访问地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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 bool RUN_IN_DEBUG = true;
|
||||||
public static AppEnvironment APP_ENV = AppEnvironment.Dev;
|
public static AppEnvironment APP_ENV = AppEnvironment.Dev;
|
||||||
#else
|
#else
|
||||||
@ -103,7 +103,8 @@ namespace AIProofread
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string WebPath(string path)
|
public static string WebPath(string path)
|
||||||
{
|
{
|
||||||
return WEB_PATH + path;
|
Random r = new Random();
|
||||||
|
return WEB_PATH + path + (path.IndexOf("?") == -1 ? "?":"&") + $"ver={APP_VERSION}&r=" + r.NextDouble();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Office.Interop.Word;
|
|
||||||
using Microsoft.Web.WebView2.Core;
|
using Microsoft.Web.WebView2.Core;
|
||||||
|
using Microsoft.Web.WebView2.WinForms;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@ -11,15 +12,55 @@ namespace AIProofread.Controls
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Bridge.InitWebEnvAsync("main", web);
|
Bridge.InitWebEnvAsync("main", web);
|
||||||
|
|
||||||
//this.minWidth = 420 * LabelWidth() / 42;
|
//this.minWidth = 420 * LabelWidth() / 42;
|
||||||
//this.MinimumSize = new System.Drawing.Size(this.minWidth, 0);
|
//this.MinimumSize = new System.Drawing.Size(this.minWidth, 0);
|
||||||
}
|
}
|
||||||
|
private bool isShowingErrorPage = false;
|
||||||
|
public void WebView2NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
if (isShowingErrorPage)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.IsSuccess)
|
||||||
|
{
|
||||||
|
isShowingErrorPage = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isShowingErrorPage = true;
|
||||||
|
string errorPageHtml = @"
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>加载失败</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: sans-serif; text-align: center; padding-top: 50px; user-select: none; }
|
||||||
|
h1 { color: #d00; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body oncontextmenu='return false;'>
|
||||||
|
<h1>页面加载失败</h1>
|
||||||
|
<p>请检查您的网络连接或稍后再试。</p>
|
||||||
|
<a href="+ "\"javascript:window.chrome.webview.postMessage('reload');\"" + @">重新加载</a>
|
||||||
|
</body>
|
||||||
|
</html>";
|
||||||
|
(sender as WebView2).CoreWebView2.NavigateToString(errorPageHtml);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ProofreadMainControl_Load(object sender, EventArgs e)
|
private void ProofreadMainControl_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.web.Source = new Uri(Config.WebPath("correct?version=" + Config.APP_VERSION + "&t=" + DateTime.Now.Ticks));
|
this.web.NavigationCompleted += WebView2NavigationCompleted;
|
||||||
|
this.web.WebMessageReceived += (s, ex) =>
|
||||||
|
{
|
||||||
|
if (ex.TryGetWebMessageAsString() == "reload")
|
||||||
|
{
|
||||||
|
isShowingErrorPage = false;
|
||||||
|
web.Source = new Uri(Config.WebPath("correct"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.web.Source = new Uri(Config.WebPath("correct" ));
|
||||||
//this.SizeChanged += ProofreadMainControl_SizeChanged;
|
//this.SizeChanged += ProofreadMainControl_SizeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using DocumentFormat.OpenXml;
|
using DocumentFormat.OpenXml;
|
||||||
using System.Windows.Forms;
|
|
||||||
using UtilLib;
|
using UtilLib;
|
||||||
using System.Diagnostics;
|
|
||||||
using System;
|
using System;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
@ -22,9 +20,9 @@ namespace AIProofread.core
|
|||||||
|
|
||||||
private static CorrectResultExportor exportor = new CorrectResultExportor();
|
private static CorrectResultExportor exportor = new CorrectResultExportor();
|
||||||
|
|
||||||
private HexBinaryValue primaryColor = new HexBinaryValue("D6AA69");
|
private HexBinaryValue primaryColor = new HexBinaryValue("FFD6AA69");
|
||||||
private HexBinaryValue whiteColor = new HexBinaryValue("FFFFFF");
|
private HexBinaryValue whiteColor = new HexBinaryValue("FFFFFFFF");
|
||||||
private HexBinaryValue blackColor = new HexBinaryValue("000000");
|
private HexBinaryValue blackColor = new HexBinaryValue("FF000000");
|
||||||
|
|
||||||
private CorrectResultExportor()
|
private CorrectResultExportor()
|
||||||
{
|
{
|
||||||
@ -166,7 +164,7 @@ namespace AIProofread.core
|
|||||||
workbookPart.Workbook = new Workbook();
|
workbookPart.Workbook = new Workbook();
|
||||||
|
|
||||||
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
|
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
|
||||||
var worksheet = new Worksheet(new SheetData());
|
var worksheet = new Worksheet();
|
||||||
// 冻结首行
|
// 冻结首行
|
||||||
worksheet.Append(new SheetViews(
|
worksheet.Append(new SheetViews(
|
||||||
new SheetView()
|
new SheetView()
|
||||||
@ -185,6 +183,9 @@ namespace AIProofread.core
|
|||||||
// 创建
|
// 创建
|
||||||
Sheets sheets = document.WorkbookPart.Workbook.AppendChild(new Sheets());
|
Sheets sheets = document.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||||
|
|
||||||
|
// 美化sheet
|
||||||
|
StyleSheet(worksheet); // column 必须在sheet data 之前
|
||||||
|
worksheet.Append(new SheetData());
|
||||||
Sheet sheet = new Sheet()
|
Sheet sheet = new Sheet()
|
||||||
{
|
{
|
||||||
Id = document.WorkbookPart.GetIdOfPart(worksheetPart),
|
Id = document.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
@ -204,24 +205,23 @@ namespace AIProofread.core
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateRow(sheetData, item, ref rowIndex);
|
CreateRow(sheetData, item, ref rowIndex);
|
||||||
}catch(Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(ex.Message);
|
Logger.Error("导出勘误表异常:" + ex.Message, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 美化sheet
|
|
||||||
StyleSheet(worksheetPart);
|
|
||||||
// 筛选
|
// 筛选
|
||||||
worksheetPart.Worksheet.Append(new AutoFilter { Reference = "A1:G1" });
|
worksheetPart.Worksheet.Append(new AutoFilter { Reference = "A1:G1" });
|
||||||
//sheet.Append(new AutoFilter() { Reference = "A1:G1"});
|
//sheet.Append(new AutoFilter() { Reference = "A1:G1"});
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Logger.Info("导出勘误表"+fileName+"完成,运行时间:" + stopwatch.Elapsed.TotalMilliseconds + "毫秒");
|
Logger.Info("导出勘误表" + fileName + "完成,运行时间:" + stopwatch.Elapsed.TotalMilliseconds + "毫秒");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StyleSheet(WorksheetPart worksheetPart)
|
private void StyleSheet(Worksheet worksheet)
|
||||||
{
|
{
|
||||||
// 设置列宽
|
// 设置列宽
|
||||||
Columns columns = new Columns();
|
Columns columns = new Columns();
|
||||||
@ -230,7 +230,7 @@ namespace AIProofread.core
|
|||||||
SetColumnWidth(4, 80, columns);
|
SetColumnWidth(4, 80, columns);
|
||||||
SetColumnWidth(5, 6, 20, columns);
|
SetColumnWidth(5, 6, 20, columns);
|
||||||
SetColumnWidth(7, 10, columns);
|
SetColumnWidth(7, 10, columns);
|
||||||
worksheetPart.Worksheet.InsertAt(columns, 1);
|
worksheet.Append(columns);
|
||||||
|
|
||||||
}
|
}
|
||||||
private void SetColumnWidth(uint colIndex, int width, Columns columns)
|
private void SetColumnWidth(uint colIndex, int width, Columns columns)
|
||||||
@ -348,9 +348,9 @@ namespace AIProofread.core
|
|||||||
var afterText = it.Start >= originSentence.Length ? null : originSentence.Substring(it.Start + richTextLength);
|
var afterText = it.Start >= originSentence.Length ? null : originSentence.Substring(it.Start + richTextLength);
|
||||||
|
|
||||||
var inlineString = new InlineString();
|
var inlineString = new InlineString();
|
||||||
AppendNormalTextToCell(beforeText, inlineString);
|
AppendRichTextToCell(beforeText, inlineString);
|
||||||
AppendRichTextToCell(richText, inlineString, "FF0000");
|
AppendRichTextToCell(richText, inlineString, "FFFF0000");
|
||||||
AppendNormalTextToCell(afterText, inlineString);
|
AppendRichTextToCell(afterText, inlineString);
|
||||||
cell.InlineString = inlineString;
|
cell.InlineString = inlineString;
|
||||||
row.AppendChild(cell);
|
row.AppendChild(cell);
|
||||||
}
|
}
|
||||||
@ -445,19 +445,23 @@ namespace AIProofread.core
|
|||||||
row.AppendChild(cell);
|
row.AppendChild(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppendNormalTextToCell(string text, InlineString inlineString)
|
private void AppendNormalTextToCell(string text, InlineString inlineString, string color = "FF000000", string fontName = "宋体")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(text)) return;
|
if (string.IsNullOrEmpty(text)) return;
|
||||||
|
var props = new RunProperties(
|
||||||
|
new FontSize() { Val = 11 }
|
||||||
|
);
|
||||||
|
if (color != "FF000000") props.Append(new Color() { Rgb = new HexBinaryValue(color) });
|
||||||
|
if (fontName != "宋体") props.Append(new RunFont() { Val = fontName });
|
||||||
var run = new Run(
|
var run = new Run(
|
||||||
new RunFont() { Val = "宋体" },
|
props,
|
||||||
new FontSize() { Val = 11 },
|
|
||||||
new Text(text) { Space = SpaceProcessingModeValues.Preserve }
|
new Text(text) { Space = SpaceProcessingModeValues.Preserve }
|
||||||
);
|
);
|
||||||
inlineString.Append(run);
|
inlineString.Append(run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppendRichTextToCell(string text, InlineString inlineString, string color = "000000", string fontName = "宋体")
|
private void AppendRichTextToCell(string text, InlineString inlineString, string color = "FF000000", string fontName = "宋体")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(text)) return;
|
if (string.IsNullOrEmpty(text)) return;
|
||||||
var props = new RunProperties(
|
var props = new RunProperties(
|
||||||
@ -466,7 +470,7 @@ namespace AIProofread.core
|
|||||||
if (color != "000000") props.Append(new Color() { Rgb = new HexBinaryValue(color) });
|
if (color != "000000") props.Append(new Color() { Rgb = new HexBinaryValue(color) });
|
||||||
if (fontName != "宋体") props.Append(new RunFont() { Val = fontName });
|
if (fontName != "宋体") props.Append(new RunFont() { Val = fontName });
|
||||||
var run = new Run(props, new Text(text) { Space = SpaceProcessingModeValues.Preserve });
|
var run = new Run(props, new Text(text) { Space = SpaceProcessingModeValues.Preserve });
|
||||||
inlineString.AppendChild(run);
|
inlineString.Append(run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
AIProofread/core/WebView2EventHandler.cs
Normal file
38
AIProofread/core/WebView2EventHandler.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.Web.WebView2.Core;
|
||||||
|
using Microsoft.Web.WebView2.WinForms;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace AIProofread.core
|
||||||
|
{
|
||||||
|
public class WebView2EventHandler
|
||||||
|
{
|
||||||
|
public static void WebView2NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.IsSuccess)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string errorPageHtml = @"
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>加载失败</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: sans-serif; text-align: center; padding-top: 50px; background-color: #f0f0f0; }
|
||||||
|
h1 { color: #d00; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>页面加载失败</h1>
|
||||||
|
<p>请检查您的网络连接或稍后再试。</p>
|
||||||
|
</body>
|
||||||
|
</html>";
|
||||||
|
if (e.NavigationId == 0)
|
||||||
|
{
|
||||||
|
(sender as WebView2).CoreWebView2.NavigateToString(errorPageHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user