初始化提交
This commit is contained in:
155
电子展板/Controller/AmazeUIController.cs
Normal file
155
电子展板/Controller/AmazeUIController.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace 电子展板.Controller
|
||||
{
|
||||
public class AmazeUIController : BaseController
|
||||
{
|
||||
#region css
|
||||
[HttpGet, Route("AmazeUI/css/admin.css")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Resouce("/AmazeUI/css/admin.css", "text/css");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/css/amazeui.css")]
|
||||
public ActionResult AmazeuiCSS()
|
||||
{
|
||||
return Resouce("/AmazeUI/css/amazeui.css", "text/css");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/css/amazeui.flat.css")]
|
||||
public ActionResult AmazeuiFlatCss()
|
||||
{
|
||||
return Resouce("/AmazeUI/css/amazeui.flat.css", "text/css");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/css/amazeui.flat.min.css")]
|
||||
public ActionResult AmazeuiFlatMinCSS()
|
||||
{
|
||||
return Resouce("/AmazeUI/css/amazeui.flat.min.css", "text/css");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/css/amazeui.min.css")]
|
||||
public ActionResult AmazeuiMinCSS()
|
||||
{
|
||||
return Resouce("/AmazeUI/css/amazeui.min.css", "text/css");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/css/app.css")]
|
||||
public ActionResult AppCSS()
|
||||
{
|
||||
return Resouce("/AmazeUI/css/app.css", "text/css");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region fonts
|
||||
[HttpGet, Route("AmazeUI/fonts/FontAwesome.otf")]
|
||||
public ActionResult FontAwesomeotf()
|
||||
{
|
||||
return Resouce("/AmazeUI/fonts/FontAwesome.otf", "font/otf");
|
||||
}
|
||||
[HttpGet, Route("AmazeUI/fonts/fontawesome-webfont.eot")]
|
||||
public ActionResult fontawesome_webfont_eot()
|
||||
{
|
||||
return Resouce("/AmazeUI/fonts/fontawesome-webfont.eot", "font/eot");
|
||||
}
|
||||
[HttpGet, Route("AmazeUI/fonts/fontawesome-webfont.ttf")]
|
||||
public ActionResult fontawesome_webfont_ttf()
|
||||
{
|
||||
return Resouce("/AmazeUI/fonts/fontawesome-webfont.ttf", "font/ttf");
|
||||
}
|
||||
[HttpGet, Route("AmazeUI/fonts/fontawesome-webfont.woff")]
|
||||
public ActionResult fontawesome_webfont_woff()
|
||||
{
|
||||
return Resouce("/AmazeUI/fonts/fontawesome-webfont.woff", "font/woff");
|
||||
}
|
||||
[HttpGet, Route("AmazeUI/fonts/fontawesome-webfont.woff2")]
|
||||
public ActionResult fontawesome_webfont_woff2()
|
||||
{
|
||||
return Resouce("/AmazeUI/fonts/fontawesome-webfont.woff2", "font/woff2");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region i
|
||||
[HttpGet, Route("AmazeUI/i/app-icon72x72@2x.png")]
|
||||
public ActionResult app_icon72x72_2x_png()
|
||||
{
|
||||
return Resouce("/AmazeUI/i/app-icon72x72@2x.png", "image/png");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/i/favicon.png")]
|
||||
public ActionResult favicon_png()
|
||||
{
|
||||
return Resouce("/AmazeUI/i/favicon.png", "image/png");
|
||||
}
|
||||
|
||||
[HttpGet, Route("AmazeUI/i/startup-640x1096.png")]
|
||||
public ActionResult startup_640x1096_png()
|
||||
{
|
||||
return Resouce("/AmazeUI/i/startup-640x1096.png", "image/png");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#region JS
|
||||
[HttpGet, Route("AmazeUI/js/amazeui.ie8polyfill.js")]
|
||||
public ActionResult amazeui_ie8polyfill_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/amazeui.ie8polyfill.js", "application/javascript");
|
||||
}
|
||||
[HttpGet, Route("AmazeUI/js/amazeui.ie8polyfill.min.js")]
|
||||
public ActionResult amazeui_ie8polyfill_min_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/amazeui.ie8polyfill.min.js", "application/javascript");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet, Route("AmazeUI/js/amazeui.js")]
|
||||
public ActionResult amazeui_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/amazeui.js", "application/javascript");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet, Route("AmazeUI/js/amazeui.min.js")]
|
||||
public ActionResult amazeui_min_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/amazeui.min.js", "application/javascript");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpGet, Route("AmazeUI/js/amazeui.widgets.helper.js")]
|
||||
public ActionResult amazeui_widgets_helper_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/amazeui.widgets.helper.js", "application/javascript");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpGet, Route("AmazeUI/js/amazeui.widgets.helper.min.js")]
|
||||
public ActionResult amazeui_widgets_helper_min_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/amazeui.widgets.helper.min.js", "application/javascript");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet, Route("AmazeUI/js/app_js")]
|
||||
public ActionResult app_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/app_js", "application/javascript");
|
||||
}
|
||||
[HttpGet, Route("AmazeUI/js/handlebars.min.js")]
|
||||
public ActionResult handlebars_min_js()
|
||||
{
|
||||
return Resouce("/AmazeUI/js/handlebars.min.js", "application/javascript");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
206
电子展板/Controller/BaseController.cs
Normal file
206
电子展板/Controller/BaseController.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
using JinianNet.JNTemplate;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Results;
|
||||
using System.Xml.Linq;
|
||||
using 电子展板.Utility.Core;
|
||||
using 电子展板.Utility.Extension;
|
||||
using 电子展板.Utility.ResponseModels;
|
||||
|
||||
|
||||
namespace 电子展板.Controller
|
||||
{
|
||||
|
||||
public class BaseController : ApiController
|
||||
{
|
||||
protected ActionResult Content(string content)
|
||||
{
|
||||
return new ActionResult { Content = new StringContent(content, Encoding.UTF8, "text/plain") };
|
||||
}
|
||||
|
||||
protected ActionResult ContentType(string content, string contentType)
|
||||
{
|
||||
return new ActionResult { Content = new StringContent(content, Encoding.UTF8, contentType) };
|
||||
}
|
||||
|
||||
public new ActionResult Redirect(string url)
|
||||
{
|
||||
ActionResult resp = new ActionResult(HttpStatusCode.Moved);
|
||||
string originalString = Request.RequestUri.OriginalString;
|
||||
string pathAndQuery = Request.RequestUri.PathAndQuery;
|
||||
string baseUrl = originalString.Substring(0, originalString.IndexOf(pathAndQuery));
|
||||
resp.Headers.Location = new Uri(baseUrl + url);
|
||||
return resp;
|
||||
}
|
||||
|
||||
protected ActionResult File(string virtualPath, string contentType)
|
||||
{
|
||||
return File(virtualPath, contentType, "HelloWorld");
|
||||
}
|
||||
|
||||
protected ActionResult File(string virtualPath, string contentType, string fileDownloadName)
|
||||
{
|
||||
string physicalPath = MyEnvironment.WebRootPath(virtualPath);
|
||||
return PhysicalFile(physicalPath, contentType, fileDownloadName);
|
||||
}
|
||||
|
||||
protected ActionResult PhysicalFile(string physicalPath, string contentType)
|
||||
{
|
||||
return PhysicalFile(physicalPath, contentType, "HelloWorld");
|
||||
}
|
||||
|
||||
protected ActionResult PhysicalFile(string physicalPath, string contentType, string fileDownloadName)
|
||||
{
|
||||
return File(System.IO.File.OpenRead(physicalPath), contentType, fileDownloadName);
|
||||
}
|
||||
|
||||
|
||||
protected ActionResult File(byte[] fileContents, string contentType)
|
||||
{
|
||||
return File(fileContents, contentType, "HelloWorld");
|
||||
}
|
||||
|
||||
|
||||
protected ActionResult File(byte[] fileContents, string contentType, string fileDownloadName)
|
||||
{
|
||||
ActionResult response = new ActionResult(HttpStatusCode.OK);
|
||||
response.Content = new ByteArrayContent(fileContents);
|
||||
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
|
||||
response.Content.Headers.ContentLength = fileContents.Length;
|
||||
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = HttpUtility.UrlEncode(fileDownloadName)
|
||||
};
|
||||
response.Headers.Add("Access-Control-Expose-Headers", "FileName");
|
||||
response.Headers.Add("FileName", HttpUtility.UrlEncode(fileDownloadName));
|
||||
return response;
|
||||
}
|
||||
|
||||
protected ActionResult File(Stream fileStream, string contentType)
|
||||
{
|
||||
return File(fileStream, contentType, "HelloWorld");
|
||||
}
|
||||
|
||||
protected ActionResult File(Stream fileStream, string contentType, string fileDownloadName)
|
||||
{
|
||||
ActionResult response = new ActionResult(HttpStatusCode.OK);
|
||||
response.Content = new StreamContent(fileStream);
|
||||
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
|
||||
response.Content.Headers.ContentLength = fileStream.Length;
|
||||
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = HttpUtility.UrlEncode(fileDownloadName)
|
||||
};
|
||||
response.Headers.Add("Access-Control-Expose-Headers", "FileName");
|
||||
response.Headers.Add("FileName", HttpUtility.UrlEncode(fileDownloadName));
|
||||
return response;
|
||||
}
|
||||
#region 快捷方法
|
||||
protected ActionResult Success(string message = "恭喜您,操作成功。", object data = null)
|
||||
{
|
||||
return Content(new AjaxResult(ResultType.Success, message, data).ToJson());
|
||||
}
|
||||
protected ActionResult Error(string message = "对不起,操作失败。", object data = null)
|
||||
{
|
||||
return Content(new AjaxResult(ResultType.Error, message, data).ToJson());
|
||||
}
|
||||
protected ActionResult Warning(string message, object data = null)
|
||||
{
|
||||
return Content(new AjaxResult(ResultType.Warning, message, data).ToJson());
|
||||
}
|
||||
protected ActionResult Info(string message, object data = null)
|
||||
{
|
||||
return Content(new AjaxResult(ResultType.Info, message, data).ToJson());
|
||||
}
|
||||
|
||||
|
||||
public ActionResult Json(object obj)
|
||||
{
|
||||
return new ActionResult { Content = new StringContent(obj.ToJson(), Encoding.UTF8, "application/json") };
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ActionResult Text(string str)
|
||||
{
|
||||
//return Content(str, "text/plain");
|
||||
return new ActionResult { Content = new System.Net.Http.StringContent(str, Encoding.UTF8, "text/plain") };
|
||||
|
||||
}
|
||||
|
||||
public ActionResult HtmlStr(string str)
|
||||
{
|
||||
return new ActionResult { Content = new System.Net.Http.StringContent(str, Encoding.UTF8, "text/html") };
|
||||
|
||||
}
|
||||
|
||||
public ActionResult Html(string view)
|
||||
{
|
||||
return Html(view, null);
|
||||
}
|
||||
public ActionResult Resouce(string viewName, string contentType)
|
||||
{
|
||||
string packUri = $"pack://application:,,,/Assets{viewName}";
|
||||
byte[] bytes = null;
|
||||
using (Stream stream = System.Windows.Application.GetResourceStream(new Uri(packUri, UriKind.RelativeOrAbsolute)).Stream)
|
||||
{
|
||||
bytes = new byte[stream.Length];
|
||||
stream.Read(bytes, 0, bytes.Length);
|
||||
}
|
||||
ActionResult response = new ActionResult(HttpStatusCode.OK);
|
||||
response.Content = new ByteArrayContent(bytes);
|
||||
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
|
||||
response.Content.Headers.ContentLength = bytes.Length;
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public ActionResult Html(string view, Dictionary<string, object> dict)
|
||||
{
|
||||
if (!view.StartsWith("/"))
|
||||
view = "/" + view;
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + "Views";
|
||||
|
||||
|
||||
var template = Engine.LoadTemplate(path + view + ".html");
|
||||
|
||||
|
||||
if (dict != null)
|
||||
{
|
||||
foreach (KeyValuePair<string, object> keyValue in dict)
|
||||
{
|
||||
template.Set(keyValue.Key, keyValue.Value);
|
||||
}
|
||||
}
|
||||
var result = template.Render();
|
||||
// return Content(result, "text/html");
|
||||
return new ActionResult { Content = new System.Net.Http.StringContent(result, Encoding.UTF8, "text/html") };
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc
|
||||
{
|
||||
public class ActionResult : System.Net.Http.HttpResponseMessage
|
||||
{
|
||||
public ActionResult() : base(HttpStatusCode.OK)
|
||||
{
|
||||
|
||||
}
|
||||
public ActionResult(HttpStatusCode statusCode) : base(statusCode)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
25
电子展板/Controller/IndexController.cs
Normal file
25
电子展板/Controller/IndexController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace 电子展板.Controller
|
||||
{
|
||||
public class IndexController : BaseController
|
||||
{
|
||||
//[HttpGet, Route("index/error")]
|
||||
//public ActionResult Error()
|
||||
//{
|
||||
// return Html("/Sys/Index/Error");
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 后台首页视图。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet, Route("")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Resouce("/Views/Login.html", "text/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
54
电子展板/Controller/LayUIController.cs
Normal file
54
电子展板/Controller/LayUIController.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace 电子展板.Controller
|
||||
{
|
||||
public class LayUIController : BaseController
|
||||
{
|
||||
#region css
|
||||
[HttpGet, Route("layui/css/layui.css")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Resouce("/layui/css/layui.css", "text/css");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region fonts
|
||||
[HttpGet, Route("layui/font/iconfont.eot")]
|
||||
public ActionResult Iconfont_eot()
|
||||
{
|
||||
return Resouce("/layui/font/iconfont.eot", "font/eot");
|
||||
}
|
||||
[HttpGet, Route("layui/font/iconfont.svg")]
|
||||
public ActionResult iconfont_svg()
|
||||
{
|
||||
return Resouce("/layui/font/iconfont.svg", "text/xml");
|
||||
}
|
||||
[HttpGet, Route("layui/font/iconfont.ttf")]
|
||||
public ActionResult iconfont_ttf()
|
||||
{
|
||||
return Resouce("/layui/font/iconfont.ttf", "font/ttf");
|
||||
}
|
||||
[HttpGet, Route("layui/font/iconfont.woff")]
|
||||
public ActionResult iconfont_woff()
|
||||
{
|
||||
return Resouce("/layui/font/iconfont.woff", "font/woff");
|
||||
}
|
||||
[HttpGet, Route("layui/font/iconfont.woff2")]
|
||||
public ActionResult iconfont_woff2()
|
||||
{
|
||||
return Resouce("/layui/font/iconfont.woff2", "font/woff2");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region JS
|
||||
[HttpGet, Route("layui/layui.js")]
|
||||
public ActionResult layui_js()
|
||||
{
|
||||
return Resouce("/layui/layui.js", "application/javascript");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user