From d464f953efc65f7c04f6376a0322837a570478aa Mon Sep 17 00:00:00 2001 From: jianweie code Date: Wed, 19 Jun 2024 09:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E7=A7=BB?= =?UTF-8?q?=E9=99=A4hangfire=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=B0=86=E8=B7=AF=E7=94=B1=E8=AE=BE=E7=BD=AE=E5=88=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Configuration/AppSettingsConstVars.cs | 4 ++++ CoreCms.Net.Web.WebApi/Program.cs | 2 +- CoreCms.Net.Web.WebApi/appsettings.json | 5 +++-- CoreCms.Net.Web.WebApi/wwwroot/index.html | 5 ++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CoreCms.Net.Configuration/AppSettingsConstVars.cs b/CoreCms.Net.Configuration/AppSettingsConstVars.cs index a83b7a02..5633c072 100644 --- a/CoreCms.Net.Configuration/AppSettingsConstVars.cs +++ b/CoreCms.Net.Configuration/AppSettingsConstVars.cs @@ -112,6 +112,10 @@ namespace CoreCms.Net.Configuration #region HangFire定时任务================================================================================ /// + /// HangFire默认访问路由地址 + /// + public static readonly string HangFireRoutePrefix = AppSettingsHelper.GetContent("HangFire", "RoutePrefix"); + /// /// 登录账号 /// public static readonly string HangFireLogin = AppSettingsHelper.GetContent("HangFire", "Login"); diff --git a/CoreCms.Net.Web.WebApi/Program.cs b/CoreCms.Net.Web.WebApi/Program.cs index 03d62280..fd42f3fb 100644 --- a/CoreCms.Net.Web.WebApi/Program.cs +++ b/CoreCms.Net.Web.WebApi/Program.cs @@ -244,7 +244,7 @@ var hangfireOptions = new Hangfire.DashboardOptions IsReadOnlyFunc = _ => false }; -app.UseHangfireDashboard("/job", hangfireOptions); //可以改变Dashboard的url +app.UseHangfireDashboard(AppSettingsConstVars.HangFireRoutePrefix, hangfireOptions); HangfireDispose.HangfireService(); //设置hangfire定时任务过期时间 diff --git a/CoreCms.Net.Web.WebApi/appsettings.json b/CoreCms.Net.Web.WebApi/appsettings.json index 7d13c710..c4e26eba 100644 --- a/CoreCms.Net.Web.WebApi/appsettings.json +++ b/CoreCms.Net.Web.WebApi/appsettings.json @@ -10,8 +10,9 @@ }, //定时任务管理面板的账户密码 "HangFire": { - "Login": "CoreShopProfessional", //登录账号 - "PassWord": "uzmp0o3213217vr53", //登录密码 + "RoutePrefix": "/job", //路由地址,默认'/job' + "Login": "", //登录账号 + "PassWord": "", //登录密码 "JobExpirationTimeOut": "10080" //已经完成的任务过期时间,单位分钟(默认10080,7天时间) }, //Swagger授权访问设置 diff --git a/CoreCms.Net.Web.WebApi/wwwroot/index.html b/CoreCms.Net.Web.WebApi/wwwroot/index.html index 4010ec6d..df44ca20 100644 --- a/CoreCms.Net.Web.WebApi/wwwroot/index.html +++ b/CoreCms.Net.Web.WebApi/wwwroot/index.html @@ -31,9 +31,8 @@
注意事项:

1、以上组件地址支持自定义调整,投产环境下请及时修改或屏蔽;投产环境下可删除此展示页面。

-

2、『Swagger接口文档』访问路径修改位置为:【Program.cs】文件第205行左右【代码:c.RoutePrefix = "doc"】,请将doc修改为其他虚拟路径。

-

3、『HangFire定时任务』面板路径修改位置为:【Program.cs】文件第240行左右【代码:app.UseHangfireDashboard("/job", hangfireOptions);】,请将job修改为其他虚拟路径。

-

4、『HangFire定时任务』初始登录账号密码均为:【CoreShop】,修改位置为:【appsettings.json】文件,代码中【HangFire】节点。

+

2、『Swagger接口文档』访问路径,登录账号密码均自行设置,修改位置为:【appsettings.json】文件,代码中【SwaggerConfig】节点。

+

4、『HangFire定时任务』访问路径,登录账号密码均自行设置,修改位置为:【appsettings.json】文件,代码中【HangFire】节点。

5、如果无法访问接口,请检查【1、数据库配置是否正常】【2、Redis是否配置正常并可正常链接使用】【3、Mysql数据库请保持5.7+版本】【4、站点日志文件夹写入权限】。

6、如果第三方请求接口服务获取不到数据,Debug提示【Access-Control-Allow-Origin】的错误,表示为跨域问题,请打开【appsettings.json】文件在【Cors】节点设置请求白名单。