diff --git a/CoreCms.Net.Auth/CoreCms.Net.Auth.csproj b/CoreCms.Net.Auth/CoreCms.Net.Auth.csproj index 1133bd1..a2714b3 100644 --- a/CoreCms.Net.Auth/CoreCms.Net.Auth.csproj +++ b/CoreCms.Net.Auth/CoreCms.Net.Auth.csproj @@ -1,12 +1,12 @@ - net5.0 + net7.0 - - + + diff --git a/CoreCms.Net.Caching/CoreCms.Net.Caching.csproj b/CoreCms.Net.Caching/CoreCms.Net.Caching.csproj index 7bf66bc..3ee8f40 100644 --- a/CoreCms.Net.Caching/CoreCms.Net.Caching.csproj +++ b/CoreCms.Net.Caching/CoreCms.Net.Caching.csproj @@ -1,13 +1,13 @@ - net5.0 + net7.0 - - - + + + diff --git a/CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj b/CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj index b25e41a..319344c 100644 --- a/CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj +++ b/CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 @@ -18,8 +18,8 @@ - - + + diff --git a/CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj b/CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj index 9119699..07fa296 100644 --- a/CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj +++ b/CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj @@ -1,13 +1,13 @@ - net5.0 + net7.0 - - - + + + diff --git a/CoreCms.Net.Core/CoreCms.Net.Core.csproj b/CoreCms.Net.Core/CoreCms.Net.Core.csproj index 292b649..4940170 100644 --- a/CoreCms.Net.Core/CoreCms.Net.Core.csproj +++ b/CoreCms.Net.Core/CoreCms.Net.Core.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 @@ -11,23 +11,23 @@ - - - - - - + + + + + + - - - - - + + + + + - - - + + + diff --git a/CoreCms.Net.Filter/CoreCms.Net.Filter.csproj b/CoreCms.Net.Filter/CoreCms.Net.Filter.csproj index 1e095c3..9cfd70c 100644 --- a/CoreCms.Net.Filter/CoreCms.Net.Filter.csproj +++ b/CoreCms.Net.Filter/CoreCms.Net.Filter.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 diff --git a/CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj b/CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj index 8ada3c3..f8a9b45 100644 --- a/CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj +++ b/CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 diff --git a/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj b/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj index d54c78d..89f6644 100644 --- a/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj +++ b/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj @@ -1,11 +1,11 @@ - net5.0 + net7.0 - + diff --git a/CoreCms.Net.Loging/CoreCms.Net.Loging.csproj b/CoreCms.Net.Loging/CoreCms.Net.Loging.csproj index 077f54c..1b2dd89 100644 --- a/CoreCms.Net.Loging/CoreCms.Net.Loging.csproj +++ b/CoreCms.Net.Loging/CoreCms.Net.Loging.csproj @@ -1,13 +1,13 @@ - net5.0 + net7.0 - - - + + + diff --git a/CoreCms.Net.Mapping/CoreCms.Net.Mapping.csproj b/CoreCms.Net.Mapping/CoreCms.Net.Mapping.csproj index e08eff1..3dd0f38 100644 --- a/CoreCms.Net.Mapping/CoreCms.Net.Mapping.csproj +++ b/CoreCms.Net.Mapping/CoreCms.Net.Mapping.csproj @@ -1,12 +1,12 @@ - net5.0 + net7.0 - - + + diff --git a/CoreCms.Net.Middlewares/CoreCms.Net.Middlewares.csproj b/CoreCms.Net.Middlewares/CoreCms.Net.Middlewares.csproj index f5f7101..c9d9a9a 100644 --- a/CoreCms.Net.Middlewares/CoreCms.Net.Middlewares.csproj +++ b/CoreCms.Net.Middlewares/CoreCms.Net.Middlewares.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.csproj b/CoreCms.Net.Model/CoreCms.Net.Model.csproj index a246a82..d8adee1 100644 --- a/CoreCms.Net.Model/CoreCms.Net.Model.csproj +++ b/CoreCms.Net.Model/CoreCms.Net.Model.csproj @@ -1,11 +1,11 @@ - net5.0 + net7.0 - + diff --git a/CoreCms.Net.RedisMQ/CoreCms.Net.RedisMQ.csproj b/CoreCms.Net.RedisMQ/CoreCms.Net.RedisMQ.csproj index cd08989..db07aea 100644 --- a/CoreCms.Net.RedisMQ/CoreCms.Net.RedisMQ.csproj +++ b/CoreCms.Net.RedisMQ/CoreCms.Net.RedisMQ.csproj @@ -1,14 +1,14 @@ - net5.0 + net7.0 - - + + - + diff --git a/CoreCms.Net.Repository/CoreCms.Net.Repository.csproj b/CoreCms.Net.Repository/CoreCms.Net.Repository.csproj index 5ed53be..1485bbc 100644 --- a/CoreCms.Net.Repository/CoreCms.Net.Repository.csproj +++ b/CoreCms.Net.Repository/CoreCms.Net.Repository.csproj @@ -1,13 +1,13 @@ - net5.0 + net7.0 - - - + + + diff --git a/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs b/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs index bbd7c94..3ebd0b8 100644 --- a/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs +++ b/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs @@ -24,7 +24,6 @@ using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Model.ViewModels.DTO; using CoreCms.Net.Utility.Helper; using Flurl.Http; -using Google.Protobuf.WellKnownTypes; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Newtonsoft.Json; diff --git a/CoreCms.Net.Services/CoreCms.Net.Services.csproj b/CoreCms.Net.Services/CoreCms.Net.Services.csproj index 60d9e97..aa24a83 100644 --- a/CoreCms.Net.Services/CoreCms.Net.Services.csproj +++ b/CoreCms.Net.Services/CoreCms.Net.Services.csproj @@ -1,21 +1,21 @@ - net5.0 + net7.0 - - + + - - + + - - - - + + + + diff --git a/CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj b/CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj index 8c4f0af..d850528 100644 --- a/CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj +++ b/CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj @@ -1,13 +1,13 @@ - net5.0 + net7.0 - - + + diff --git a/CoreCms.Net.Task/CoreCms.Net.Task.csproj b/CoreCms.Net.Task/CoreCms.Net.Task.csproj index 473b1bf..47fb7a1 100644 --- a/CoreCms.Net.Task/CoreCms.Net.Task.csproj +++ b/CoreCms.Net.Task/CoreCms.Net.Task.csproj @@ -1,12 +1,12 @@ - net5.0 + net7.0 - - + + diff --git a/CoreCms.Net.Uni-App/CoreCms.Net.Uni-App.csproj b/CoreCms.Net.Uni-App/CoreCms.Net.Uni-App.csproj index be4f089..a405659 100644 --- a/CoreCms.Net.Uni-App/CoreCms.Net.Uni-App.csproj +++ b/CoreCms.Net.Uni-App/CoreCms.Net.Uni-App.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 diff --git a/CoreCms.Net.Utility/CoreCms.Net.Utility.csproj b/CoreCms.Net.Utility/CoreCms.Net.Utility.csproj index d462686..f627f05 100644 --- a/CoreCms.Net.Utility/CoreCms.Net.Utility.csproj +++ b/CoreCms.Net.Utility/CoreCms.Net.Utility.csproj @@ -1,14 +1,14 @@ - net5.0 + net7.0 - - - + + + diff --git a/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj b/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj index 8420228..65ddeb1 100644 --- a/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj +++ b/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj @@ -1,17 +1,17 @@ - net5.0 + net7.0 - - + + - - - - + + + + diff --git a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj index 6f068f0..5511aae 100644 --- a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj +++ b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 zh-Hans false b93911e3-96d4-453b-aa87-357c154804c2 @@ -52,31 +52,31 @@ - - - - - - - - + + + + + + + + - + - + - - - - + + + + - - - - - + + + + + diff --git a/CoreCms.Net.Web.Admin/Program.cs b/CoreCms.Net.Web.Admin/Program.cs index 818d960..9d23f18 100644 --- a/CoreCms.Net.Web.Admin/Program.cs +++ b/CoreCms.Net.Web.Admin/Program.cs @@ -7,61 +7,214 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using NLog.Web; using System; +using System.Linq; +using Autofac; +using CoreCms.Net.Auth; +using CoreCms.Net.Configuration; +using CoreCms.Net.Core.AutoFac; +using CoreCms.Net.Core.Config; +using CoreCms.Net.Filter; +using CoreCms.Net.Mapping; +using CoreCms.Net.Middlewares; +using CoreCms.Net.Swagger; +using Essensoft.Paylink.Alipay; +using Essensoft.Paylink.WeChatPay; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Yitter.IdGenerator; -namespace CoreCms.Net.Web.Admin + +var builder = WebApplication.CreateBuilder(args); + +//添加本地路径获取支持 +builder.Services.AddSingleton(new AppSettingsHelper(builder.Environment.ContentRootPath)); +builder.Services.AddSingleton(new LogLockHelper(builder.Environment.ContentRootPath)); + +//Memory缓存 +builder.Services.AddMemoryCacheSetup(); +//Redis缓存 +builder.Services.AddRedisCacheSetup(); + +//添加数据库连接SqlSugar注入支持 +builder.Services.AddSqlSugarSetup(); +//配置跨域(CORS) +builder.Services.AddCorsSetup(); + +//添加session支持(session依赖于cache进行存储) +builder.Services.AddSession(); +// AutoMapper支持 +builder.Services.AddAutoMapper(typeof(AutoMapperConfiguration)); + +//使用 SignalR +builder.Services.AddSignalR(); + +// 引入Payment 依赖注入(支付宝支付/微信支付) +builder.Services.AddAlipay(); +builder.Services.AddWeChatPay(); + +// 在 appsettings.json 中 配置选项 +builder.Services.Configure(builder.Configuration.GetSection("WeChatPay")); +builder.Services.Configure(builder.Configuration.GetSection("Alipay")); + +//注册自定义微信接口配置文件 +builder.Services.Configure(builder.Configuration.GetSection(nameof(CoreCms.Net.WeChat.Service.Options.WeChatOptions))); + +// 注入工厂 HTTP 客户端 +builder.Services.AddHttpClient(); +builder.Services.AddSingleton(); + +//Swagger接口文档注入 +builder.Services.AddAdminSwaggerSetup(); + +//配置易联云打印机 +builder.Services.AddYiLianYunSetup(); + +//jwt授权支持注入 +builder.Services.AddAuthorizationSetupForAdmin(); +//上下文注入 +builder.Services.AddHttpContextSetup(); + +//服务配置中加入AutoFac控制器替换规则。 +builder.Services.Replace(ServiceDescriptor.Transient()); + +//注册mvc,注册razor引擎视图 +builder.Services.AddMvc(options => { - /// - /// 初始化 - /// - public class Program + //实体验证 + options.Filters.Add(); + //异常处理 + options.Filters.Add(); + //Swagger剔除不需要加入api展示的列表 + options.Conventions.Add(new ApiExplorerIgnores()); + + options.EnableEndpointRouting = false; +}) + .AddNewtonsoftJson(p => { - /// - /// 启动配置 - /// - /// - public static void Main(string[] args) + //数据格式首字母小写 不使用驼峰 + p.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + //不使用驼峰样式的key + //p.SerializerSettings.ContractResolver = new DefaultContractResolver(); + //忽略循环引用 + p.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + //设置时间格式 + p.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + }); + + +// 雪花漂移算法 +// 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId: +var options = new IdGeneratorOptions(1); +// 保存参数(必须的操作,否则以上设置都不能生效): +YitIdHelper.SetIdGenerator(options); + +#region AutoFac注册============================================================================ + +builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); +builder.Host.ConfigureContainer(containerBuilder => +{ + //获取所有控制器类型并使用属性注入 + var controllerBaseType = typeof(ControllerBase); + containerBuilder.RegisterAssemblyTypes(typeof(Program).Assembly) + .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType) + .PropertiesAutowired(); + + containerBuilder.RegisterModule(new AutofacModuleRegister()); + +}); + +#endregion + +var app = builder.Build(); + +#region 解决Ubuntu Nginx 代理不能获取IP问题 +app.UseForwardedHeaders(new ForwardedHeadersOptions +{ + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto +}); +#endregion + +// 记录请求与返回数据 (注意开启权限,不然本地无法写入) +app.UseRequestResponseLog(); +// 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流)(注意开启权限,不然本地无法写入) +app.UseRecordAccessLogsMildd(); +// 记录ip请求 (注意开启权限,不然本地无法写入) +app.UseIpLogMildd(); +// signalr +app.UseSignalRSendMildd(); + +app.UseSwagger().UseSwaggerUI(c => +{ + //根据版本名称倒序 遍历展示 + typeof(CustomApiVersion.ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach( + version => { - var host = CreateHostBuilder(args).Build(); - try - { - //确保NLog.config中连接字符串与appsettings.json中同步 - NLogUtil.EnsureNlogConfig("NLog.config"); - //throw new Exception("测试异常");//for test - //其他项目启动时需要做的事情 - NLogUtil.WriteAll(NLog.LogLevel.Trace, LogType.Web, "网站启动", "网站启动成功"); + c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"Doc {version}"); + }); + c.RoutePrefix = "doc"; +}); - host.Run(); - } - catch (Exception ex) - { - //使用nlog写到本地日志文件(万一数据库没创建/连接成功) - NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.Web, "网站启动", "初始化数据异常", ex); - throw; - } - } +//使用 Session +app.UseSession(); - /// - /// 创建启动支撑 - /// - /// - /// - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .UseServiceProviderFactory(new AutofacServiceProviderFactory()) //<--NOTE THIS - .ConfigureLogging(logging => - { - logging.ClearProviders(); //移除已经注册的其他日志处理程序 - logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); //设置最小的日志级别 - }) - .UseNLog() //NLog: Setup NLog for Dependency injection - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder - .ConfigureKestrel(serverOptions => - { - serverOptions.AllowSynchronousIO = true;//启用同步 IO - }) - .UseStartup(); - }); - } -} \ No newline at end of file +if (app.Environment.IsDevelopment()) +{ + // 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。 + app.UseDeveloperExceptionPage(); +} +else +{ + app.UseExceptionHandler("/Home/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +// CORS跨域 +app.UseCors(AppSettingsConstVars.CorsPolicyName); +// 跳转https +//app.UseHttpsRedirection(); +// 使用静态文件 +app.UseStaticFiles(); +// 使用cookie +app.UseCookiePolicy(); +// 返回错误码 +app.UseStatusCodePages(); +// Routing +app.UseRouting(); +// 先开启认证 +app.UseAuthentication(); +// 然后是授权中间件 +app.UseAuthorization(); + +app.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + +//设置默认起始页(如default.html) +//此处的路径是相对于wwwroot文件夹的相对路径 +var defaultFilesOptions = new DefaultFilesOptions(); +defaultFilesOptions.DefaultFileNames.Clear(); +defaultFilesOptions.DefaultFileNames.Add("index.html"); +app.UseDefaultFiles(defaultFilesOptions); +app.UseStaticFiles(); + +try +{ + //确保NLog.config中连接字符串与appsettings.json中同步 + NLogUtil.EnsureNlogConfig("NLog.config"); + //其他项目启动时需要做的事情 + NLogUtil.WriteAll(NLog.LogLevel.Trace, LogType.ApiRequest, "接口启动", "接口启动成功"); + + app.Run(); +} +catch (Exception ex) +{ + //使用Nlog写到本地日志文件(万一数据库没创建/连接成功) + NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.ApiRequest, "接口启动", "初始化数据异常", ex); + throw; +} diff --git a/CoreCms.Net.Web.Admin/Startup.cs b/CoreCms.Net.Web.Admin/Startup.cs deleted file mode 100644 index 18d2028..0000000 --- a/CoreCms.Net.Web.Admin/Startup.cs +++ /dev/null @@ -1,255 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using Autofac; -using CoreCms.Net.Auth; -using CoreCms.Net.Configuration; -using CoreCms.Net.Core.AutoFac; -using CoreCms.Net.Core.Config; -using CoreCms.Net.Filter; -using CoreCms.Net.Loging; -using CoreCms.Net.Mapping; -using CoreCms.Net.Middlewares; -using CoreCms.Net.Swagger; -using Essensoft.Paylink.Alipay; -using Essensoft.Paylink.WeChatPay; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.AspNetCore.Localization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.DotNet.PlatformAbstractions; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using Yitter.IdGenerator; - -namespace CoreCms.Net.Web.Admin -{ - /// - /// 启动配置 - /// - public class Startup - { - /// - /// 构造函数 - /// - /// - /// - public Startup(IConfiguration configuration, IWebHostEnvironment env) - { - Configuration = configuration; - Env = env; - } - - /// - /// - public IConfiguration Configuration { get; } - - /// - /// - public IWebHostEnvironment Env { get; } - - /// - /// This method gets called by the runtime. Use this method to add services to the container. - /// - /// - public void ConfigureServices(IServiceCollection services) - { - //添加本地路径获取支持 - services.AddSingleton(new AppSettingsHelper(Env.ContentRootPath)); - services.AddSingleton(new LogLockHelper(Env.ContentRootPath)); - - //Memory缓存 - services.AddMemoryCacheSetup(); - //Redis缓存 - services.AddRedisCacheSetup(); - - - //添加数据库连接SqlSugar注入支持 - services.AddSqlSugarSetup(); - //配置跨域(CORS) - services.AddCorsSetup(); - - //添加session支持(session依赖于cache进行存储) - services.AddSession(); - // AutoMapper支持 - services.AddAutoMapper(typeof(AutoMapperConfiguration)); - - //使用 SignalR - services.AddSignalR(); - - // 引入Payment 依赖注入(支付宝支付/微信支付) - services.AddAlipay(); - services.AddWeChatPay(); - - // 在 appsettings.json 中 配置选项 - services.Configure(Configuration.GetSection("WeChatPay")); - services.Configure(Configuration.GetSection("Alipay")); - - - //注册自定义微信接口配置文件 - services.Configure(Configuration.GetSection(nameof(WeChat.Service.Options.WeChatOptions))); - - // 注入工厂 HTTP 客户端 - services.AddHttpClient(); - services.AddSingleton(); - - - //Swagger接口文档注入 - services.AddAdminSwaggerSetup(); - - //配置易联云打印机 - services.AddYiLianYunSetup(); - - //jwt授权支持注入 - services.AddAuthorizationSetupForAdmin(); - //上下文注入 - services.AddHttpContextSetup(); - - //服务配置中加入AutoFac控制器替换规则。 - services.Replace(ServiceDescriptor.Transient()); - - //注册mvc,注册razor引擎视图 - services.AddMvc(options => - { - //实体验证 - options.Filters.Add(); - //异常处理 - options.Filters.Add(); - //Swagger剔除不需要加入api展示的列表 - options.Conventions.Add(new ApiExplorerIgnores()); - - options.EnableEndpointRouting = false; - }) - .AddNewtonsoftJson(p => - { - //数据格式首字母小写 不使用驼峰 - p.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); - //不使用驼峰样式的key - //p.SerializerSettings.ContractResolver = new DefaultContractResolver(); - //忽略循环引用 - p.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - //设置时间格式 - p.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; - }); - - - - // 雪花漂移算法 - // 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId: - var options = new IdGeneratorOptions(1); - // 保存参数(必须的操作,否则以上设置都不能生效): - YitIdHelper.SetIdGenerator(options); - - - } - - /// - /// Autofac规则配置 - /// - /// - public void ConfigureContainer(ContainerBuilder builder) - { - builder.RegisterModule(new AutofacModuleRegister()); - - //获取所有控制器类型并使用属性注入 - var controllerBaseType = typeof(ControllerBase); - builder.RegisterAssemblyTypes(typeof(Program).Assembly) - .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType) - .PropertiesAutowired(); - } - - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - #region 解决Ubuntu Nginx 代理不能获取IP问题 - app.UseForwardedHeaders(new ForwardedHeadersOptions - { - ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto - }); - #endregion - - // 记录请求与返回数据 (注意开启权限,不然本地无法写入) - app.UseRequestResponseLog(); - // 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流)(注意开启权限,不然本地无法写入) - app.UseRecordAccessLogsMildd(); - // 记录ip请求 (注意开启权限,不然本地无法写入) - app.UseIpLogMildd(); - // signalr - app.UseSignalRSendMildd(); - - - app.UseSwagger().UseSwaggerUI(c => - { - //根据版本名称倒序 遍历展示 - typeof(CustomApiVersion.ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach( - version => - { - c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"Doc {version}"); - }); - c.RoutePrefix = "doc"; - }); - - //使用 Session - app.UseSession(); - - if (env.IsDevelopment()) - { - // 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。 - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - // CORS跨域 - app.UseCors(AppSettingsConstVars.CorsPolicyName); - // 跳转https - //app.UseHttpsRedirection(); - // 使用静态文件 - app.UseStaticFiles(); - // 使用cookie - app.UseCookiePolicy(); - // 返回错误码 - app.UseStatusCodePages(); - // Routing - app.UseRouting(); - // 先开启认证 - app.UseAuthentication(); - // 然后是授权中间件 - app.UseAuthorization(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllerRoute( - "areas", - "{area:exists}/{controller=Default}/{action=Index}/{id?}" - ); - - endpoints.MapControllerRoute( - "default", - "{controller=Home}/{action=Index}/{id?}"); - }); - - //设置默认起始页(如default.html) - //此处的路径是相对于wwwroot文件夹的相对路径 - var defaultFilesOptions = new DefaultFilesOptions(); - defaultFilesOptions.DefaultFileNames.Clear(); - defaultFilesOptions.DefaultFileNames.Add("index.html"); - app.UseDefaultFiles(defaultFilesOptions); - app.UseStaticFiles(); - } - } -} \ No newline at end of file diff --git a/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj b/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj index 1e61a1c..d6cd1d6 100644 --- a/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj +++ b/CoreCms.Net.Web.WebApi/CoreCms.Net.Web.WebApi.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 zh-Hans false 077906fd-e490-4431-9bae-c3a48ae21992 @@ -47,28 +47,28 @@ - - - - - - - - + + + + + + + + - - - + + + - + - - + + - - - + + + diff --git a/CoreCms.Net.Web.WebApi/Program.cs b/CoreCms.Net.Web.WebApi/Program.cs index bdeb09b..08e7759 100644 --- a/CoreCms.Net.Web.WebApi/Program.cs +++ b/CoreCms.Net.Web.WebApi/Program.cs @@ -1,69 +1,259 @@ using System; +using System.Linq; +using Autofac; using Autofac.Extensions.DependencyInjection; +using CoreCms.Net.Auth; +using CoreCms.Net.Configuration; +using CoreCms.Net.Core.AutoFac; +using CoreCms.Net.Core.Config; +using CoreCms.Net.Filter; using CoreCms.Net.Loging; +using CoreCms.Net.Mapping; +using CoreCms.Net.Middlewares; +using CoreCms.Net.Swagger; +using CoreCms.Net.Task; +using CoreCms.Net.WeChat.Service.Mediator; +using Essensoft.Paylink.Alipay; +using Essensoft.Paylink.WeChatPay; +using Hangfire; +using Hangfire.Dashboard.BasicAuthorization; +using MediatR; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; using NLog.Web; -using LogLevel = NLog.LogLevel; -namespace CoreCms.Net.Web.WebApi +var builder = WebApplication.CreateBuilder(args); + +//添加本地路径获取支持 +builder.Services.AddSingleton(new AppSettingsHelper(builder.Environment.ContentRootPath)); +builder.Services.AddSingleton(new LogLockHelper(builder.Environment.ContentRootPath)); + +//Memory缓存 +builder.Services.AddMemoryCacheSetup(); +//Redis缓存 +builder.Services.AddRedisCacheSetup(); + +//添加数据库连接SqlSugar注入支持 +builder.Services.AddSqlSugarSetup(); +//配置跨域(CORS) +builder.Services.AddCorsSetup(); + +//添加session支持(session依赖于cache进行存储) +builder.Services.AddSession(); +// AutoMapper支持 +builder.Services.AddAutoMapper(typeof(AutoMapperConfiguration)); + +//MediatR(只需要注册一个,同项目或类库下就不需要注册多个) +builder.Services.AddMediatR(typeof(TextMessageEventCommand).Assembly); + +//使用 SignalR +builder.Services.AddSignalR(); + +//Redis消息队列 +builder.Services.AddRedisMessageQueueSetup(); + +// 引入Payment 依赖注入(支付宝支付/微信支付) +builder.Services.AddAlipay(); +builder.Services.AddWeChatPay(); + +// 在 appsettings.json 中 配置选项 +builder.Services.Configure(builder.Configuration.GetSection("WeChatPay")); +builder.Services.Configure(builder.Configuration.GetSection("Alipay")); + +//注册自定义微信接口配置文件 +builder.Services.Configure(builder.Configuration.GetSection(nameof(CoreCms.Net.WeChat.Service.Options.WeChatOptions))); + +// 注入工厂 HTTP 客户端 +builder.Services.AddHttpClient(); +builder.Services.AddSingleton(); + +//Swagger接口文档注入 +builder.Services.AddClientSwaggerSetup(); + +//配置易联云打印机 +builder.Services.AddYiLianYunSetup(); + +//注册Hangfire定时任务 +builder.Services.AddHangFireSetup(); + +//授权支持注入 +builder.Services.AddAuthorizationSetupForClient(); +//上下文注入 +builder.Services.AddHttpContextSetup(); + +//服务配置中加入AutoFac控制器替换规则。 +builder.Services.Replace(ServiceDescriptor.Transient()); + +//注册mvc,注册razor引擎视图 +builder.Services.AddMvc(options => { - /// - /// 启动类 - /// - public class Program + //实体验证 + options.Filters.Add(); + //异常处理 + options.Filters.Add(); + //Swagger剔除不需要加入api展示的列表 + options.Conventions.Add(new ApiExplorerIgnores()); +}) + .AddNewtonsoftJson(p => { - /// - /// 启动配置 - /// - /// - public static void Main(string[] args) - { - var host = CreateHostBuilder(args).Build(); - try - { - //确保NLog.config中连接字符串与appsettings.json中同步 - NLogUtil.EnsureNlogConfig("NLog.config"); - //其他项目启动时需要做的事情 - NLogUtil.WriteAll(LogLevel.Trace, LogType.Web, "接口启动", "接口启动成功"); + //数据格式首字母小写 不使用驼峰 + p.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + //不使用驼峰样式的key + //p.SerializerSettings.ContractResolver = new DefaultContractResolver(); + //忽略循环引用 + p.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + //设置时间格式(必须使用yyyy/MM/dd格式,因为ios系统不支持2018-03-29格式的时间,只识别2018/03/09这种格式。) + p.SerializerSettings.DateFormatString = "yyyy/MM/dd HH:mm:ss"; + }); - host.Run(); - } - catch (Exception ex) +#region AutoFac注册============================================================================ + +builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); +builder.Host.ConfigureContainer(containerBuilder => +{ + //获取所有控制器类型并使用属性注入 + var controllerBaseType = typeof(ControllerBase); + containerBuilder.RegisterAssemblyTypes(typeof(Program).Assembly) + .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType) + .PropertiesAutowired(); + + containerBuilder.RegisterModule(new AutofacModuleRegister()); + +}); + +#endregion + +var app = builder.Build(); + +#region 解决Ubuntu Nginx 代理不能获取IP问题 +app.UseForwardedHeaders(new ForwardedHeadersOptions +{ + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto +}); +#endregion + +// 记录请求与返回数据 (注意开启权限,不然本地无法写入) +app.UseRequestResponseLog(); +// 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流)(注意开启权限,不然本地无法写入) +app.UseRecordAccessLogsMildd(); +// 记录ip请求 (注意开启权限,不然本地无法写入) +app.UseIpLogMildd(); + +//强制显示中文 +System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); + +app.UseSwagger().UseSwaggerUI(c => +{ + //根据版本名称倒序 遍历展示 + typeof(CustomApiVersion.ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach( + version => + { + c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"Doc {version}"); + }); + //设置默认跳转到swagger-ui + c.RoutePrefix = "doc"; + //c.RoutePrefix = string.Empty; +}); + +#region Hangfire定时任务 + +//授权 +var filter = new BasicAuthAuthorizationFilter( + new BasicAuthAuthorizationFilterOptions + { + SslRedirect = false, + // Require secure connection for dashboard + RequireSsl = false, + // Case sensitive login checking + LoginCaseSensitive = false, + // Users + Users = new[] + { + new BasicAuthAuthorizationUser { - //使用nlog写到本地日志文件(万一数据库没创建/连接成功) - NLogUtil.WriteFileLog(LogLevel.Error, LogType.ApiRequest, "接口启动", "初始化数据异常", ex); - throw; + Login = AppSettingsConstVars.HangFireLogin, + PasswordClear = AppSettingsConstVars.HangFirePassWord } } + }); +var hangfireOptions = new Hangfire.DashboardOptions +{ + AppPath = "/",//返回时跳转的地址 + DisplayStorageConnectionString = false,//是否显示数据库连接信息 + Authorization = new[] + { + filter + }, + IsReadOnlyFunc = _ => false +}; - /// - /// 创建启动支撑 - /// - /// - /// - public static IHostBuilder CreateHostBuilder(string[] args) - { - return Host.CreateDefaultBuilder(args) - .UseServiceProviderFactory(new AutofacServiceProviderFactory()) //<--NOTE THIS - .ConfigureLogging(logging => - { - logging.ClearProviders(); //移除已经注册的其他日志处理程序 - logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); //设置最小的日志级别 - }) - .UseNLog() //NLog: Setup NLog for Dependency injection - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder - .ConfigureKestrel(serverOptions => - { - serverOptions.AllowSynchronousIO = true; //启用同步 IO - }) - .UseStartup(); - }); - } - } -} \ No newline at end of file +app.UseHangfireDashboard("/job", hangfireOptions); //可以改变Dashboard的url +HangfireDispose.HangfireService(); + +#endregion + +//使用 Session +app.UseSession(); + +if (app.Environment.IsDevelopment()) +{ + // 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。 + app.UseDeveloperExceptionPage(); +} +else +{ + app.UseExceptionHandler("/Home/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +// CORS跨域 +app.UseCors(AppSettingsConstVars.CorsPolicyName); + +// Routing +app.UseRouting(); + +// 使用静态文件 +app.UseStaticFiles(); +// 先开启认证 +app.UseAuthentication(); +// 然后是授权中间件 +app.UseAuthorization(); + +app.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + +//设置默认起始页(如default.html) +//此处的路径是相对于wwwroot文件夹的相对路径 +var defaultFilesOptions = new DefaultFilesOptions(); +defaultFilesOptions.DefaultFileNames.Clear(); +defaultFilesOptions.DefaultFileNames.Add("index.html"); +app.UseDefaultFiles(defaultFilesOptions); +app.UseStaticFiles(); + +try +{ + //确保NLog.config中连接字符串与appsettings.json中同步 + NLogUtil.EnsureNlogConfig("NLog.config"); + //其他项目启动时需要做的事情 + NLogUtil.WriteAll(NLog.LogLevel.Trace, LogType.ApiRequest, "接口启动", "接口启动成功"); + + app.Run(); +} +catch (Exception ex) +{ + //使用Nlog写到本地日志文件(万一数据库没创建/连接成功) + NLogUtil.WriteFileLog(NLog.LogLevel.Error, LogType.ApiRequest, "接口启动", "初始化数据异常", ex); + throw; +} diff --git a/CoreCms.Net.Web.WebApi/Startup.cs b/CoreCms.Net.Web.WebApi/Startup.cs deleted file mode 100644 index 3a99fe7..0000000 --- a/CoreCms.Net.Web.WebApi/Startup.cs +++ /dev/null @@ -1,312 +0,0 @@ -using Autofac; -using AutoMapper; -using CoreCms.Net.Auth; -using CoreCms.Net.Configuration; -using CoreCms.Net.Core.AutoFac; -using CoreCms.Net.Core.Config; -using CoreCms.Net.Filter; -using CoreCms.Net.Loging; -using CoreCms.Net.Mapping; -using CoreCms.Net.Middlewares; -using CoreCms.Net.Swagger; -using CoreCms.Net.Task; -using Hangfire; -using Hangfire.Dashboard.BasicAuthorization; -using InitQ; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using Qc.YilianyunSdk; -using System; -using System.Collections.Generic; -using System.Linq; -using CoreCms.Net.RedisMQ.Subscribe; -using CoreCms.Net.Utility.Extensions; -using CoreCms.Net.WeChat.Service.Mediator; -using Essensoft.Paylink.Alipay; -using Essensoft.Paylink.WeChatPay; -using MediatR; -using Microsoft.AspNetCore.HttpOverrides; - -namespace CoreCms.Net.Web.WebApi -{ - /// - /// 启动配置 - /// - public class Startup - { - /// - /// 构造函数 - /// - /// - /// - public Startup(IConfiguration configuration, IWebHostEnvironment env) - { - Configuration = configuration; - Env = env; - } - /// - /// 配置属性 - /// - public IConfiguration Configuration { get; } - /// - /// web环境 - /// - public IWebHostEnvironment Env { get; } - - /// This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - //添加本地路径获取支持 - services.AddSingleton(new AppSettingsHelper(Env.ContentRootPath)); - services.AddSingleton(new LogLockHelper(Env.ContentRootPath)); - - //Memory缓存 - services.AddMemoryCacheSetup(); - //Redis缓存 - services.AddRedisCacheSetup(); - - //添加数据库连接SqlSugar注入支持 - services.AddSqlSugarSetup(); - //配置跨域(CORS) - services.AddCorsSetup(); - - - //添加session支持(session依赖于cache进行存储) - services.AddSession(); - // AutoMapper支持 - services.AddAutoMapper(typeof(AutoMapperConfiguration)); - - //MediatR(只需要注册一个,同项目或类库下就不需要注册多个) - services.AddMediatR(typeof(TextMessageEventCommand).Assembly); - - //使用 SignalR - services.AddSignalR(); - - //Redis消息队列 - services.AddRedisMessageQueueSetup(); - - // 引入Payment 依赖注入(支付宝支付/微信支付) - services.AddAlipay(); - services.AddWeChatPay(); - - // 在 appsettings.json 中 配置选项 - services.Configure(Configuration.GetSection("WeChatPay")); - services.Configure(Configuration.GetSection("Alipay")); - - - //注册自定义微信接口配置文件 - services.Configure(Configuration.GetSection(nameof(WeChat.Service.Options.WeChatOptions))); - - // 注入工厂 HTTP 客户端 - services.AddHttpClient(); - services.AddSingleton(); - - - //Swagger接口文档注入 - services.AddClientSwaggerSetup(); - - //配置易联云打印机 - services.AddYiLianYunSetup(); - - //注册Hangfire定时任务 - services.AddHangFireSetup(); - - - //授权支持注入 - services.AddAuthorizationSetupForClient(); - //上下文注入 - services.AddHttpContextSetup(); - - //服务配置中加入AutoFac控制器替换规则。 - services.Replace(ServiceDescriptor.Transient()); - - //注册mvc,注册razor引擎视图 - services.AddMvc(options => - { - //实体验证 - options.Filters.Add(); - //异常处理 - options.Filters.Add(); - //Swagger剔除不需要加入api展示的列表 - options.Conventions.Add(new ApiExplorerIgnores()); - }) - .AddNewtonsoftJson(p => - { - //数据格式首字母小写 不使用驼峰 - p.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); - //不使用驼峰样式的key - //p.SerializerSettings.ContractResolver = new DefaultContractResolver(); - //忽略循环引用 - p.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - //设置时间格式(必须使用yyyy/MM/dd格式,因为ios系统不支持2018-03-29格式的时间,只识别2018/03/09这种格式。) - p.SerializerSettings.DateFormatString = "yyyy/MM/dd HH:mm:ss"; - }); - - - - } - - /// - /// Autofac规则配置 - /// - /// - public void ConfigureContainer(ContainerBuilder builder) - { - //获取所有控制器类型并使用属性注入 - var controllerBaseType = typeof(ControllerBase); - builder.RegisterAssemblyTypes(typeof(Program).Assembly) - .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType) - .PropertiesAutowired(); - - builder.RegisterModule(new AutofacModuleRegister()); - - } - - // public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions senparcSetting, IOptions senparcWeixinSetting) - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - #region 解决Ubuntu Nginx 代理不能获取IP问题 - app.UseForwardedHeaders(new ForwardedHeadersOptions - { - ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto - }); - #endregion - - // 记录请求与返回数据 (注意开启权限,不然本地无法写入) - app.UseRequestResponseLog(); - // 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流)(注意开启权限,不然本地无法写入) - app.UseRecordAccessLogsMildd(); - // 记录ip请求 (注意开启权限,不然本地无法写入) - app.UseIpLogMildd(); - - - //强制显示中文 - System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); - - app.UseSwagger().UseSwaggerUI(c => - { - //根据版本名称倒序 遍历展示 - typeof(CustomApiVersion.ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach( - version => - { - c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"Doc {version}"); - }); - //设置默认跳转到swagger-ui - c.RoutePrefix = "doc"; - //c.RoutePrefix = string.Empty; - }); - - - #region Hangfire定时任务 - - //授权 - var filter = new BasicAuthAuthorizationFilter( - new BasicAuthAuthorizationFilterOptions - { - SslRedirect = false, - // Require secure connection for dashboard - RequireSsl = false, - // Case sensitive login checking - LoginCaseSensitive = false, - // Users - Users = new[] - { - new BasicAuthAuthorizationUser - { - Login = AppSettingsConstVars.HangFireLogin, - PasswordClear = AppSettingsConstVars.HangFirePassWord - } - } - }); - var options = new DashboardOptions - { - AppPath = "/",//返回时跳转的地址 - DisplayStorageConnectionString = false,//是否显示数据库连接信息 - Authorization = new[] - { - filter - }, - IsReadOnlyFunc = Context => - { - return false;//是否只读面板 - } - }; - - app.UseHangfireDashboard("/job", options); //可以改变Dashboard的url - HangfireDispose.HangfireService(); - - #endregion - - - - - //使用 Session - app.UseSession(); - - if (env.IsDevelopment()) - { - // 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。 - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - // CORS跨域 - app.UseCors(AppSettingsConstVars.CorsPolicyName); - - // Routing - app.UseRouting(); - - // 使用静态文件 - app.UseStaticFiles(); - // 先开启认证 - app.UseAuthentication(); - // 然后是授权中间件 - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllerRoute( - "areas", - "{area:exists}/{controller=Default}/{action=Index}/{id?}" - ); - - //endpoints.MapControllers(); - endpoints.MapControllerRoute( - "default", - "{controller=Default}/{action=Index}/{id?}"); - }); - - - - //设置默认起始页(如default.html) - //此处的路径是相对于wwwroot文件夹的相对路径 - var defaultFilesOptions = new DefaultFilesOptions(); - defaultFilesOptions.DefaultFileNames.Clear(); - defaultFilesOptions.DefaultFileNames.Add("index.html"); - app.UseDefaultFiles(defaultFilesOptions); - app.UseStaticFiles(); - - } - - - } -} \ No newline at end of file diff --git a/README.md b/README.md index 25bf2f8..4f0525f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ QQ缇わ細70494974 #### 馃拹 鏍稿績鍟嗗煄锛圕oreShop锛変粙缁� -> 鏍稿績鍟嗗煄绯荤粺`锛圕oreShop锛塦 鏄熀浜� Asp.Net 5.0銆乁ni-App寮�鍙戙�佹敮鎸佸彲瑙嗗寲甯冨眬鐨勫皬绋嬪簭鍟嗗煄绯荤粺锛涘墠鍚庣鍒嗙锛屾敮鎸佸垎甯冨紡閮ㄧ讲锛岃法骞冲彴杩愯锛涙嫢鏈夊垎閿�銆佷唬鐞嗐�佸洟璐鏉�銆佹帴榫欍�佹嫾鍥€�佺洿鎾�佷紭鎯犲埜銆佽嚜瀹氫箟琛ㄥ崟绛変紬澶氳惀閿�鍔熻兘锛屾嫢鏈夊畬鏁碨KU銆佷笅鍗曘�佸敭鍚庛�佺墿娴佹祦绋嬶紝鏀寔鍙鍖栬嚜瀹氫箟棣栭〉妯″潡甯冨眬鏁堟灉銆� +> 鏍稿績鍟嗗煄绯荤粺`锛圕oreShop锛塦 鏄熀浜� Asp.Net 7.0銆乁ni-App寮�鍙戙�佹敮鎸佸彲瑙嗗寲甯冨眬鐨勫皬绋嬪簭鍟嗗煄绯荤粺锛涘墠鍚庣鍒嗙锛屾敮鎸佸垎甯冨紡閮ㄧ讲锛岃法骞冲彴杩愯锛涙嫢鏈夊垎閿�銆佷唬鐞嗐�佸洟璐鏉�銆佹帴榫欍�佹嫾鍥€�佺洿鎾�佷紭鎯犲埜銆佽嚜瀹氫箟琛ㄥ崟绛変紬澶氳惀閿�鍔熻兘锛屾嫢鏈夊畬鏁碨KU銆佷笅鍗曘�佸敭鍚庛�佺墿娴佹祦绋嬶紝鏀寔鍙鍖栬嚜瀹氫箟棣栭〉妯″潡甯冨眬鏁堟灉銆� > 鏀寔涓�濂椾唬鐮佺紪璇戝彂甯冨井淇″皬绋嬪簭鐗堛�丠5鐗堛�丄ndroid鐗堛�乮OS鐗堛�佹敮浠樺疂灏忕▼搴忕増銆佺櫨搴﹀皬绋嬪簭鐗堛�佸瓧鑺傝烦鍔ㄥ皬绋嬪簭鐗堛�丵Q灏忕▼搴忕増銆佸揩搴旂敤銆�360灏忕▼搴忓叡10涓钩鍙般��