diff --git a/DataBase/MySql/Dump.sql b/DataBase/MySql/Dump.sql index 15fb3bce2..d9abf5782 100644 --- a/DataBase/MySql/Dump.sql +++ b/DataBase/MySql/Dump.sql @@ -849,7 +849,7 @@ CREATE TABLE `CMS_Redirection` ( /*!40000 ALTER TABLE `CMS_Redirection` DISABLE KEYS */; INSERT INTO `CMS_Redirection` VALUES -(1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',1); +(1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',0); /*!40000 ALTER TABLE `CMS_Redirection` ENABLE KEYS */; DROP TABLE IF EXISTS `CMS_Rule`; diff --git a/DataBase/SQLite/ZKEACMS.sqlite.sql b/DataBase/SQLite/ZKEACMS.sqlite.sql index 87ecc8145..a019b92ca 100644 --- a/DataBase/SQLite/ZKEACMS.sqlite.sql +++ b/DataBase/SQLite/ZKEACMS.sqlite.sql @@ -4784,7 +4784,7 @@ INSERT INTO [HtmlWidget] ([ID],[HTML]) VALUES ('f6de0d62d3974ee2bf2ded3fbbc82c2b INSERT INTO [CMS_Theme] ([ID],[Title],[Url],[UrlDebugger],[Thumbnail],[IsActived],[Status],[Description],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate]) VALUES ('Default','默认','~/themes/Default/css/Theme.min.css','~/themes/Default/css/Theme.css','~/themes/Default/thumbnail.jpg',1,1,NULL,'admin','ZKEASOFT','2016-04-04 22:17:10.790','admin','ZKEASOFT','2016-04-04 22:21:01.487'); INSERT INTO [CMS_Rule] ([RuleID],[Title],[ZoneName],[RuleExpression],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[RuleItems]) VALUES (1,'所有页面','顶部','StartsWith(ValueOf(''Url''),''/'')',NULL,1,'admin','ZKEASOFT','2018-05-21 23:43:34.623','admin','ZKEASOFT','2018-05-21 23:43:34.623','[{"Condition":"and","FunctionName":"StartsWith","Property":"ValueOf(''Url'')","Value":"/","Title":null,"Description":null,"Status":null,"CreateBy":null,"CreatebyName":null,"CreateDate":null,"LastUpdateBy":null,"LastUpdateByName":null,"LastUpdateDate":null,"ActionType":1}]'); INSERT INTO [CMS_Rule] ([RuleID],[Title],[ZoneName],[RuleExpression],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[RuleItems]) VALUES (2,'所有页面','底部','StartsWith(ValueOf(''Url''),''/'')',NULL,1,'admin','ZKEASOFT','2018-05-21 23:43:52.343','admin','ZKEASOFT','2018-05-21 23:43:52.343','[{"Condition":"and","FunctionName":"StartsWith","Property":"ValueOf(''Url'')","Value":"/","Title":null,"Description":null,"Status":null,"CreateBy":null,"CreatebyName":null,"CreateDate":null,"LastUpdateBy":null,"LastUpdateByName":null,"LastUpdateDate":null,"ActionType":1}]'); -INSERT INTO [CMS_Redirection] ([ID],[Title],[InComingUrl],[DestinationURL],[IsPermanent],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[IsPattern]) VALUES (1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',1); +INSERT INTO [CMS_Redirection] ([ID],[Title],[InComingUrl],[DestinationURL],[IsPermanent],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[IsPattern]) VALUES (1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',0); INSERT INTO [CMS_Message] ([ID],[Title],[Email],[PostMessage],[Reply],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[Description]) VALUES (1,'ZKEASOFT','zkea@zkea.net','ZKEACMS是基于ASP.NET MVC4开发的开源CMS,提供免费下载学习使用。','KEACMS使用可视化编辑设计,所见即所得,可直接在页面上设计你要的页面。',1,'admin','ZKEASOFT','2017-03-19 21:02:34.260','admin','ZKEASOFT','2017-03-19 21:02:34.260',NULL); INSERT INTO [CMS_Message] ([ID],[Title],[Email],[PostMessage],[Reply],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[Description]) VALUES (2,'ZKEASOFT','zkea@zkea.net','ZKEACMS使用可视化编辑设计','ZKEACMS是一个内容管理软件(网站),不仅只是管理内容,更是重新定义了布局、页面和组件,让用户可以自由规划页面的布局,页面和内容。',1,'admin','ZKEASOFT','2017-03-19 21:03:09.967','admin','ZKEASOFT','2017-03-19 21:03:09.967',NULL); INSERT INTO [CMS_Media] ([ID],[ParentID],[Title],[MediaType],[Url],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[Description]) VALUES ('6056810a7ede46bb94b55b2756323640','#','图片',1,NULL,NULL,'admin','ZKEASOFT','2016-04-01 21:42:14.960','admin','ZKEASOFT','2016-04-01 21:42:14.960',NULL); diff --git a/DataBase/script.sql b/DataBase/script.sql index 380ec3870..94425272c 100644 --- a/DataBase/script.sql +++ b/DataBase/script.sql @@ -1978,7 +1978,7 @@ INSERT [dbo].[CMS_Page] ([ID], [ReferencePageID], [IsPublishedPage], [ParentId], INSERT [dbo].[CMS_Page] ([ID], [ReferencePageID], [IsPublishedPage], [ParentId], [PageName], [IsHomePage], [Url], [LayoutId], [Title], [Content], [DisplayOrder], [Description], [Status], [IsPublish], [PublishDate], [MetaKeyWorlds], [MetaDescription], [Script], [Style], [CreateBy], [CreatebyName], [CreateDate], [LastUpdateBy], [LastUpdateByName], [LastUpdateDate]) VALUES (N'e371628aa3ff46c3a167f121c7a3f32b', NULL, 0, N'#', N'文章', 0, N'~/article', N'0846a33e56bf45d5aae602ef40d87444', N'文章', NULL, 3, NULL, 1, 1, CAST(N'2017-10-15T18:11:44.940' AS DateTime), NULL, NULL, NULL, NULL, N'admin', N'ZKEASOFT', CAST(N'2016-03-09T12:45:01.000' AS DateTime), N'admin', N'ZKEASOFT', CAST(N'2017-10-15T18:11:44.940' AS DateTime)) SET IDENTITY_INSERT [dbo].[CMS_Redirection] ON -INSERT [dbo].[CMS_Redirection] ([ID], [Title], [InComingUrl], [DestinationURL], [IsPermanent], [Description], [Status], [CreateBy], [CreatebyName], [CreateDate], [LastUpdateBy], [LastUpdateByName], [LastUpdateDate], [IsPattern]) VALUES (1, N'默认', N'~/', N'~/index', 0, NULL, 1, N'admin', N'ZKEASOFT', CAST(N'2017-08-14T14:58:06.000' AS DateTime), N'admin', N'ZKEASOFT', CAST(N'2020-08-01T22:21:26.837' AS DateTime), 1) +INSERT [dbo].[CMS_Redirection] ([ID], [Title], [InComingUrl], [DestinationURL], [IsPermanent], [Description], [Status], [CreateBy], [CreatebyName], [CreateDate], [LastUpdateBy], [LastUpdateByName], [LastUpdateDate], [IsPattern]) VALUES (1, N'默认', N'~/', N'~/index', 0, NULL, 1, N'admin', N'ZKEASOFT', CAST(N'2017-08-14T14:58:06.000' AS DateTime), N'admin', N'ZKEASOFT', CAST(N'2020-08-01T22:21:26.837' AS DateTime), 0) SET IDENTITY_INSERT [dbo].[CMS_Redirection] OFF SET IDENTITY_INSERT [dbo].[CMS_Rule] ON diff --git a/src/ZKEACMS/Page/PageService.cs b/src/ZKEACMS/Page/PageService.cs index f6d641c24..2e5f24185 100644 --- a/src/ZKEACMS/Page/PageService.cs +++ b/src/ZKEACMS/Page/PageService.cs @@ -52,7 +52,7 @@ public PageService(IWidgetBasePartService widgetService, _layoutHtmlService = layoutHtmlService; _eventManager = eventManager; _localize = localize; - _cachedPage = new Dictionary>(); + _cachedPage = new Dictionary>(StringComparer.OrdinalIgnoreCase); } private string FormatPath(string path) @@ -77,6 +77,7 @@ private void InitAssets(PageEntity page) { if (page.Style.IsNotNullAndWhiteSpace()) { + page.Styles.Clear(); if (page.Style.StartsWith("[")) { foreach (var item in JsonConvert.DeserializeObject(page.Style)) @@ -91,6 +92,7 @@ private void InitAssets(PageEntity page) } if (page.Script.IsNotNullAndWhiteSpace()) { + page.Scripts.Clear(); if (page.Script.StartsWith("[")) { foreach (var item in JsonConvert.DeserializeObject(page.Script)) @@ -378,16 +380,19 @@ public void Move(string id, int position, int oldPosition) public PageEntity GetByPath(string path, bool isPreView) { string formatedPath = FormatPath(path); + PageEntity page = null; if (_cachedPage.ContainsKey(formatedPath)) { - return _cachedPage[formatedPath].Where(m => m.Url.Equals(formatedPath, StringComparison.OrdinalIgnoreCase) && m.IsPublishedPage == !isPreView) + page = _cachedPage[formatedPath].Where(m => m.IsPublishedPage == !isPreView) .OrderByDescending(m => m.PublishDate) .FirstOrDefault(); } - PageEntity page = Get() - .Where(m => m.Url == formatedPath && m.IsPublishedPage == !isPreView) - .OrderByDescending(m => m.PublishDate) - .FirstOrDefault(); + else + { + page = Get().Where(m => m.Url == formatedPath && m.IsPublishedPage == !isPreView) + .OrderByDescending(m => m.PublishDate) + .FirstOrDefault(); + } InitAssets(page); return page; } diff --git a/src/ZKEACMS/PluginBase.cs b/src/ZKEACMS/PluginBase.cs index 172c0eefa..f35fcab65 100644 --- a/src/ZKEACMS/PluginBase.cs +++ b/src/ZKEACMS/PluginBase.cs @@ -151,7 +151,40 @@ public virtual void Setup(params object[] args) if (serviceCollection != null) { ConfigureServices(serviceCollection); - Assembly.DefinedTypes.Where(type => IsController(type)).Each(c => serviceCollection.TryAddTransient(c)); + Assembly.DefinedTypes.Where(type => IsController(type)).Each(c => + { + // RouteAttribute[] controllerRoutes = c.GetCustomAttributes(typeof(RouteAttribute), false) as RouteAttribute[]; + // if (controllerRoutes != null) + // { + // foreach (var route in controllerRoutes) + // { + // RouteDescriptors.Routes.Add(new RouteDescriptor() + // { + // RouteName = $"ControllerRoute_{c.Name}", + // Template = route.Template, + // Priority = 10 + // }); + // } + // } + // MemberInfo[] actions = c.GetMethods(); + // foreach (var action in actions) + // { + // RouteAttribute[] actionRoutes = action.GetCustomAttributes(typeof(RouteAttribute), false) as RouteAttribute[]; + // if (actionRoutes != null) + // { + // foreach (var route in actionRoutes) + // { + // RouteDescriptors.Routes.Add(new RouteDescriptor() + // { + // RouteName = $"ActionRoute_{c.Name}", + // Template = route.Template, + // Priority = 11 + // }); + // } + // } + // } + serviceCollection.TryAddTransient(c); + }); } } else if (item is IMvcBuilder)