From 3b50120a5c7e220be282d01128dbb08814bdeabd Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4V1LH5\\Jin" Date: Fri, 23 Oct 2020 14:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcookies=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E6=88=90=E5=8A=9F=EF=BC=9B=E4=BF=AE=E5=A4=8D=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E5=9B=A0=E6=9B=B4?= =?UTF-8?q?=E6=96=B0boottable=E5=90=8E=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=80=89=E4=B8=ADid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMCMS.Common/CookiesHelper.cs | 9 +++++- COMCMS.Common/Pages.cs | 2 +- COMCMS.Core/Article/文章.Biz.cs | 30 +++++++++++++++++++ COMCMS.Core/Article/文章栏目.Biz.cs | 3 +- .../Core}/ViewsHelper.cs | 16 +++++----- .../Views/Article/AddArticleCategory.cshtml | 2 +- .../Views/Article/EditArticleCategory.cshtml | 2 +- .../Areas/AdminCP/Views/Index/Main.cshtml | 2 +- COMCMS.Web/Controllers/ArticleController.cs | 5 ++-- COMCMS.Web/wwwroot/js/rtpost.js | 5 +++- 10 files changed, 60 insertions(+), 16 deletions(-) rename {COMCMS.Web/Common => COMCMS.Core/Core}/ViewsHelper.cs (90%) diff --git a/COMCMS.Common/CookiesHelper.cs b/COMCMS.Common/CookiesHelper.cs index a95828d..f0664b8 100644 --- a/COMCMS.Common/CookiesHelper.cs +++ b/COMCMS.Common/CookiesHelper.cs @@ -57,7 +57,14 @@ namespace COMCMS.Common /// public static void ClearCookies(string strKey) { - MyHttpContext.Current.Response.Cookies.Delete(strKey); + CookieOptions op = new CookieOptions + { + Expires = DateTime.Now.AddMinutes(-1), + Path = "/", + HttpOnly = true, + SameSite = SameSiteMode.Lax + }; + MyHttpContext.Current.Response.Cookies.Delete(strKey, op); } #endregion } diff --git a/COMCMS.Common/Pages.cs b/COMCMS.Common/Pages.cs index bebcf31..11c2cf8 100644 --- a/COMCMS.Common/Pages.cs +++ b/COMCMS.Common/Pages.cs @@ -38,7 +38,7 @@ namespace COMCMS.Common StringBuilder strPage = new StringBuilder(); string pageLink = "";// url + "?id=" + HttpContext.Current.Request.QueryString["id"] + "&page={0}"; string strQueryString = MyHttpContext.Current.Request.QueryString.ToString().ToLower(); - if (isRewrite != 5) + if (isRewrite != 5 && isRewrite != 99) url = url.ToLower(); pageLink = url + "?" + strQueryString; string currPage = MyHttpContext.Current.Request.Query["page"]; diff --git a/COMCMS.Core/Article/文章.Biz.cs b/COMCMS.Core/Article/文章.Biz.cs index 34f9cbb..79d7993 100644 --- a/COMCMS.Core/Article/文章.Biz.cs +++ b/COMCMS.Core/Article/文章.Biz.cs @@ -228,6 +228,36 @@ namespace COMCMS.Core else return null; } + + + /// + /// 获取前几条文章 + /// + /// 栏目id + /// 条数 + /// + public static IList
FindTopList(int kid, int records, bool isShowSub = false) + { + if (!isShowSub) + return FindAll(_.KId == kid & _.IsHide == 0, _.Id.Desc(), null, 0, records); + else + { + Expression ex = _.IsHide == 0; + List kids = new List(); + kids.Add(kid); + IList subkinds = ArticleCategory.FindByParentID(kid); + if (subkinds != null && subkinds.Count > 0) + { + foreach (var item in subkinds) + { + kids.Add(item.Id); + } + } + ex &= Article._.KId.In(kids); + + return FindAll(ex, _.Id.Desc(), null, 0, records); + } + } #endregion } } \ No newline at end of file diff --git a/COMCMS.Core/Article/文章栏目.Biz.cs b/COMCMS.Core/Article/文章栏目.Biz.cs index 071515e..1a06ad0 100644 --- a/COMCMS.Core/Article/文章栏目.Biz.cs +++ b/COMCMS.Core/Article/文章栏目.Biz.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Web; using System.Xml.Serialization; +using COMCMS.Common; using NewLife; using NewLife.Data; using NewLife.Log; @@ -359,7 +360,7 @@ namespace COMCMS.Core } else { - re += " > " + string.Format(tpl, "/article/index/" + model.Id, model.KindName); + re += " > " + string.Format(tpl, ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory, kid), model.KindName); if (model.PId != 0) { re = GetNav(model.PId) + re; diff --git a/COMCMS.Web/Common/ViewsHelper.cs b/COMCMS.Core/Core/ViewsHelper.cs similarity index 90% rename from COMCMS.Web/Common/ViewsHelper.cs rename to COMCMS.Core/Core/ViewsHelper.cs index 2d022de..349965c 100644 --- a/COMCMS.Web/Common/ViewsHelper.cs +++ b/COMCMS.Core/Core/ViewsHelper.cs @@ -7,7 +7,7 @@ using COMCMS.Common; using XCode; -namespace COMCMS.Web.Common +namespace COMCMS.Core { /// /// 识图方法 @@ -53,12 +53,14 @@ namespace COMCMS.Web.Common if (model == null) return "javascript:;"; - if (!string.IsNullOrEmpty(model.ArticleKind.FilePath)) + ArticleCategory categoty = ArticleCategory.FindById(model.KId); + + if (categoty != null && !string.IsNullOrEmpty(categoty.FilePath)) { - string url = $"{model.ArticleKind.FilePath}/{model.Id}.html"; + string url = $"{categoty.FilePath}/{model.Id}.html"; if (!string.IsNullOrEmpty(model.FileName)) { - url = $"{model.ArticleKind.FilePath}/{model.FileName}"; + url = $"{categoty.FilePath}/{model.FileName}"; } return url; } @@ -73,7 +75,7 @@ namespace COMCMS.Web.Common /// public static string EchoURL(Product model) { - return $"/product/detail/{model.Id}"; + return $"/product/detail/{model.Id}"; } /// @@ -82,7 +84,7 @@ namespace COMCMS.Web.Common /// /// /// - public static string EchoURL(Utils.CMSType ctype,int id) + public static string EchoURL(Utils.CMSType ctype, int id) { string url = "/"; switch (ctype) @@ -104,7 +106,7 @@ namespace COMCMS.Web.Common url = EchoURL(p); break; default: - url= "/"; + url = "/"; break; } diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml index f936ed0..e21c14b 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml @@ -137,7 +137,7 @@
- +
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml index d2af43c..21483ea 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml @@ -145,7 +145,7 @@
- +
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml index 0544cf2..14bf9b3 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml @@ -156,7 +156,7 @@ 服务器IP地址 - @Utils.GetIP() + @ViewBag.remoteip diff --git a/COMCMS.Web/Controllers/ArticleController.cs b/COMCMS.Web/Controllers/ArticleController.cs index aa093f2..a2f9e18 100644 --- a/COMCMS.Web/Controllers/ArticleController.cs +++ b/COMCMS.Web/Controllers/ArticleController.cs @@ -29,8 +29,9 @@ namespace COMCMS.Web.Controllers { if (Utils.IsInt(model.LinkURL))//如果是数字,则跳转到详情 { - //Redirect($"/aritcle/{model.LinkURL}.html"); - return Redirect($"/Article/Detail/{model.LinkURL}"); + //return Redirect($"/Article/Detail/{model.LinkURL}"); + string linkUrl = ViewsHelper.EchoArticleURL(int.Parse(model.LinkURL)); + return Redirect(linkUrl); } else { diff --git a/COMCMS.Web/wwwroot/js/rtpost.js b/COMCMS.Web/wwwroot/js/rtpost.js index c034ce6..36f7af4 100644 --- a/COMCMS.Web/wwwroot/js/rtpost.js +++ b/COMCMS.Web/wwwroot/js/rtpost.js @@ -354,7 +354,7 @@ function DoAdminLogin(formId, rules, messages) { //后台列表执行批量操作 function doBatchAction(url, title) { - var list = $('#tb_departments').bootstrapTable('getAllSelections'); + var list = $('#tb_departments').bootstrapTable('getSelections'); var ids = []; if (!list || list.length < 1) { layer.alert("请至少选择一条记录!", { icon: 2 }); @@ -364,6 +364,9 @@ function doBatchAction(url, title) { if (item.id) { ids.push(item.id); } + if (item.Id) { + ids.push(item.Id); + } }) layer.confirm('确认要执行批量' + title + '吗?', {