溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

ASP.NET MVC 開(kāi)源建站系統(tǒng) ZKEACMS 推薦,從此網(wǎng)站“拼”起來(lái)

發(fā)布時(shí)間:2020-06-25 16:04:48 來(lái)源:網(wǎng)絡(luò) 閱讀:545 作者:seriawei 欄目:編程語(yǔ)言

一個(gè)挺有意思的項(xiàng)目,跟拼圖一樣的創(chuàng)建網(wǎng)站,先來(lái)幾張GIF感受一下:



ASP.NET MVC 開(kāi)源建站系統(tǒng) ZKEACMS 推薦,從此網(wǎng)站“拼”起來(lái)

ASP.NET MVC 開(kāi)源建站系統(tǒng) ZKEACMS 推薦,從此網(wǎng)站“拼”起來(lái)

ASP.NET MVC 開(kāi)源建站系統(tǒng) ZKEACMS 推薦,從此網(wǎng)站“拼”起來(lái)




官方地址:http://www.zkea.net/zkeacms

下載地址:https://github.com/SeriaWei/ASP.NET-MVC-CMS/releases

GitHub:https://github.com/SeriaWei/ASP.NET-MVC-CMS

Git@OCS:http://git.oschina.net/seriawei/ASP.NET-MVC-CMS


演示地址:http://demo.zkea.net/  

后臺(tái):http://demo.zkea.net/admin 

用戶(hù)名,密碼:admin


ZKEACMS是基于EasyFrameWork,使用ASP.NET MVC4開(kāi)發(fā)的開(kāi)源CMS。

ZKEACMS一個(gè)內(nèi)容管理軟件(網(wǎng)站)。ZKEACMS不僅只是管理內(nèi)容,更是重新定義了布局、頁(yè)面和組件,讓用戶(hù)可以自由規(guī)劃頁(yè)面的布局,頁(yè)面和內(nèi)容。

ZKEACMS使用可視化編輯設(shè)計(jì),真正做到所見(jiàn)即所得,可直接在預(yù)覽頁(yè)面上設(shè)計(jì)頁(yè)面。

ZKEACMS采用插件式設(shè)計(jì),支持?jǐn)U展新插件。

架設(shè)環(huán)境:

Windows server 2003,IIS 6 或以上

MsSql 2005 或以上

.Net FrameWork 4.0,MVC 4

開(kāi)發(fā)環(huán)境

Microsoft VisualStudio 2013

Microsoft Sql Server 2005 以上

關(guān)于項(xiàng)目的特性大家到官網(wǎng)去看看就好了,這里主要講講Code:

資源管理與應(yīng)用(JS/CSS):

資源定義


script("jQuery").Include("~/Scripts/jquery-1.11.2.min.js", "~/Scripts/jquery-1.11.2.min.js").RequiredAtHead();
script("bootStrap").Include("~/Content/bootstrap/js/bootstrap.js", "~/Content/bootstrap/js/bootstrap.min.js").RequiredAtFoot();
script("jQueryUi").Include("~/Scripts/jquery-ui/jquery-ui.js", "~/Scripts/jquery-ui/jquery-ui.min.js");


style("bootStrap").Include("~/Content/bootstrap/css/bootstrap.css", "~/Content/bootstrap/css/bootstrap.min.css").RequiredAtHead();
style("bootStrapTheme").Include("~/Content/bootstrap/css/bootstrap-theme.css", "~/Content/bootstrap/css/bootstrap-theme.min.css").RequiredAtHead();
style("Site").Include("~/Content/Site.css", "~/Content/Site.min.css").RequiredAtFoot();

這里是對(duì)腳本和樣式文件的定義,顯示調(diào)用RequiredAtHead()/RequiredAtFoot(),則無(wú)需主動(dòng)加到頁(yè)面中,默認(rèn)都會(huì)使用該資源文件,加到頁(yè)面的開(kāi)頭或者結(jié)尾。

資源的使用(.cshtml):

Style.Reqiured("Site").AtHead();
Script.Reqiured("jQueryUi").AtFoot();


@using (Script.AtFoot())
{    
    <script type="text/javascript">
        function Create(xxx) {
           
        }    
    </script>
}

ASP.NET MVC 開(kāi)源建站系統(tǒng) ZKEACMS 推薦,從此網(wǎng)站“拼”起來(lái)

為什么需要這樣管理資源?因?yàn)閆KEACMS的頁(yè)面是由不同的組件構(gòu)成的,完全由用戶(hù)選擇在頁(yè)面中顯示什么組件,而不同的組件會(huì)需要不同的JS或CSS,因此需要?jiǎng)討B(tài)加載這些資源文件。

簡(jiǎn)單的數(shù)據(jù)和視圖配置(元數(shù)據(jù)注冊(cè)):


    [DataConfigure(typeof(CarouselEntityMetaData))]    
    public class CarouselEntity : EditorEntity
    {        
    public long? ID { get; set; }        
    public int? Height { get; set; }        
    public List<CarouselItemEntity> CarouselItems { get; set; }

    }    
    class CarouselEntityMetaData : DataViewMetaData<CarouselEntity>
    {        
        protected override void DataConfigure()
        {
            DataTable("Carousel");
            DataConfig(m => m.ID).AsIncreasePrimaryKey();
            DataConfig(m => m.CarouselItems).Ignore();
        }        protected override void ViewConfigure()
        {
            ViewConfig(m => m.ID).AsHidden();
            ViewConfig(m => m.CarouselItems).AsListEditor();
            ViewConfig(m => m.Height).AsHidden();
        }
    }


編輯頁(yè)面直接使用EditorForModel:

在視圖配置完以后(.AsTextBox(),.AsDropDownList()...) 直接調(diào)用EditorForModel即可自動(dòng)生成表單:

@Html.EditorForModel()

列表頁(yè)面:

@(
 Html.Grid<ArticleEntity>().SetColumnTemplate(col => {
     col.Add(m => m.Title, "<a href='"+Url.Action("Edit")+"?ID={ID}'>{Title}</a>");
 }).SetAsToolBar("#toolBar").ShowCheckbox(m=>m.ID).OrderBy(m=>m.PublishDate, OrderType.Descending)
)

FilterConfig:

以前我們這樣寫(xiě):

[ViewDataArticleType]public override ActionResult Edit(ArticleEntity entity)

現(xiàn)在我們這樣寫(xiě):

Registry.Register<ArticleController, ViewDataArticleTypeAttribute>(m => m.Edit(null));

靈活的Service


Service.Add(entity);
Service.Count(m=>m.Id=1);
Service.Delete(primaryKey);
Service.Delete(m=>m.Id=1);
Service.Get(primaryKey);
Service.Get(m=>m.Id=1);
...

實(shí)現(xiàn)卻如此簡(jiǎn)單:

public class CarouselService : ServiceBase<CarouselEntity>{
}

。。。。。。

寫(xiě)得很簡(jiǎn)單,可是還有很多,有興趣的就下下來(lái)玩玩吧。


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI