diff --git a/aspnet-core/modules/NotificationManagement/src/CompanyName.ProjectName.NotificationManagement.Application/NotificationManagementApplicationModule.cs b/aspnet-core/modules/NotificationManagement/src/CompanyName.ProjectName.NotificationManagement.Application/NotificationManagementApplicationModule.cs index c89e5fcb..fca79604 100644 --- a/aspnet-core/modules/NotificationManagement/src/CompanyName.ProjectName.NotificationManagement.Application/NotificationManagementApplicationModule.cs +++ b/aspnet-core/modules/NotificationManagement/src/CompanyName.ProjectName.NotificationManagement.Application/NotificationManagementApplicationModule.cs @@ -1,8 +1,10 @@ +using System; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.Application; using Microsoft.Extensions.Configuration; +using Volo.Abp; using Volo.Abp.AspNetCore.SignalR; namespace CompanyName.ProjectName.NotificationManagement @@ -13,33 +15,46 @@ namespace CompanyName.ProjectName.NotificationManagement typeof(AbpDddApplicationModule), typeof(AbpAutoMapperModule), typeof(AbpAspNetCoreSignalRModule) - )] + )] public class NotificationManagementApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + Configure(options => { options.AddMaps(validate: true); }); ConfigurationSignalR(context); } - + private void ConfigurationSignalR(ServiceConfigurationContext context) { - var redisConnectionString = - context.Services.GetConfiguration().GetSection("Cache:Redis:ConnectionString").Value; - var redisDatabaseId = context.Services.GetConfiguration().GetValue("Cache:Redis:DatabaseId"); - var password = context.Services.GetConfiguration().GetValue("Cache:Redis:Password"); + var redisConnection = context.Services.GetConfiguration()["Redis:Configuration"]; + var redisConnectionStringList = redisConnection.Split(',', StringSplitOptions.RemoveEmptyEntries); + if (redisConnectionStringList == null || redisConnectionStringList.Length == 0) + { + throw new UserFriendlyException(message: "Redis连接字符串配置异常"); + } + + var password = string.Empty; + if (redisConnection.Contains("password")) + { + password = redisConnectionStringList[1].Split('=')[1]; + } + + var redisDatabaseId = 0; + if (redisConnection.Contains("defaultdatabase")) + { + redisDatabaseId = Convert.ToInt32(redisConnectionStringList[2].Split('=')[1]); + } + + context.Services.AddSignalR().AddStackExchangeRedis(options => { options.Configuration.ChannelPrefix = "CompanyName.ProjectName"; options.Configuration.DefaultDatabase = redisDatabaseId; options.Configuration.Password = password; - options.Configuration.EndPoints.Add(redisConnectionString); + options.Configuration.EndPoints.Add(redisConnectionStringList[0]); }); } } -} +} \ No newline at end of file diff --git a/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs b/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs index 7c148f4f..16221505 100644 --- a/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs +++ b/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs @@ -42,6 +42,7 @@ using Serilog; using Swashbuckle.AspNetCore.SwaggerUI; using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.Caching; namespace CompanyName.ProjectName { @@ -236,13 +237,9 @@ namespace CompanyName.ProjectName /// private void ConfigureCache(ServiceConfigurationContext context) { - var redisConnectionString = - context.Services.GetConfiguration().GetValue("Cache:Redis:ConnectionString"); - var redisDatabaseId = context.Services.GetConfiguration().GetValue("Cache:Redis:DatabaseId"); - var password = context.Services.GetConfiguration().GetValue("Cache:Redis:Password"); - var connectString = $"{redisConnectionString},password={password},defaultdatabase={redisDatabaseId}"; - var redis = ConnectionMultiplexer.Connect(connectString); - context.Services.AddStackExchangeRedisCache(options => { options.Configuration = connectString; }); + Configure(options => { options.KeyPrefix = "ProjectName:"; }); + var configuration = context.Services.GetConfiguration(); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); context.Services .AddDataProtection() .PersistKeysToStackExchangeRedis(redis, "ProjectName-Protection-Keys"); diff --git a/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/appsettings.Development.json index 29ae496c..8690b060 100644 --- a/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/host/CompanyName.ProjectName.HttpApi.Host/appsettings.Development.json @@ -17,12 +17,8 @@ "ConnectionStrings": { "Default": "Data Source=localhost;Database=CompanyNameProjectNameDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" }, - "Cache": { - "Redis": { - "ConnectionString": "localhost", - "Password": "mypassword", - "DatabaseId": 0 - } + "Redis": { + "Configuration": "localhost,password=mypassword,defaultdatabase=1" }, "Jwt": { "Audience": "CompanyNameProjectName", diff --git a/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/ProjectNameIdentityServerModule.cs b/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/ProjectNameIdentityServerModule.cs index 0a5aa425..6af8c091 100644 --- a/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/ProjectNameIdentityServerModule.cs +++ b/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/ProjectNameIdentityServerModule.cs @@ -173,13 +173,9 @@ namespace CompanyName.ProjectName /// private void ConfigureCache(ServiceConfigurationContext context) { - var redisConnectionString = - context.Services.GetConfiguration().GetValue("Cache:Redis:ConnectionString"); - var redisDatabaseId = context.Services.GetConfiguration().GetValue("Cache:Redis:DatabaseId"); - var password = context.Services.GetConfiguration().GetValue("Cache:Redis:Password"); - var connectString = $"{redisConnectionString},password={password},defaultdatabase={redisDatabaseId}"; - var redis = ConnectionMultiplexer.Connect(connectString); - context.Services.AddStackExchangeRedisCache(options => { options.Configuration = connectString; }); + Configure(options => { options.KeyPrefix = "ProjectName:"; }); + var configuration = context.Services.GetConfiguration(); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); context.Services .AddDataProtection() .PersistKeysToStackExchangeRedis(redis, "ProjectName-Protection-Keys"); diff --git a/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/appsettings.Development.json b/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/appsettings.Development.json index 038c2b51..03748433 100644 --- a/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/appsettings.Development.json +++ b/aspnet-core/services/host/CompanyName.ProjectName.IdentityServer/appsettings.Development.json @@ -8,12 +8,8 @@ "ConnectionStrings": { "Default": "Data Source=localhost;Database=CompanyNameProjectNameDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" }, - "Cache": { - "Redis": { - "ConnectionString": "localhost", - "Password": "mypassword", - "DatabaseId": 0 - } + "Redis": { + "Configuration": "localhost,password=mypassword,defaultdatabase=1" } } diff --git a/vben271/package.json b/vben271/package.json index 4d6f4e5a..2ea95473 100644 --- a/vben271/package.json +++ b/vben271/package.json @@ -118,7 +118,7 @@ "ts-jest": "^27.0.4", "ts-node": "^10.2.0", "typescript": "4.3.5", - "vite": "2.5.0", + "vite": "2.5.9", "vite-plugin-compression": "^0.3.3", "vite-plugin-html": "^2.0.7", "vite-plugin-imagemin": "^0.4.3", @@ -149,4 +149,4 @@ "engines": { "node": "^12 || >=14" } -} +} \ No newline at end of file