diff --git a/COMCMS.Common/COMCMS.Common.csproj b/COMCMS.Common/COMCMS.Common.csproj index 471d873..4633556 100644 --- a/COMCMS.Common/COMCMS.Common.csproj +++ b/COMCMS.Common/COMCMS.Common.csproj @@ -5,7 +5,7 @@ - + diff --git a/COMCMS.Common/Pages.cs b/COMCMS.Common/Pages.cs new file mode 100644 index 0000000..0e5f005 --- /dev/null +++ b/COMCMS.Common/Pages.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace COMCMS.Common +{ + public class Pages + { + + #region 列表分页 + /// + /// 显示分页2 + /// + /// 每页显示记录数 + /// 总记录数 + /// 当前页码 + /// 分页文件名字,静态:index.html;动态List.aspx + /// 系统urlReWrite方案;99为ajax连接 + /// 最大显示分页数量 + /// 目录名称(系统urlReWrite方案为5必填) + /// + public static string GetPageStr(int pageSize, int recordCount, int page, string url, int isRewrite, int maxShowPage, string filepath = "") + { + if (recordCount < 1) + { + return ""; + } + int pageCount = recordCount / pageSize;//总页数 + if (recordCount % pageSize > 0) + { + pageCount += 1; + } + if (pageCount < 2) + { + return ""; + } + if (page > pageCount) page = pageCount; + 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) + url = url.ToLower(); + pageLink = url + "?" + strQueryString; + string currPage = MyHttpContext.Current.Request.Query["page"]; + string id = MyHttpContext.Current.Request.Query["id"]; + if (isRewrite == 5) + { + url = $"/{filepath}/index.html"; + } + if (url == "memberdownloads.aspx" && isRewrite == 2) + { + string t = MyHttpContext.Current.Request.Query["t"]; + if (string.IsNullOrEmpty(t) || !Utils.IsInt(t)) + t = "1"; + url = string.Format("memberdownloads-{0}.aspx", t); + } + + switch (isRewrite) + { + case 1: + url = url.Replace(".html", ".aspx");//避免设置错之后出现问题 + url = url.Replace(".", "-" + id + "."); + pageLink = url.Replace(".", "-{0}."); + break; + case 2: + url = url.Replace(".aspx", ".html");//避免设置错之后出现问题 + if (!string.IsNullOrEmpty(id)) + url = url.Replace(".", "-" + id + "."); + else + url = url.Replace(".", "-0."); + pageLink = url.Replace(".", "-{0}."); + break; + case 3: + url = url.Replace(".aspx", ".html");//避免设置错之后出现问题 + pageLink = url.Replace(".", "-{0}."); + break; + case 5: + pageLink = url.Replace(".", "-{0}."); + break; + case 99://调用ajax 连接 + pageLink = url; + url = string.Format(pageLink, "1"); + break; + case 0: + default: + //动态链接 + if (pageLink.IndexOf("page=") > 0) + { + pageLink = pageLink.Replace("page=" + currPage, "page={0}"); + } + else + { + pageLink = pageLink + "&page={0}"; + } + url = string.Format(pageLink, "1"); + break; + } + strPage.Append("
"); + if (page != 1)//显示[首页] + { + //strPage.AppendFormat("{1}", url, Lang.GetPagesLangVal("firstpage")); + strPage.AppendFormat("{1}", string.Format(pageLink, 1), "首页"); + } + + if (page > 1)//上一页 + { + if (page == 2)//[首页]要index.html + { + //strPage.AppendFormat("{1}", url, Lang.GetPagesLangVal("prevpage")); + strPage.AppendFormat("{1}", string.Format(pageLink, (page - 1).ToString()), "上一页"); + } + else + { + strPage.AppendFormat("{1}", string.Format(pageLink, (page - 1).ToString()), "上一页"); + } + } + //显示中间所有页数,如果是当前页,则外加一个样式 + string strAllPage = "[{1}]"; + + //显示当前的多少页 + int cureSize = maxShowPage; + int sizes = cureSize / 2;//中间 + int minPage = page - sizes;//最小起始页码 + int maxPage = page + sizes;//最大页码 + if (minPage <= 0) + { + minPage = 1; + maxPage = cureSize; + } + if (maxPage >= pageCount) + { + minPage = pageCount - cureSize + 1; + maxPage = pageCount; + } + + for (int i = 1; i <= pageCount; i++) + { + if (i >= minPage && i <= maxPage)//循环最小到最大页码中间所有页数 + { + if (i == page) + { + strPage.Append(string.Format(strAllPage, "javascritp:;", i.ToString(), "class=\"curr\"")); + } + else + { + if (i == 1)//第一页不能显示成index-1.html + { + if (isRewrite == 4) + { + strPage.Append(string.Format(strAllPage, string.Format(pageLink, i.ToString()), i.ToString(), "")); + } + else + strPage.Append(string.Format(strAllPage, url, "1", "")); + } + else + { + strPage.Append(string.Format(strAllPage, string.Format(pageLink, i.ToString()), i.ToString(), "")); + } + } + } + } + if (page < pageCount)//显示[下一页]/[尾页] + { + strPage.AppendFormat("{1}", string.Format(pageLink, (page + 1).ToString()), "下一页"); + strPage.AppendFormat("{1}", string.Format(pageLink, pageCount.ToString()), "尾页"); + } + strPage.Append("
"); + return strPage.ToString().Replace("[", "").Replace("]", ""); + } + #endregion + } +} diff --git a/COMCMS.Core/COMCMS.Core.csproj b/COMCMS.Core/COMCMS.Core.csproj index 3346f3c..9017645 100644 --- a/COMCMS.Core/COMCMS.Core.csproj +++ b/COMCMS.Core/COMCMS.Core.csproj @@ -6,7 +6,7 @@ - + diff --git a/COMCMS.Web/Areas/AdminCP/Views/Other/AddLink.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Other/AddLink.cshtml index 4388d8f..308f75e 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Other/AddLink.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Other/AddLink.cshtml @@ -81,6 +81,8 @@ diff --git a/COMCMS.Web/Areas/AdminCP/Views/Product/AddProduct.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Product/AddProduct.cshtml index 4172d20..699a3d3 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Product/AddProduct.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Product/AddProduct.cshtml @@ -2,7 +2,7 @@ @{ ViewBag.title = "添加商品详情"; } -
+
@ViewBag.title
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Product/EditProduct.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Product/EditProduct.cshtml index 7f6b063..349c22d 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Product/EditProduct.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Product/EditProduct.cshtml @@ -2,7 +2,7 @@ @{ ViewBag.title = "编辑商品详情"; } -
+
@ViewBag.title
diff --git a/COMCMS.Web/COMCMS.Web.csproj b/COMCMS.Web/COMCMS.Web.csproj index f6abe4a..e136e6e 100644 --- a/COMCMS.Web/COMCMS.Web.csproj +++ b/COMCMS.Web/COMCMS.Web.csproj @@ -5,17 +5,17 @@ - + - - + + - - - - - + + + + + diff --git a/COMCMS.Web/Controllers/ProductController.cs b/COMCMS.Web/Controllers/ProductController.cs new file mode 100644 index 0000000..e86991a --- /dev/null +++ b/COMCMS.Web/Controllers/ProductController.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using COMCMS.Common; +using COMCMS.Core; +using COMCMS.Core.Models; +using COMCMS.Web.Common; +using XCode; + +namespace COMCMS.Web.Controllers +{ + public class ProductController : HomeBaseController + { + #region 分类页面 + [HttpGet] + public IActionResult Index(int id = 0, int page = 1) + { + Category entity = null; + if (id > 0) + { + entity = Category.FindById(id); + if (entity == null) + { + return EchoTip("系统找不到本分类!"); + } + } + else + { + entity = new Category() + { + Id = 0, + KindName = "所有分类", + Keyword = "所有分类", + Description = "所有分类", + PageSize = 10 + }; + } + Expression ex = Product._.IsHide == 0; + if (entity.Id > 0) + { + ex &= Product._.KId == entity.Id; + } + + //计算分页 + int numPerPage, currentPage, startRowIndex; + long totalCount = 0; + + numPerPage = 10; + currentPage = page; + startRowIndex = (currentPage - 1) * numPerPage; + + IList list = Product.FindAll(ex, null, null, startRowIndex, numPerPage); + totalCount = Product.FindCount(ex, null, null, startRowIndex, numPerPage); + + ViewBag.totalCount = totalCount; + ViewBag.page = page; + ViewBag.pagesize = numPerPage; + ViewBag.cfg = cfg; + ViewBag.list = list; + + return View(entity); + } + #endregion + + #region 商品详情 + [HttpGet] + public IActionResult Detail(int id) + { + Product entity = Product.FindById(id); + if (entity == null || entity.IsHide == 1) + { + return EchoTip("系统找不到本记录!"); + } + //文章更多图片列表 + if (!string.IsNullOrEmpty(entity.ItemImg)) + { + string[] arrimg = entity.ItemImg.Split(new string[] { "|||" }, StringSplitOptions.None); + List listimg = new List(); + foreach (string s in arrimg) + { + if (!string.IsNullOrEmpty(s) && Utils.IsImgFilename(s)) + { + listimg.Add(s.Trim()); + } + } + ViewBag.ListImg = listimg; + } + entity.Hits++; + entity.Update(); + ViewBag.cfg = cfg; + ViewBag.category = entity.Category; + + return View(entity); + } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Web/Startup.cs b/COMCMS.Web/Startup.cs index 9b7dbb1..4451f8d 100644 --- a/COMCMS.Web/Startup.cs +++ b/COMCMS.Web/Startup.cs @@ -103,7 +103,7 @@ namespace COMCMS.Web { app.Use(async (context, next) => { - //context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); + context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); await next(); }); diff --git a/COMCMS.Web/Views/Article/Detail.cshtml b/COMCMS.Web/Views/Article/Detail.cshtml index c19b3fa..2314402 100644 --- a/COMCMS.Web/Views/Article/Detail.cshtml +++ b/COMCMS.Web/Views/Article/Detail.cshtml @@ -8,7 +8,24 @@ } +
diff --git a/COMCMS.Web/Views/Article/Detail_About.cshtml b/COMCMS.Web/Views/Article/Detail_About.cshtml index dab4248..4e6c641 100644 --- a/COMCMS.Web/Views/Article/Detail_About.cshtml +++ b/COMCMS.Web/Views/Article/Detail_About.cshtml @@ -7,7 +7,24 @@ int topkid = ViewBag.kind.PId > 0 ? ViewBag.kind.PId : ViewBag.kind.Id; } +
diff --git a/COMCMS.Web/Views/Article/Detail_Contact.cshtml b/COMCMS.Web/Views/Article/Detail_Contact.cshtml index 9f65201..9cbd3eb 100644 --- a/COMCMS.Web/Views/Article/Detail_Contact.cshtml +++ b/COMCMS.Web/Views/Article/Detail_Contact.cshtml @@ -10,7 +10,24 @@ } +
diff --git a/COMCMS.Web/Views/Article/Detail_News.cshtml b/COMCMS.Web/Views/Article/Detail_News.cshtml new file mode 100644 index 0000000..7ced4c2 --- /dev/null +++ b/COMCMS.Web/Views/Article/Detail_News.cshtml @@ -0,0 +1,88 @@ +@model COMCMS.Core.Article +@{ + ViewBag.title = Model.Title; + ViewBag.keywords = Model.Keyword; + ViewBag.description = Model.Description; + IList
alist = Article.FindAll(Article._.KId == Model.KId, Article._.Sequence.Asc(), null, 0, 0); + int topkid = ViewBag.kind.PId > 0 ? ViewBag.kind.PId : ViewBag.kind.Id; + //获取同级分类 + IList sameList = ArticleCategory.FindAll(ArticleCategory._.PId == ViewBag.kind.PId, ArticleCategory._.Rank.Asc(), null, 0, 0); + +} + + + +
+
+
    + @foreach (var k in sameList) + { +
  • @k.KindName
  • + } +
+ + +
+
+ +
+
+
+
+ @Model.Title + @Model.AddTime.ToString("yyyy-MM-dd HH:mm") +
+
+ @Html.Raw(Model.Content) +
+ + +
+ @*
+

+ 上一篇: +

+

+ 下一篇:已经最后一篇 +

+
*@ + [ 返回列表 ] +
+
+
+
+ + diff --git a/COMCMS.Web/Views/Article/Index.cshtml b/COMCMS.Web/Views/Article/Index.cshtml index b690a7b..2217776 100644 --- a/COMCMS.Web/Views/Article/Index.cshtml +++ b/COMCMS.Web/Views/Article/Index.cshtml @@ -9,7 +9,25 @@ } + + @if (Model.PId > 0) { @@ -51,7 +69,7 @@
- @a.Title + @a.Title
} @@ -72,7 +90,7 @@
- + @Html.Raw(Pages.GetPageStr(ViewBag.pagesize, (int)ViewBag.totalCount, ViewBag.page, $"/Article/Index/{Model.Id}" + "?page={0}", 99, 10, ""))
diff --git a/COMCMS.Web/Views/Article/Index_Guestbook.cshtml b/COMCMS.Web/Views/Article/Index_Guestbook.cshtml index 893f6ff..9db2473 100644 --- a/COMCMS.Web/Views/Article/Index_Guestbook.cshtml +++ b/COMCMS.Web/Views/Article/Index_Guestbook.cshtml @@ -9,7 +9,24 @@ } + @if (Model.PId > 0) { diff --git a/COMCMS.Web/Views/Home/Index.cshtml b/COMCMS.Web/Views/Home/Index.cshtml index 1f42a22..d92ab5b 100644 --- a/COMCMS.Web/Views/Home/Index.cshtml +++ b/COMCMS.Web/Views/Home/Index.cshtml @@ -1,33 +1,30 @@ -@{ +@using COMCMS.Core.Models +@{ Config cfg = ViewBag.cfg; ViewBag.title = string.IsNullOrEmpty(cfg.IndexTitle) ? cfg.SiteName : cfg.IndexTitle; ViewBag.keywords = cfg.Keyword; ViewBag.description = cfg.Description; Article about = ViewBag.about; + + IList listLinks = Link.FindAll(Link._.KId == 1, Link._.Sequence.Asc(), null, 0, 0); + + //处理bannr广告 + var bannerPC = Ads.GetSlideAds(1); + var bannerMobile = Ads.GetSlideAds(2); }
@@ -345,143 +266,113 @@
+ @{ + IList
listNews1 = Article.FindAll(Article._.KId == 6, Article._.Sequence.Asc(), null, 0, 4); + }
-
-
- - + } - +
@@ -521,120 +412,36 @@
+ @foreach (var l in listLinks) + {
-
  • - - 8 - -
  • - -
    -
  • - - 7 - -
  • - -
  • - - 6 - -
  • - -
    -
  • - - 4 - -
  • - -
  • - - 3 - -
  • - -
    -
  • - - 2 - -
  • - -
  • - - 1 - -
  • - -
      + }
      -
      - -
    • - - 8 - -
    • - -
      -
    • - - 7 - -
    • - -
    • - - 6 - -
    • - -
      -
    • - - 4 - -
    • - -
    • - - 3 - -
    • - -
      -
    • - - 2 - -
    • - -
    • - - 1 - -
    • - -
        -
        + @foreach (var l in listLinks) + { +
        + +
        + } +
        diff --git a/COMCMS.Web/Views/Product/Detail.cshtml b/COMCMS.Web/Views/Product/Detail.cshtml new file mode 100644 index 0000000..814cf0d --- /dev/null +++ b/COMCMS.Web/Views/Product/Detail.cshtml @@ -0,0 +1,87 @@ +@model COMCMS.Core.Product +@{ + ViewBag.title = Model.Title; + ViewBag.keywords = Model.Keyword; + ViewBag.description = Model.Description; + + IList sameList = Category.FindAll(Category._.PId == 0, Category._.Rank.Asc(), null, 0, 0); + +} + + + +
        +
        +
          + @foreach (var k in sameList) + { +
        • @k.KindName
        • + } +
        + + +
        +
        + +
        +
        +
        +
        + @Model.Title +
        +
        + @if (!string.IsNullOrEmpty(Model.Pic)) + { +

        + } + + + @Html.Raw(Model.Content) + +
        +
        +
        +
        + + +
        +
        +
        + @Html.Raw(Model.Content) +
        +
        +
        + diff --git a/COMCMS.Web/Views/Product/Index.cshtml b/COMCMS.Web/Views/Product/Index.cshtml new file mode 100644 index 0000000..15538ff --- /dev/null +++ b/COMCMS.Web/Views/Product/Index.cshtml @@ -0,0 +1,100 @@ +@model COMCMS.Core.Category +@{ + ViewBag.title = Model.KindName; + ViewBag.keywords = Model.Keyword; + ViewBag.description = Model.Description; + //获取同级分类 + IList sameList = Category.FindAll(Category._.PId == 0, Category._.Rank.Asc(), null, 0, 0); + +} + + + +
        +
        +
          + @foreach (var k in sameList) + { +
        • @k.KindName
        • + } +
        + + +
        +
        + +
        +
        +
        + +
        + +
        + + +
        + @Html.Raw(Pages.GetPageStr(ViewBag.pagesize, (int)ViewBag.totalCount, ViewBag.page, $"/Product/Index/{Model.Id}" + "?page={0}", 99, 10, "")) +
        + +
        + +
        + + +
        +
        +
        + + + \ No newline at end of file diff --git a/COMCMS.Web/wwwroot/images/default/bg_13.png b/COMCMS.Web/wwwroot/images/default/bg_13.png new file mode 100644 index 0000000..770ed97 Binary files /dev/null and b/COMCMS.Web/wwwroot/images/default/bg_13.png differ diff --git a/COMCMS.Web/wwwroot/images/default/coop1.png b/COMCMS.Web/wwwroot/images/default/coop1.png new file mode 100644 index 0000000..75bee17 Binary files /dev/null and b/COMCMS.Web/wwwroot/images/default/coop1.png differ diff --git a/COMCMS.Web/wwwroot/images/default/iprobg.png b/COMCMS.Web/wwwroot/images/default/iprobg.png new file mode 100644 index 0000000..4f5fcc8 Binary files /dev/null and b/COMCMS.Web/wwwroot/images/default/iprobg.png differ diff --git a/COMCMS.Web/wwwroot/js/public.js b/COMCMS.Web/wwwroot/js/public.js index 0e90da2..34f3c6d 100644 --- a/COMCMS.Web/wwwroot/js/public.js +++ b/COMCMS.Web/wwwroot/js/public.js @@ -579,4 +579,17 @@ function doPostMessage() { } }); return false; +} +var menu_show = 0; +function mbNav() { + if (menu_show === 0) { + $('.menu-btn').addClass('menu-on'); + $('.menu-box').slideDown('slow'); + menu_show = 1; + } else { + $('.menu-box').slideUp('slow', function () { + $('.menu-btn').removeClass('menu-on'); + }); + menu_show = 0; + } } \ No newline at end of file diff --git a/Lib.Core/Lib.Core.csproj b/Lib.Core/Lib.Core.csproj index e40ae4f..f8efa83 100644 --- a/Lib.Core/Lib.Core.csproj +++ b/Lib.Core/Lib.Core.csproj @@ -5,7 +5,7 @@ - + diff --git a/README.md b/README.md index 0e7b52d..784c6e8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # COMCMS_NETCORE COMCMS NETCORE版本,一个简单的CMS后台管理系统,暂时不带前台演示,后面有时间会加上。 -主要是演示了.net core 一个系统后台如何搭建。 +主要是演示了.net core 一个系统后台如何搭建。前台如何使用。可以简单的完成一个企业站。通过二次开发,可以支持商城系统、小程序、app服务器端等... ### 技术简要 -- .net core 2.1.5 (请注意升级本地SDK 或者runtime) -- 数据库:Mysql 5.7 +- .net core 2.1.6 (请注意升级本地SDK 或者runtime) +- 数据库:Mysql 5.7 /Mysql 8.0 - ORM:数据库操作使用XCode,目前支持mysql、sqlserver。详细见:https://github.com/NewLifeX/X - 据库驱动使用:MySQL官方驱动,8.0.13 - 后台模板是H+ @@ -34,8 +34,8 @@ COMCMS NETCORE版本,一个简单的CMS后台管理系统,暂时不带前台 ### 演示地址 ``` -演示地址(windows + IIS):[http://123.207.59.192/AdminCP](http://123.207.59.192/AdminCP) -演示地址2(Centos + Nginx):[http://47.106.32.133/AdminCP] +演示地址(windows server 2019 + IIS):前台:http://123.207.59.192 后台:[http://123.207.59.192/AdminCP](http://123.207.59.192/AdminCP) +演示地址2(Centos + Nginx):后台[http://47.106.32.133/AdminCP] 账号密码都是admin @@ -46,4 +46,11 @@ COMCMS NETCORE版本,一个简单的CMS后台管理系统,暂时不带前台 **1600800** ### 贡献者 -漫遊者(hogenwang)、笑笑(xxred)、一只萌新(HTR) \ No newline at end of file +漫遊者(hogenwang)、笑笑(xxred)、一只萌新(HTR) + +### 捐赠 +- 如果您觉得本源码对您有用,可以给我捐赠一杯咖啡 + +![捐赠微信码](https://images.gitee.com/uploads/images/2018/1202/202616_4bcf10db_390643.jpeg "s_wx.jpg") + +![捐赠支付宝码](https://images.gitee.com/uploads/images/2018/1202/202707_fd6b1cb4_390643.jpeg "s_zfb.jpg") \ No newline at end of file