插件升级信息
This commit is contained in:
parent
79d9e215b6
commit
7a48856b1b
Binary file not shown.
@ -43,6 +43,11 @@ namespace AIProofread
|
||||
|
||||
private static int selectProofreadId = -1;
|
||||
|
||||
public string GetAppVersion()
|
||||
{
|
||||
return Config.APP_VERSION;
|
||||
}
|
||||
|
||||
public void showDialog(string message)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(message);
|
||||
@ -129,6 +134,16 @@ namespace AIProofread
|
||||
return Tools.GetJSONString(data);
|
||||
}
|
||||
|
||||
public void ShowUpgrade(string data)
|
||||
{
|
||||
var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data);
|
||||
var ret = System.Windows.Forms.MessageBox.Show(upgradeData.Message,"更新提示",System.Windows.Forms.MessageBoxButtons.YesNo,System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if(ret == System.Windows.Forms.DialogResult.Yes)
|
||||
{
|
||||
OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public void noticeOtherWeb(string json, string targetWebName)
|
||||
{
|
||||
if (targetWebName != null)
|
||||
|
@ -6,11 +6,12 @@ namespace AIProofread
|
||||
public class Config
|
||||
{
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "1.0.0";
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// 网页访问地址
|
||||
/// </summary>
|
||||
public static readonly string WEB_PATH = "https://gm-plugin.gachafun.com/";
|
||||
public static readonly string WEB_PATH = "http://192.168.10.100:5173/";
|
||||
#else
|
||||
public static readonly string WEB_PATH = "https://gm-plugin.gachafun.com/";
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ namespace AIProofread.Controls
|
||||
|
||||
private void ProofreadMainControl_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.web.Source = new Uri(Config.WebPath("#home"));
|
||||
this.web.Source = new Uri(Config.WebPath("#home?version=" + Config.APP_VERSION));
|
||||
}
|
||||
|
||||
}
|
||||
|
2
AIProofread/Ribbon1.Designer.cs
generated
2
AIProofread/Ribbon1.Designer.cs
generated
@ -63,7 +63,6 @@
|
||||
//
|
||||
// tabAIProofread
|
||||
//
|
||||
this.tabAIProofread.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
|
||||
this.tabAIProofread.Groups.Add(this.group1);
|
||||
this.tabAIProofread.Groups.Add(this.group3);
|
||||
this.tabAIProofread.Groups.Add(this.group2);
|
||||
@ -72,6 +71,7 @@
|
||||
this.tabAIProofread.Groups.Add(this.gpLogout);
|
||||
this.tabAIProofread.Label = "AI校对王";
|
||||
this.tabAIProofread.Name = "tabAIProofread";
|
||||
this.tabAIProofread.Position = this.Factory.RibbonPosition.AfterOfficeId("TabHelp");
|
||||
//
|
||||
// group1
|
||||
//
|
||||
|
@ -82,7 +82,8 @@ namespace AIProofread
|
||||
|
||||
private void BtnUpdate_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("当前插件是最新版本");
|
||||
//System.Windows.Forms.MessageBox.Show("当前插件是最新版本");
|
||||
Globals.ThisAddIn.SendMessageToWeb("upgrade",Config.APP_VERSION);
|
||||
}
|
||||
|
||||
private void BtnProofreadAll_Click(object sender, RibbonControlEventArgs e)
|
||||
|
@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
||||
using UtilLib;
|
||||
using System.Threading;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System.Linq;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -31,7 +32,6 @@ namespace AIProofread
|
||||
/// 校对面板
|
||||
/// </summary>
|
||||
public ProofreadMainControl proofreadPanel;
|
||||
public CustomTaskPane customTaskPane;
|
||||
/// <summary>
|
||||
/// 工具栏
|
||||
/// </summary>
|
||||
@ -41,20 +41,99 @@ namespace AIProofread
|
||||
|
||||
public List<FormLogin> LoginFormList = new List<FormLogin>();
|
||||
|
||||
public Dictionary<Word.Document, CustomTaskPane> taskPanels = new Dictionary<Word.Document, CustomTaskPane>();
|
||||
private CustomTaskPane customTaskPane;
|
||||
|
||||
|
||||
private void Application_WindowDeactivate(Word.Document Doc, Window Wn)
|
||||
{
|
||||
//HidePanel(Doc);
|
||||
}
|
||||
|
||||
private void Application_WindowActivate(Word.Document Doc, Window Wn)
|
||||
{
|
||||
//ShowPanel(Doc);
|
||||
|
||||
if (!taskPanels.ContainsKey(Doc))
|
||||
{
|
||||
ShowPanel(Doc);
|
||||
}
|
||||
HideOtherPanel(Doc);
|
||||
}
|
||||
|
||||
private void Application_DocumentBeforeClose(Word.Document Doc, ref bool Cancel)
|
||||
{
|
||||
DisposePanel(Doc);
|
||||
}
|
||||
|
||||
private void Application_NewDocument(Word.Document Doc)
|
||||
{
|
||||
ShowPanel(Doc);
|
||||
}
|
||||
|
||||
private void Application_DocumentOpen(Word.Document Doc)
|
||||
{
|
||||
ShowPanel(Doc);
|
||||
}
|
||||
void DisposePanel(Word.Document doc)
|
||||
{
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
taskPanels[doc].Visible = false;
|
||||
taskPanels[doc].Dispose();
|
||||
taskPanels.Remove(doc);
|
||||
}
|
||||
}
|
||||
|
||||
void HideOtherPanel(Word.Document doc)
|
||||
{
|
||||
if (taskPanels.ContainsKey(doc) && taskPanels[doc].Visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var key in taskPanels.Keys)
|
||||
{
|
||||
taskPanels[key].Visible = doc == key;
|
||||
}
|
||||
}
|
||||
|
||||
void HidePanel(Word.Document doc)
|
||||
{
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
taskPanels[doc].Visible = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// word创建面板
|
||||
/// </summary>
|
||||
private void CreateCustomTaskPane()
|
||||
private CustomTaskPane ShowPanel(Word.Document doc)
|
||||
{
|
||||
proofreadPanel = new ProofreadMainControl();
|
||||
customTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(proofreadPanel, AddinName);
|
||||
customTaskPane.Width = MinWidth;
|
||||
customTaskPane.Visible = false;
|
||||
//proofreadPanel.SizeChanged += ProofreadPanel_SizeChanged;
|
||||
//customTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
|
||||
//if (!IsWPS)
|
||||
//{
|
||||
// if (Application.ActiveDocument == null) return;
|
||||
// if (doc == null) doc = Application.ActiveDocument;
|
||||
//}
|
||||
if (Application.ActiveDocument == null) return null;
|
||||
if (doc == null) doc = Application.ActiveDocument;
|
||||
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
taskPanels[doc].Visible = true;
|
||||
return taskPanels[doc];
|
||||
}
|
||||
|
||||
public void Send(SendOrPostCallback d) {
|
||||
//proofreadPanel = new ProofreadMainControl();
|
||||
var panel = Globals.ThisAddIn.CustomTaskPanes.Add(new ProofreadMainControl(), AddinName);
|
||||
this.customTaskPane = panel;
|
||||
taskPanels.Add(doc, panel);
|
||||
panel.Width = MinWidth;
|
||||
panel.Visible = !IsWPS;
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void Send(SendOrPostCallback d)
|
||||
{
|
||||
FmainThreadContext.Send(d, null);
|
||||
}
|
||||
|
||||
@ -71,17 +150,25 @@ namespace AIProofread
|
||||
private void ThisAddIn_Startup(object sender, System.EventArgs e)
|
||||
{
|
||||
FmainThreadContext = SynchronizationContext.Current;
|
||||
//Module1.CreateCTP();
|
||||
// 启动地址
|
||||
applicationStartupPath = System.Windows.Forms.Application.StartupPath;
|
||||
if (applicationStartupPath.Contains("WPS"))
|
||||
{
|
||||
IsWPS = true;
|
||||
}
|
||||
CreateCustomTaskPane();
|
||||
// 处理文档事件
|
||||
Application.DocumentOpen += Application_DocumentOpen;
|
||||
Application.DocumentBeforeClose += Application_DocumentBeforeClose;
|
||||
Application.WindowActivate += Application_WindowActivate;
|
||||
Application.WindowDeactivate += Application_WindowDeactivate;
|
||||
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
||||
// 选区发生变化事件
|
||||
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void Application_WindowSelectionChange(Word.Selection s)
|
||||
{
|
||||
if (s.Bookmarks != null)
|
||||
@ -106,19 +193,14 @@ namespace AIProofread
|
||||
Bridge.bridge.SelectMarkById(-1);
|
||||
}
|
||||
|
||||
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
|
||||
{
|
||||
// PanelModule.DisposeCTP();
|
||||
this.proofreadPanel.Dispose();
|
||||
this.customTaskPane.Dispose();
|
||||
this.customTaskPane = null;
|
||||
}
|
||||
public int MyProperty { get; set; }
|
||||
|
||||
public void SendMessageToWeb(string msg, object data)
|
||||
{
|
||||
this.ShowPanel();
|
||||
var panel = this.ShowPanel(Application.ActiveDocument);
|
||||
var json = JsonConvert.SerializeObject(new WebMessage(msg, data));
|
||||
this.proofreadPanel.web.CoreWebView2.PostWebMessageAsJson(json);
|
||||
var control = (ProofreadMainControl)panel.Control;
|
||||
control.web.CoreWebView2.PostWebMessageAsJson(json);
|
||||
}
|
||||
|
||||
// 显示面板
|
||||
@ -143,6 +225,30 @@ namespace AIProofread
|
||||
frm.Show();
|
||||
}
|
||||
|
||||
void ClearPanels()
|
||||
{
|
||||
taskPanels.Values.ToList().ForEach(p =>
|
||||
{
|
||||
try
|
||||
{
|
||||
p.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
|
||||
Logger.Log(ex.Message + "\n" + ex.StackTrace);
|
||||
}
|
||||
});
|
||||
taskPanels.Clear();
|
||||
}
|
||||
|
||||
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
|
||||
{
|
||||
// PanelModule.DisposeCTP();
|
||||
//this.proofreadPanel.Dispose();
|
||||
ClearPanels();
|
||||
}
|
||||
|
||||
#region VSTO generated code
|
||||
|
||||
/// <summary>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
47
util-lib/UpgradeData.cs
Normal file
47
util-lib/UpgradeData.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace UtilLib
|
||||
{
|
||||
public class UpgradeData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// APP名称
|
||||
/// </summary>
|
||||
public string AppName { get; set; }
|
||||
/// <summary>
|
||||
/// 客户端类型 1ios 2安卓 3window插件 4 5
|
||||
/// </summary>
|
||||
public int ClientType { get; set; }
|
||||
/// <summary>
|
||||
/// 发布类型
|
||||
/// </summary>
|
||||
public int PublishType { get; set; }
|
||||
/// <summary>
|
||||
/// 发布的版本号
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
/// <summary>
|
||||
/// 升级类型(1强制升级 2强制提示 3弱提示)
|
||||
/// </summary>
|
||||
public int UpgradeType { get; set; }
|
||||
public string DownloadUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 发布时间
|
||||
/// </summary>
|
||||
public int PublishTime { get; set; }
|
||||
/// <summary>
|
||||
/// 发布的信息
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
public int CompatibleVersionId { get; set; }
|
||||
public int IsShowPop { get; set; }
|
||||
|
||||
public bool NeedUpgrade(string currentVersion)
|
||||
{
|
||||
var remoteVer = new Version(Version);
|
||||
var currentVer = new Version(currentVersion);
|
||||
return remoteVer > currentVer;
|
||||
}
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@
|
||||
<Compile Include="CorrectedContent.cs" />
|
||||
<Compile Include="DocumentCorrectItem.cs" />
|
||||
<Compile Include="ProofreadType.cs" />
|
||||
<Compile Include="UpgradeData.cs" />
|
||||
<Compile Include="Userinfo.cs" />
|
||||
<Compile Include="UtilLib.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user