feat: 加载网页时,自动带上版本

This commit is contained in:
LittleBoy 2025-04-08 09:24:26 +08:00
parent 37d21446ec
commit ddf2c5c7e8
5 changed files with 25 additions and 5 deletions

Binary file not shown.

View File

@ -52,7 +52,7 @@ namespace AIProofread
/// <summary> /// <summary>
/// 网页访问地址 /// 网页访问地址
/// </summary> /// </summary>
public static string WEB_PATH = AppServer.GM_FN; //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 bool RUN_IN_DEBUG = true;
public static AppEnvironment APP_ENV = AppEnvironment.Dev; public static AppEnvironment APP_ENV = AppEnvironment.Dev;
#else #else
@ -103,7 +103,7 @@ namespace AIProofread
/// <returns></returns> /// <returns></returns>
public static string WebPath(string path) public static string WebPath(string path)
{ {
return WEB_PATH + path; return WEB_PATH + path + (path.IndexOf("?") == -1 ? "?" : "&") + "version=" + APP_VERSION;
} }
} }
} }

View File

@ -29,6 +29,7 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.WebView = new Microsoft.Web.WebView2.WinForms.WebView2(); this.WebView = new Microsoft.Web.WebView2.WinForms.WebView2();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.WebView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.WebView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -44,23 +45,36 @@
this.WebView.TabIndex = 0; this.WebView.TabIndex = 0;
this.WebView.ZoomFactor = 1D; this.WebView.ZoomFactor = 1D;
// //
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(380, 219);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 1;
this.label1.Text = "校对王";
this.label1.Visible = false;
//
// FormWebView // FormWebView
// //
this.AllowDrop = true; this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.label1);
this.Controls.Add(this.WebView); this.Controls.Add(this.WebView);
this.Name = "FormWebView"; this.Name = "FormWebView";
this.ShowIcon = false; this.ShowIcon = false;
this.Load += new System.EventHandler(this.FormWebView_Load); this.Load += new System.EventHandler(this.FormWebView_Load);
((System.ComponentModel.ISupportInitialize)(this.WebView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.WebView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private Microsoft.Web.WebView2.WinForms.WebView2 WebView; private Microsoft.Web.WebView2.WinForms.WebView2 WebView;
private System.Windows.Forms.Label label1;
} }
} }

View File

@ -16,10 +16,16 @@ namespace AIProofread.Controls
public partial class FormWebView : BaseWinForm public partial class FormWebView : BaseWinForm
{ {
public string WebUrl { get; set; } public string WebUrl { get; set; }
private double dpiScaleFactor;
public FormWebView(string url,int width,int height) public FormWebView(string url,int width,int height)
{ {
InitializeComponent(); InitializeComponent();
this.WebUrl = url; this.WebUrl = url;
this.dpiScaleFactor = this.label1.Width / 42.0; // 设置的宽度为42实际渲染宽度 / 42 即为缩放比例
Screen screen = Screen.FromControl(this);
this.SetSize(width, height); this.SetSize(width, height);
this.StartPosition = FormStartPosition.CenterScreen; this.StartPosition = FormStartPosition.CenterScreen;
} }
@ -31,8 +37,8 @@ namespace AIProofread.Controls
public void SetSize(int width, int height) public void SetSize(int width, int height)
{ {
this.Width = width; this.Width = (int)(width * dpiScaleFactor);
this.Height = height; this.Height = (int)(height * dpiScaleFactor);
} }
private void FormWebView_Load(object sender, EventArgs e) private void FormWebView_Load(object sender, EventArgs e)

View File

@ -97,7 +97,7 @@ namespace AIProofread
{ {
if (fromStockQuery == null || fromStockQuery.IsDisposed) if (fromStockQuery == null || fromStockQuery.IsDisposed)
{ {
fromStockQuery = new FormWebView(Config.WebPath("stock-query"),500,400); fromStockQuery = new FormWebView(Config.WebPath("stock-query?app_v=101"),500 ,400);
} }
fromStockQuery.Show(); fromStockQuery.Show();
// 显示在最前面 // 显示在最前面