mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	实现加载md文档内容
This commit is contained in:
		@@ -2,7 +2,10 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using FreeSql.Site.DAL;
 | 
			
		||||
using FreeSql.Site.Entity;
 | 
			
		||||
using FreeSql.Site.UI.Controllers;
 | 
			
		||||
using FreeSql.Site.UI.Models;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
 | 
			
		||||
@@ -11,17 +14,49 @@ namespace FreeSql.Site.UI.Areas.Doc.Controllers
 | 
			
		||||
    [Area("Doc")]
 | 
			
		||||
    public class DocumentsController : BaseController
 | 
			
		||||
    {
 | 
			
		||||
        // GET: Documents
 | 
			
		||||
        public IActionResult Index()
 | 
			
		||||
        public DocumentTypeDAL DocumentTypeDAL { get; set; }
 | 
			
		||||
 | 
			
		||||
        public DocumentContentDAL DocumentContentDAL { get; set; }
 | 
			
		||||
 | 
			
		||||
        public DocumentsController()
 | 
			
		||||
        {
 | 
			
		||||
           ViewBag.DocumentList = new FreeSql.Site.DAL.DocumentTypeDAL().Query(d => d.ID != 0);
 | 
			
		||||
            this.DocumentTypeDAL = new DocumentTypeDAL();
 | 
			
		||||
            this.DocumentContentDAL = new DocumentContentDAL();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // GET: Documents
 | 
			
		||||
        public IActionResult Index(int id = 1)
 | 
			
		||||
        {
 | 
			
		||||
            var typeList = DocumentTypeDAL.Query(d => d.ID != 0);
 | 
			
		||||
            var contentlist = DocumentContentDAL.Query(d => d.Status == 1);
 | 
			
		||||
 | 
			
		||||
            //适应两层结构即可
 | 
			
		||||
            var query = (from p in typeList
 | 
			
		||||
                         where p.UpID == null || p.UpID == 0
 | 
			
		||||
                         select new TreeData(p, typeList).AddChildrens(GetContentTreeData(p.ID, contentlist), (tid) => GetContentTreeData(tid, contentlist))).ToList();
 | 
			
		||||
 | 
			
		||||
            ViewBag.DocumentList = query;
 | 
			
		||||
            ViewBag.DocID = id;
 | 
			
		||||
            return View();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<TreeData> GetContentTreeData(int id, List<DocumentContent> contentlist)
 | 
			
		||||
        {
 | 
			
		||||
            return contentlist.Where(w => w.TypeID == id).Select(s => new TreeData
 | 
			
		||||
            {
 | 
			
		||||
                id = s.ID,
 | 
			
		||||
                text = s.DocTitle,
 | 
			
		||||
                datatype = 1
 | 
			
		||||
            }).ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // GET: Documents/Details/5
 | 
			
		||||
        public ActionResult Details(int id)
 | 
			
		||||
        {
 | 
			
		||||
            return View();
 | 
			
		||||
            ViewBag.DocumentID = id;
 | 
			
		||||
            var doc = this.DocumentContentDAL.GetByOne(w => w.ID == id);
 | 
			
		||||
            ViewBag.DocumentInfo = doc;
 | 
			
		||||
            return this.PartialView();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // GET: Documents/Create
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,71 @@
 | 
			
		||||
@{
 | 
			
		||||
    Layout = null;
 | 
			
		||||
    var documentinfo = (FreeSql.Site.Entity.DocumentContent)ViewBag.DocumentInfo;
 | 
			
		||||
}
 | 
			
		||||
@if (ViewBag.DocumentInfo == null)
 | 
			
		||||
{
 | 
			
		||||
    <span style="font-size:20px; color:red;">
 | 
			
		||||
        编号: @ViewBag.DocumentID
 | 
			
		||||
    </span>
 | 
			
		||||
    <span>测试没有</span>
 | 
			
		||||
}
 | 
			
		||||
else
 | 
			
		||||
{
 | 
			
		||||
    <h1 class="site-h1">@*开始使用 - 入门指南*@@documentinfo.DocTitle</h1>
 | 
			
		||||
    <div id="details_content" >
 | 
			
		||||
        @*<markdown>@documentinfo.DocContent</markdown>*@
 | 
			
		||||
        @documentinfo.DocContent
 | 
			
		||||
        @*<blockquote class="layui-elem-quote">
 | 
			
		||||
                lFreeSql 是轻量化、可扩展和跨平台版的 .NETStandard 数据访问技术实现。<br />
 | 
			
		||||
                FreeSql 可用作对象关系映射程序 (O/RM),以便于开发人员能够使用 .NETStandard 对象来处理数据库,不必经常编写大部分数据访问代码。<br />
 | 
			
		||||
                FreeSql 支持 MySql/SqlServer/PostgreSQL 数据库技术实现。<br />
 | 
			
		||||
                FreeSql 打造 .NETCore 最方便的 ORM,dbfirst codefirst混合使用,codefirst模式下的开发阶段,建好实体不用执行任何操作,就能创建表和修改字段,dbfirst模式下提供api+模板,自定义生成代码,作者提供了3种模板。<br />
 | 
			
		||||
                FreeSql 目前仍处在测试阶段,您可以持续关注或者参与给出宝贵意见,QQ群:4336577
 | 
			
		||||
            </blockquote>
 | 
			
		||||
            <fieldset class="layui-elem-field layui-field-title site-title">
 | 
			
		||||
                <legend><a name="compatibility">兼容性和面向场景</a></legend>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            <div class="site-text">
 | 
			
		||||
                <p>1. 官网首页下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    您可以通过 <a href="#">Github</a> 下载到FreeSql的最新版:
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li>  ├─css //css目录</li><li>  │  │─modules //模块css目录(一般如果模块相对较大,我们会单独提取,比如下面三个:)</li><li>  │  │  ├─laydate</li><li>  │  │  ├─layer</li><li>  │  │  └─layim</li><li>  │  └─layui.css //核心样式文件</li><li>  ├─font  //字体图标目录</li><li>  ├─images //图片资源目录(目前只有layim和编辑器用到的GIF表情)</li><li>  │─lay //模块核心目录</li><li>  │  └─modules //各模块组件</li><li>  │─layui.js //基础核心库</li><li>  └─layui.all.js //包含layui.js和所有模块的合并文件</li><li>     </li></ol></pre>
 | 
			
		||||
                <p>2. Git 仓库下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    你也可以通过 <a href="https://github.com/2881099/FreeSql/" target="_blank">GitHub</a> 或 <a href="https://gitee.com/sentsin/layui" target="_blank">码云</a> 得到 FreeSql 的完整开发包,以便于你进行二次开发,或者 Fork FreeSql 为我们贡献方案
 | 
			
		||||
                    <br><br>
 | 
			
		||||
                    <iframe src="//ghbtns.com/github-btn.html?user=2881099&repo=FreeSql&type=watch&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="156px" height="30px"></iframe>
 | 
			
		||||
                    <iframe src="//ghbtns.com/github-btn.html?user=2881099&repo=FreeSql&type=fork&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="156px" height="30px"></iframe>
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <p>3. npm 安装</p>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view layui-code-notepad" lay-skin="notepad"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li> </li><li>Install-Package FreeSql    </li><li>      </li></ol></pre>
 | 
			
		||||
                <p>一般用于 WebPack 管理</p>
 | 
			
		||||
            </div>
 | 
			
		||||
            <fieldset class="layui-elem-field layui-field-title site-title">
 | 
			
		||||
                <legend><a name="quickstart">快速上手</a></legend>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            <div class="site-text">
 | 
			
		||||
                <p>1. 官网首页下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    你可以在我们的 <a href="http://www.layui.com/">官网首页</a> 下载到 layui 的最新版,它经过了自动化构建,更适合用于生产环境。目录结构如下:
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li>  ├─css //css目录</li><li>  │  │─modules //模块css目录(一般如果模块相对较大,我们会单独提取,比如下面三个:)</li><li>  │  │  ├─laydate</li><li>  │  │  ├─layer</li><li>  │  │  └─layim</li><li>  │  └─layui.css //核心样式文件</li><li>  ├─font  //字体图标目录</li><li>  ├─images //图片资源目录(目前只有layim和编辑器用到的GIF表情)</li><li>  │─lay //模块核心目录</li><li>  │  └─modules //各模块组件</li><li>  │─layui.js //基础核心库</li><li>  └─layui.all.js //包含layui.js和所有模块的合并文件</li><li>     </li></ol></pre>
 | 
			
		||||
            </div>*@
 | 
			
		||||
    </div>
 | 
			
		||||
    <script>
 | 
			
		||||
        marked.setOptions({
 | 
			
		||||
            renderer: new marked.Renderer(),
 | 
			
		||||
            gfm: true,
 | 
			
		||||
            tables: true,
 | 
			
		||||
            breaks: true,
 | 
			
		||||
            pedantic: false,
 | 
			
		||||
            sanitize: false,
 | 
			
		||||
            smartLists: true,
 | 
			
		||||
            smartypants: false,
 | 
			
		||||
        });
 | 
			
		||||
        document.getElementById('details_content').innerHTML =
 | 
			
		||||
            marked($("#details_content").html());
 | 
			
		||||
        $("#details_content").show();
 | 
			
		||||
    </script>
 | 
			
		||||
}
 | 
			
		||||
@@ -1,61 +1,62 @@
 | 
			
		||||
@{
 | 
			
		||||
    //ViewBag.Title = Model.ResultInfo.CurrentType.TypeName + "-" + Model.ResultInfo.Master.MasterName + PubConst.SitePrefix;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
<div class="layui-main site-inline">
 | 
			
		||||
    <div class="site-tree">
 | 
			
		||||
        <ul class="layui-tree">
 | 
			
		||||
            <li><h2>基础说明</h2></li>
 | 
			
		||||
            @foreach (var item in (List<FreeSql.Site.Entity.DocumentType>)ViewBag.DocumentList)
 | 
			
		||||
            @foreach (var item in (List<FreeSql.Site.UI.Models.TreeData>)ViewBag.DocumentList)
 | 
			
		||||
            {
 | 
			
		||||
                <li class="site-tree-noicon">
 | 
			
		||||
                    <a href="#1"><cite>@item.TypeName</cite></a>
 | 
			
		||||
                </li>
 | 
			
		||||
                <li><h2>@item.text</h2></li>
 | 
			
		||||
                foreach (var children in item.children)
 | 
			
		||||
                {
 | 
			
		||||
                    if (children.datatype == 1)
 | 
			
		||||
                    {
 | 
			
		||||
                        <li class="site-tree-noicon">
 | 
			
		||||
                            <a href="?id=@(children.id)"><cite>@children.text</cite></a>
 | 
			
		||||
                        </li>
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        <li class="site-tree-noicon">
 | 
			
		||||
                            <a href="#@(children.id)"><cite>> @children.text</cite></a>
 | 
			
		||||
                        </li>
 | 
			
		||||
                        foreach (var children2 in children.children)
 | 
			
		||||
                        {
 | 
			
		||||
                            <li class="site-tree-noicon">
 | 
			
		||||
                                <a href="?id=@(children2.id)"><cite>    @children2.text</cite></a>
 | 
			
		||||
                            </li>
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        </ul>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="site-content">
 | 
			
		||||
        <h1 class="site-h1">开始使用 - 入门指南</h1>
 | 
			
		||||
        <div>
 | 
			
		||||
            <blockquote class="layui-elem-quote">
 | 
			
		||||
                lFreeSql 是轻量化、可扩展和跨平台版的 .NETStandard 数据访问技术实现。<br />
 | 
			
		||||
                FreeSql 可用作对象关系映射程序 (O/RM),以便于开发人员能够使用 .NETStandard 对象来处理数据库,不必经常编写大部分数据访问代码。<br />
 | 
			
		||||
                FreeSql 支持 MySql/SqlServer/PostgreSQL 数据库技术实现。<br />
 | 
			
		||||
                FreeSql 打造 .NETCore 最方便的 ORM,dbfirst codefirst混合使用,codefirst模式下的开发阶段,建好实体不用执行任何操作,就能创建表和修改字段,dbfirst模式下提供api+模板,自定义生成代码,作者提供了3种模板。<br />
 | 
			
		||||
                FreeSql 目前仍处在测试阶段,您可以持续关注或者参与给出宝贵意见,QQ群:4336577
 | 
			
		||||
            </blockquote>
 | 
			
		||||
            <fieldset class="layui-elem-field layui-field-title site-title">
 | 
			
		||||
                <legend><a name="compatibility">兼容性和面向场景</a></legend>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            <div class="site-text">
 | 
			
		||||
                <p>1. 官网首页下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    您可以通过 <a href="#">Github</a> 下载到FreeSql的最新版:
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li>  ├─css //css目录</li><li>  │  │─modules //模块css目录(一般如果模块相对较大,我们会单独提取,比如下面三个:)</li><li>  │  │  ├─laydate</li><li>  │  │  ├─layer</li><li>  │  │  └─layim</li><li>  │  └─layui.css //核心样式文件</li><li>  ├─font  //字体图标目录</li><li>  ├─images //图片资源目录(目前只有layim和编辑器用到的GIF表情)</li><li>  │─lay //模块核心目录</li><li>  │  └─modules //各模块组件</li><li>  │─layui.js //基础核心库</li><li>  └─layui.all.js //包含layui.js和所有模块的合并文件</li><li>     </li></ol></pre>
 | 
			
		||||
                <p>2. Git 仓库下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    你也可以通过 <a href="https://github.com/2881099/FreeSql/" target="_blank">GitHub</a> 或 <a href="https://gitee.com/sentsin/layui" target="_blank">码云</a> 得到 FreeSql 的完整开发包,以便于你进行二次开发,或者 Fork FreeSql 为我们贡献方案
 | 
			
		||||
                    <br><br>
 | 
			
		||||
                    <iframe src="//ghbtns.com/github-btn.html?user=2881099&repo=FreeSql&type=watch&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="156px" height="30px"></iframe>
 | 
			
		||||
                    <iframe src="//ghbtns.com/github-btn.html?user=2881099&repo=FreeSql&type=fork&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="156px" height="30px"></iframe>
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <p>3. npm 安装</p>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view layui-code-notepad" lay-skin="notepad"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li> </li><li>Install-Package FreeSql    </li><li>      </li></ol></pre>
 | 
			
		||||
                <p>一般用于 WebPack 管理</p>
 | 
			
		||||
            </div>
 | 
			
		||||
            <fieldset class="layui-elem-field layui-field-title site-title">
 | 
			
		||||
                <legend><a name="quickstart">快速上手</a></legend>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            <div class="site-text">
 | 
			
		||||
                <p>1. 官网首页下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    你可以在我们的 <a href="http://www.layui.com/">官网首页</a> 下载到 layui 的最新版,它经过了自动化构建,更适合用于生产环境。目录结构如下:
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li>  ├─css //css目录</li><li>  │  │─modules //模块css目录(一般如果模块相对较大,我们会单独提取,比如下面三个:)</li><li>  │  │  ├─laydate</li><li>  │  │  ├─layer</li><li>  │  │  └─layim</li><li>  │  └─layui.css //核心样式文件</li><li>  ├─font  //字体图标目录</li><li>  ├─images //图片资源目录(目前只有layim和编辑器用到的GIF表情)</li><li>  │─lay //模块核心目录</li><li>  │  └─modules //各模块组件</li><li>  │─layui.js //基础核心库</li><li>  └─layui.all.js //包含layui.js和所有模块的合并文件</li><li>     </li></ol></pre>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        @Html.Action("Details", new RouteValueDictionary { { "id", ViewBag.DocID } })
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
<div class="site-tree-mobile layui-hide">
 | 
			
		||||
    <i class="layui-icon"></i>
 | 
			
		||||
</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
        //window.onhashchange = function () {
 | 
			
		||||
        //    var hash = location.hash;
 | 
			
		||||
        //    if (hash.search(/^#C\d+$/g) == 0) {
 | 
			
		||||
        //        var docid = hash.replace('C', '');
 | 
			
		||||
 | 
			
		||||
        //        $(".site-content").load("/Doc/Documents/Details", { id: docid }, function () {
 | 
			
		||||
        //            alert(1);
 | 
			
		||||
        //        });
 | 
			
		||||
        //        //$.ajax({
 | 
			
		||||
        //        //    type: "GET",
 | 
			
		||||
        //        //    url: "/Doc/Documents/Details",
 | 
			
		||||
        //        //    data: { id: docid },
 | 
			
		||||
        //        //    dataType: "html",
 | 
			
		||||
        //        //    success: function (data) {
 | 
			
		||||
        //        //        $(".site-content").html(data);
 | 
			
		||||
        //        //    }
 | 
			
		||||
        //        //});
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
</script>
 | 
			
		||||
@@ -0,0 +1,7 @@
 | 
			
		||||
@using FreeSql.Site.UI;
 | 
			
		||||
@using FreeSql.Site.UI.Models;
 | 
			
		||||
@using FreeSql.Site.UI.Common;
 | 
			
		||||
@using Microsoft.AspNetCore.Routing;
 | 
			
		||||
@using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
 | 
			
		||||
@addTagHelper "FreeSql.Site.UI.Common.TagHelpers.MarkdownTagHelper, FreeSql.Site.UI"
 | 
			
		||||
		Reference in New Issue
	
	Block a user