diff --git a/YLErpWeb/Common/HtmlUtil.cs b/YLErpWeb/Common/HtmlUtil.cs index cc3e6247..1292f24e 100644 --- a/YLErpWeb/Common/HtmlUtil.cs +++ b/YLErpWeb/Common/HtmlUtil.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Html; -using System.Collections; +using System.Reflection; using YLErp.Events; namespace YLErp @@ -17,6 +17,12 @@ namespace YLErp //bin目录文件版本 public static readonly DateTime BinFileVersion; + /// + /// Git提交哈希(取自程序集 AssemblyInformationalVersion,由.NET SDK在编译时自动生成, + /// 格式 "1.0.0+<sha>";前端诊断信息用它精确定位是哪次提交的部署)。 + /// + public static readonly string GitCommit; + static long _dataCacheUpdateTime; static HtmlUtil() @@ -27,6 +33,13 @@ namespace YLErp BinFileVersion = files.Any() ? files.Max(n => n.LastWriteTime) : DateTime.MinValue; JsVersion = BinFileVersion.ToString("yyMMddHHmmss"); + //从 AssemblyInformationalVersion 读取 git sha(SDK 编译时已嵌入,零额外依赖) + var infoVer = typeof(HtmlUtil).Assembly + .GetCustomAttribute()?.InformationalVersion; + //格式 "1.0.0+",取 + 之后部分;无则回退到完整字符串 + GitCommit = string.IsNullOrEmpty(infoVer) ? "unknown" + : (infoVer.Contains('+') ? infoVer.Substring(infoVer.LastIndexOf('+') + 1) : infoVer); + EventBus.Subscribe(t => { _dataCacheUpdateTime = DateTimeOffset.Now.ToUnixTimeSeconds(); diff --git a/YLErpWeb/Views/Shared/_MainLayout.cshtml b/YLErpWeb/Views/Shared/_MainLayout.cshtml index 07b5b054..59716859 100644 --- a/YLErpWeb/Views/Shared/_MainLayout.cshtml +++ b/YLErpWeb/Views/Shared/_MainLayout.cshtml @@ -157,6 +157,18 @@