diff --git a/COMCMS.Web/Controllers/ArticleController.cs b/COMCMS.Web/Controllers/ArticleController.cs new file mode 100644 index 0000000..f94716f --- /dev/null +++ b/COMCMS.Web/Controllers/ArticleController.cs @@ -0,0 +1,146 @@ +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 ArticleController : HomeBaseController + { + #region 显示列表 + // GET: Article + [HttpGet] + public IActionResult Index(int id = 0, int page = 1) + { + ArticleCategory model = ArticleCategory.FindById(id); + if (model == null) + { + return AlertAndGoBack("系统找不到本记录"); + } + //如果跳转到地址 + if (!string.IsNullOrEmpty(model.LinkURL)) + { + if (Utils.IsInt(model.LinkURL))//如果是数字,则跳转到详情 + { + //Redirect($"/aritcle/{model.LinkURL}.html"); + Redirect($"/Article/Detail/{model.LinkURL}"); + } + else + { + Redirect(model.LinkURL); + } + + } + if (page < 1) page = 1; + + if (model.IsList == 1) + { + IList
list = new List
(); + int numPerPage, currentPage, startRowIndex; + numPerPage = model.PageSize; + if (page > 0) + currentPage = page; + else + currentPage = 1; + + startRowIndex = (currentPage - 1) * numPerPage; + + var ex = Article._.IsHide != 1 & Article._.IsDel != 1; + + //如果显示下级栏目文章 + if (model.IsShowSubDetail == 1) + { + //获取下级所有栏目 + List allsubkids = new List(); + allsubkids.Add(model.Id); + + IList allkind = ArticleCategory.FindAllSubKinds(model.Id); + if (allkind != null && allkind.Count > 0) + { + foreach (var s in allkind) + { + allsubkids.Add(s.Id); + } + } + ex &= Article._.KId.In(allsubkids); + } + else + ex &= Article._.KId == model.Id; + long totalCount = Article.FindCount(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage); + int pageCount = (int)totalCount / numPerPage;//总页数 + if (totalCount % numPerPage > 0) + { + pageCount += 1; + } + list = Article.FindAll(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage); + ViewBag.list = list;//列表 + //分页信息 + ViewBag.totalCount = totalCount; + ViewBag.pageCount = pageCount; + ViewBag.page = page; + ViewBag.pagesize = numPerPage; + } + + ViewBag.cfg = cfg; + string templatesname = "";//模板名称 + if (!string.IsNullOrEmpty(model.TemplateFile)) + templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", ""); + + return View(model); + + } + #endregion + + #region 显示详情 + [HttpGet] + public IActionResult Detail(int id) + { + Article entity = Article.Find(Article._.Id == id); + if (entity == null) + { + return AlertAndGoBack("系统找不到本记录!"); + } + ArticleCategory kind = ArticleCategory.FindById(entity.KId); + if (kind == null) + { + return AlertAndGoBack("系统找不到本文章栏目!"); + } + //增加点击 + entity.Hits++; + entity.Update(); + if (!string.IsNullOrEmpty(entity.LinkURL)) + { + //return Content(entity.LinkURL); + Redirect(entity.LinkURL); + } + ViewBag.kind = kind; + ViewBag.cfg = cfg; + //文章更多图片列表 + 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; + } + string templatesname = "";//模板名称 + if (!string.IsNullOrEmpty(kind.TemplateFile)) + templatesname = kind.DetailTemplateFile.Replace(".cshtml", "").Replace(".aspx", ""); + + return View(entity); + } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs index b86f93b..6a236db 100644 --- a/COMCMS.Web/Controllers/HomeController.cs +++ b/COMCMS.Web/Controllers/HomeController.cs @@ -25,6 +25,7 @@ namespace COMCMS.Web.Controllers public IActionResult Index() { ViewBag.cfg = cfg; + ViewBag.about = Article.FindById(1);//关于我们 return View(); } #endregion diff --git a/COMCMS.Web/Views/Home/Index.cshtml b/COMCMS.Web/Views/Home/Index.cshtml index e9e3ea9..3ae622e 100644 --- a/COMCMS.Web/Views/Home/Index.cshtml +++ b/COMCMS.Web/Views/Home/Index.cshtml @@ -1,678 +1,680 @@ -@using COMCMS.Core -@{ - Config cfg = ViewBag.cfg; - ViewBag.title = string.IsNullOrEmpty(cfg.IndexTitle) ? cfg.SiteName : cfg.IndexTitle; - ViewBag.keywords = cfg.Keyword; - ViewBag.description = cfg.Description; -} - - - - - - - -
- -
-
-
    -
  • -
    -
    - -
    -
    -
    -
    -

    - 基于Asp.net Core开发 - Development with Asp.net core -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    -
    -
    -

    - 完全开源 - Open source -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    -
    -
    -

    - 应用广泛 - Use everywhere -

    -
    -
    -
  • -
-
-
- -
-
-
    -
  • -
    -
    - -
    -
    - -
    -
    -

    - 著名品牌供应商 - supplier of famous brands -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    - -
    -
    -

    - 公司成立20年 - founded 20 years -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    - -
    -
    -

    - 业务涵盖广东省 - Business covers Guangdong -

    -
    -
    -
  • -
-
-
- - -
-
-
-

- 公司简介 - company profile -

-
- -
-
-
- - 关于我们 - -
-
-
-

- 上的放进塑料袋放进... -

- 查看详情 -
-
-
-
- - -
-
-
-

- 产品展示 - product display -

-
- - - - 查看更多 -
-
- - -
-
-
-

- 新闻资讯 - news information -

-
-
-
-
    -
  • 公司新闻
  • -
  • 行业资讯
  • -
-
-
- - -
-
-
- - -
- - -
-
-
-

- 合作伙伴 - cooperative partner -

-
-
- -
-
-
-
- -
  • - - 8 - -
  • - -
    -
  • - - 7 - -
  • - -
  • - - 6 - -
  • - -
    -
  • - - 4 - -
  • - -
  • - - 3 - -
  • - -
    -
  • - - 2 - -
  • - -
  • - - 1 - -
  • - -
      -
      -
      -
      -
      -
      -
      - -
    • - - 8 - -
    • - -
      -
    • - - 7 - -
    • - -
    • - - 6 - -
    • - -
      -
    • - - 4 - -
    • - -
    • - - 3 - -
    • - -
      -
    • - - 2 - -
    • - -
    • - - 1 - -
    • - -
        -
        -
        -
        -
        - - - -
        - - -
        -
        +@{ + 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; +} + + + + + + + +
        + +
        +
        +
          +
        • +
          +
          + +
          +
          +
          +
          +

          + 基于Asp.net Core开发 + Development with Asp.net core +

          +
          +
          +
        • +
        • +
          +
          + +
          +
          +
          +
          +

          + 完全开源 + Open source +

          +
          +
          +
        • +
        • +
          +
          + +
          +
          +
          +
          +

          + 应用广泛 + Use everywhere +

          +
          +
          +
        • +
        +
        +
        + +
        +
        +
          +
        • +
          +
          + +
          +
          + +
          +
          +

          + 著名品牌供应商 + supplier of famous brands +

          +
          +
          +
        • +
        • +
          +
          + +
          +
          + +
          +
          +

          + 公司成立20年 + founded 20 years +

          +
          +
          +
        • +
        • +
          +
          + +
          +
          + +
          +
          +

          + 业务涵盖广东省 + Business covers Guangdong +

          +
          +
          +
        • +
        +
        +
        + + +
        +
        +
        +

        + 公司简介 + company profile +

        +
        + +
        +
        +
        + + 关于我们 + +
        +
        +
        +

        + @(Utils.CutString(Utils.NoHTML(about.Content),700)) +

        + 查看详情 +
        +
        +
        +
        + + +
        +
        +
        +

        + 产品展示 + product display +

        +
        + + + + 查看更多 +
        +
        + + +
        +
        +
        +

        + 新闻资讯 + news information +

        +
        +
        +
        +
          +
        • 公司新闻
        • +
        • 行业资讯
        • +
        +
        +
        + + +
        +
        +
        + + +
        + + +
        +
        +
        +

        + 合作伙伴 + cooperative partner +

        +
        +
        + +
        +
        +
        +
        + +
      • + + 8 + +
      • + +
        +
      • + + 7 + +
      • + +
      • + + 6 + +
      • + +
        +
      • + + 4 + +
      • + +
      • + + 3 + +
      • + +
        +
      • + + 2 + +
      • + +
      • + + 1 + +
      • + +
          +
          +
          +
          +
          +
          +
          + +
        • + + 8 + +
        • + +
          +
        • + + 7 + +
        • + +
        • + + 6 + +
        • + +
          +
        • + + 4 + +
        • + +
        • + + 3 + +
        • + +
          +
        • + + 2 + +
        • + +
        • + + 1 + +
        • + +
            +
            +
            +
            +
            + + + +
            + + +
            +
            \ No newline at end of file diff --git a/COMCMS.Web/Views/Shared/_Layout.cshtml b/COMCMS.Web/Views/Shared/_Layout.cshtml index a233093..4d558be 100644 --- a/COMCMS.Web/Views/Shared/_Layout.cshtml +++ b/COMCMS.Web/Views/Shared/_Layout.cshtml @@ -29,17 +29,24 @@
            @RenderBody() + @{ + IList allArticleCategorys = ArticleCategory.GetListTree(0, -1, false, false); + IList
            aboutlist = Article.FindAll(Article._.KId == 1 & Article._.IsHide ==0, Article._.Sequence.Asc(), null, 0, 0); + + IList allCategorys = Category.FindAll(Category._.PId==0 & Category._.IsHide ==0, Category._.Rank.Asc(),null,0,0); + }