Ver código fonte

Merge branch 'next' of gitee.com:zuohuaijun/Admin.NET into next

ccjungle 2 anos atrás
pai
commit
7ffab93715

+ 7 - 7
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -17,17 +17,17 @@
     <PackageReference Include="AngleSharp" Version="1.1.2" />
     <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
     <PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
-    <PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.15.6" />
-    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.5.12" />
-    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.5.12" />
-    <PackageReference Include="Furion.Pure" Version="4.9.5.12" />
+    <PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.15.8" />
+    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.5.13" />
+    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.5.13" />
+    <PackageReference Include="Furion.Pure" Version="4.9.5.13" />
     <PackageReference Include="Hashids.net" Version="1.7.0" />
     <PackageReference Include="IPTools.China" Version="1.6.0" />
     <PackageReference Include="IPTools.International" Version="1.6.0" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Pdf" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Word" Version="2.7.5.2" />
-    <PackageReference Include="MailKit" Version="4.7.1.1" />
+    <PackageReference Include="MailKit" Version="4.8.0" />
     <PackageReference Include="NewLife.Redis" Version="5.7.2024.801" />
     <PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
     <PackageReference Include="QRCoder" Version="1.6.0" />
@@ -35,11 +35,11 @@
     <PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.2" />
     <PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.5.0" />
-    <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.7.0" />
+    <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.8.0" />
     <PackageReference Include="SqlSugarCore" Version="5.1.4.169" />
     <PackageReference Include="SSH.NET" Version="2024.1.0" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />
-    <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1095" />
+    <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1100" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
   </ItemGroup>

+ 18 - 21
Admin.NET/Admin.NET.Core/Extension/EnumExtension.cs

@@ -31,7 +31,7 @@ public static class EnumExtension
             throw new ArgumentException("Type '" + enumType.Name + "' is not an enum.");
 
         // 查询缓存
-        var enumDic = EnumNameValueDict.ContainsKey(enumType) ? EnumNameValueDict[enumType] : new Dictionary<int, string>();
+        var enumDic = EnumNameValueDict.TryGetValue(enumType, out var value) ? value : new Dictionary<int, string>();
         if (enumDic.Count != 0)
             return enumDic;
         // 取枚举类型的Key/Value字典集合
@@ -57,7 +57,7 @@ public static class EnumExtension
         // 遍历字段数组获取key和name
         foreach (var enumField in enumFields)
         {
-            var intValue = (int)enumField.GetValue(enumType);
+            var intValue = (int)enumField.GetValue(enumType)!;
             enumDic[intValue] = enumField.Name;
         }
 
@@ -76,8 +76,8 @@ public static class EnumExtension
             throw new ArgumentException("Type '" + enumType.Name + "' is not an enum.");
 
         // 查询缓存
-        var enumDic = EnumDisplayValueDict.ContainsKey(enumType)
-            ? EnumDisplayValueDict[enumType]
+        var enumDic = EnumDisplayValueDict.TryGetValue(enumType, out var value)
+            ? value
             : new Dictionary<int, string>();
         if (enumDic.Count != 0)
             return enumDic;
@@ -105,7 +105,7 @@ public static class EnumExtension
         // 遍历字段数组获取key和name
         foreach (var enumField in enumFields)
         {
-            var intValue = (int)enumField.GetValue(enumType);
+            var intValue = (int)enumField.GetValue(enumType)!;
             var desc = enumField.GetDescriptionValue<DescriptionAttribute>();
             enumDic[intValue] = desc != null && !string.IsNullOrEmpty(desc.Description) ? desc.Description : enumField.Name;
         }
@@ -125,7 +125,7 @@ public static class EnumExtension
         _enumTypeDict ??= LoadEnumTypeDict(assembly);
 
         // 按名称查找
-        return _enumTypeDict.ContainsKey(typeName) ? _enumTypeDict[typeName] : null;
+        return _enumTypeDict.TryGetValue(typeName, out var value) ? value : null;
     }
 
     /// <summary>
@@ -149,10 +149,9 @@ public static class EnumExtension
     /// </summary>
     /// <param name="value"></param>
     /// <returns></returns>
-    public static string GetDescription(this System.Enum value)
+    public static string GetDescription(this Enum value)
     {
-        return value.GetType().GetMember(value.ToString()).FirstOrDefault()?.GetCustomAttribute<DescriptionAttribute>()
-            ?.Description;
+        return value.GetType().GetField(value.ToString())?.GetCustomAttribute<DescriptionAttribute>()?.Description;
     }
 
     /// <summary>
@@ -162,8 +161,7 @@ public static class EnumExtension
     /// <returns></returns>
     public static string GetDescription(this object value)
     {
-        return value.GetType().GetMember(value.ToString() ?? string.Empty).FirstOrDefault()
-            ?.GetCustomAttribute<DescriptionAttribute>()?.Description;
+        return value.GetType().GetField(value.ToString()!)?.GetCustomAttribute<DescriptionAttribute>()?.Description;
     }
 
     /// <summary>
@@ -173,8 +171,7 @@ public static class EnumExtension
     /// <returns></returns>
     public static string GetTheme(this object value)
     {
-        return value.GetType().GetMember(value.ToString() ?? string.Empty).FirstOrDefault()
-            ?.GetCustomAttribute<ThemeAttribute>()?.Theme;
+        return value.GetType().GetField(value.ToString()!)?.GetCustomAttribute<ThemeAttribute>()?.Theme;
     }
 
     /// <summary>
@@ -186,10 +183,10 @@ public static class EnumExtension
     {
         if (!type.IsEnum)
             throw new ArgumentException("Type '" + type.Name + "' is not an enum.");
-        var arr = System.Enum.GetNames(type);
+        var arr = Enum.GetNames(type);
         return arr.Select(sl =>
         {
-            var item = System.Enum.Parse(type, sl);
+            var item = Enum.Parse(type, sl);
             return new EnumEntity
             {
                 Name = item.ToString(),
@@ -210,8 +207,8 @@ public static class EnumExtension
     {
         if (!type.IsEnum)
             throw new ArgumentException("Type '" + type.Name + "' is not an enum.");
-        var arr = System.Enum.GetNames(type);
-        return arr.Select(name => (T)System.Enum.Parse(type, name)).ToList();
+        var arr = Enum.GetNames(type);
+        return arr.Select(name => (T)Enum.Parse(type, name)).ToList();
     }
 }
 
@@ -223,20 +220,20 @@ public class EnumEntity
     /// <summary>
     /// 枚举的描述
     /// </summary>
-    public string Describe { set; get; }
+    public string Describe { get; set; }
 
     /// <summary>
     /// 枚举的样式
     /// </summary>
-    public string Theme { set; get; }
+    public string Theme { get; set; }
 
     /// <summary>
     /// 枚举名称
     /// </summary>
-    public string Name { set; get; }
+    public string Name { get; set; }
 
     /// <summary>
     /// 枚举对象的值
     /// </summary>
-    public int Value { set; get; }
+    public int Value { get; set; }
 }

+ 29 - 1
Admin.NET/Admin.NET.Web.Core/Startup.cs

@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.HttpOverrides;
+using Microsoft.AspNetCore.ResponseCompression;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Newtonsoft.Json;
@@ -25,7 +26,7 @@ using OnceMi.AspNetCore.OSS;
 using SixLabors.ImageSharp.Web.DependencyInjection;
 using System;
 using System.Threading.Tasks;
-
+using System.Linq;
 namespace Admin.NET.Web.Core;
 
 public class Startup : AppStartup
@@ -201,10 +202,37 @@ public class Startup : AppStartup
         // 设置默认查询器China和International
         //IpToolSettings.DefalutSearcherType = IpSearcherType.China;
         IpToolSettings.DefalutSearcherType = IpSearcherType.International;
+        // 第一步: 配置gzip与br的压缩等级为最优
+        //services.Configure<BrotliCompressionProviderOptions>(options =>
+        //{
+        //    options.Level = CompressionLevel.Optimal;
+        //});
+        //services.Configure<GzipCompressionProviderOptions>(options =>
+        //{
+        //    options.Level = CompressionLevel.Optimal;
+        //});
+        //注册压缩响应
+        services.AddResponseCompression((options) =>
+        {
+            options.EnableForHttps = true;
+            options.Providers.Add<BrotliCompressionProvider>();
+            options.Providers.Add<GzipCompressionProvider>();
+            // 指定压缩的大小阈值,这里设置为1024字节
+            // 扩展一些类型 (MimeTypes中有一些基本的类型,可以打断点看看)
+            options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
+            {
+                    "text/html; charset=utf-8",
+                    "application/xhtml+xml",
+                    "application/atom+xml",
+                    "image/svg+xml"
+             });
+        });
     }
 
     public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
     {
+        // 响应压缩
+        app.UseResponseCompression();
         app.UseForwardedHeaders();
 
         if (env.IsDevelopment())

+ 10 - 10
Web/package.json

@@ -2,7 +2,7 @@
 	"name": "admin.net",
 	"type": "module",
 	"version": "2.4.33",
-	"lastBuildTime": "2024.09.26",
+	"lastBuildTime": "2024.10.03",
 	"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
 	"author": "zuohuaijun",
 	"license": "MIT",
@@ -32,7 +32,7 @@
 		"echarts": "^5.5.1",
 		"echarts-gl": "^2.0.9",
 		"echarts-wordcloud": "^2.1.0",
-		"element-plus": "^2.8.3",
+		"element-plus": "^2.8.4",
 		"ezuikit-js": "^8.0.12-alpha.3",
 		"js-cookie": "^3.0.5",
 		"js-table2excel": "^1.1.2",
@@ -43,7 +43,7 @@
 		"monaco-editor": "^0.52.0",
 		"mqtt": "^4.3.8",
 		"nprogress": "^0.2.0",
-		"pinia": "^2.2.2",
+		"pinia": "^2.2.4",
 		"print-js": "^1.6.0",
 		"push.js": "^1.0.12",
 		"qrcodejs2-fixes": "^0.0.2",
@@ -55,7 +55,7 @@
 		"splitpanes": "^3.1.5",
 		"vcrontab-3": "^3.3.22",
 		"vform3-builds": "^3.0.10",
-		"vue": "^3.5.8",
+		"vue": "^3.5.10",
 		"vue-clipboard3": "^2.0.0",
 		"vue-demi": "^0.14.6",
 		"vue-draggable-plus": "^0.5.3",
@@ -74,20 +74,20 @@
 		"@types/node": "^20.14.15",
 		"@types/nprogress": "^0.2.3",
 		"@types/sortablejs": "^1.15.8",
-		"@typescript-eslint/eslint-plugin": "^8.7.0",
-		"@typescript-eslint/parser": "^8.7.0",
+		"@typescript-eslint/eslint-plugin": "^8.8.0",
+		"@typescript-eslint/parser": "^8.8.0",
 		"@vitejs/plugin-vue": "^5.1.4",
 		"@vitejs/plugin-vue-jsx": "^4.0.1",
-		"@vue/compiler-sfc": "^3.5.8",
+		"@vue/compiler-sfc": "^3.5.10",
 		"code-inspector-plugin": "^0.16.1",
 		"eslint": "^9.11.1",
 		"eslint-plugin-vue": "^9.28.0",
-		"globals": "^15.9.0",
+		"globals": "^15.10.0",
 		"less": "^4.2.0",
 		"prettier": "^3.3.3",
 		"rollup-plugin-visualizer": "^5.12.0",
-		"sass": "^1.79.3",
-		"terser": "^5.33.0",
+		"sass": "^1.79.4",
+		"terser": "^5.34.1",
 		"typescript": "^5.6.2",
 		"vite": "^5.4.8",
 		"vite-plugin-cdn-import": "^1.0.1",