@@ -163,5 +164,29 @@
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
DoPost("editArticleKindForm");
CKEDITOR.replace('KindInfo');
- })
+ });
+ function aoutoTransform() {
+ var title = $("#KindName").val();
+ var filePath = $("#FilePath").val();
+ if (!filePath) {
+ $.ajax({
+ type: "POST",
+ url: "/AdminCP/Server/Hanzi2Pinyin",
+ data: { name: title},
+ dataType: "JSON",
+ success: function (data) {
+ if (data.status == "success") {
+ if (data.message) {
+ $("#FilePath").val(data.message);
+ }
+ } else {
+ layer.alert(data.message, { icon: 2 });
+ }
+ },
+ error: function () {
+ layer.alert('执行错误,请联系管理员!', { icon: 2 });
+ }
+ });
+ }
+ }
\ No newline at end of file
diff --git a/COMCMS.Web/Common/ViewsHelper.cs b/COMCMS.Web/Common/ViewsHelper.cs
new file mode 100644
index 0000000..c0b83d3
--- /dev/null
+++ b/COMCMS.Web/Common/ViewsHelper.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using COMCMS.Core;
+using COMCMS.Common;
+using XCode;
+
+namespace COMCMS.Web.Common
+{
+ ///
+ /// 识图方法
+ ///
+ public class ViewsHelper
+ {
+ #region 获取分类链接
+ public static string EchoURL(ArticleCategory model)
+ {
+ if (model == null)
+ return "";
+ if (!string.IsNullOrEmpty(model.FilePath))
+ return model.FilePath + "/index.html";
+ else
+ return $"/article/index/{model.Id}";
+ }
+ #endregion
+
+ }
+}
diff --git a/COMCMS.Web/Controllers/ArticleController.cs b/COMCMS.Web/Controllers/ArticleController.cs
index ee6b1d0..fab86f7 100644
--- a/COMCMS.Web/Controllers/ArticleController.cs
+++ b/COMCMS.Web/Controllers/ArticleController.cs
@@ -19,6 +19,7 @@ namespace COMCMS.Web.Controllers
public IActionResult Index(int id = 0, int page = 1)
{
ArticleCategory model = ArticleCategory.FindById(id);
+
if (model == null)
{
return AlertAndGoBack("系统找不到本记录");
@@ -88,16 +89,13 @@ namespace COMCMS.Web.Controllers
}
ViewBag.cfg = cfg;
- string templatesname = "";//模板名称
+ string templatesname = "Index.cshtml";//模板名称
if (!string.IsNullOrEmpty(model.TemplateFile))
{
- templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", "");
- return View(templatesname, model);
- }
- else
- {
- return View(model);
+ templatesname = model.TemplateFile;
+ //return Content(templatesname);
}
+ return View("~/Views/Article/" + templatesname, model); //固定死就是这个
}
#endregion
diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs
index 5379490..4cade6e 100644
--- a/COMCMS.Web/Controllers/HomeController.cs
+++ b/COMCMS.Web/Controllers/HomeController.cs
@@ -26,7 +26,7 @@ namespace COMCMS.Web.Controllers
{
ViewBag.cfg = cfg;
ViewBag.about = Article.FindById(1);//关于我们
- return View();
+ return View("~/Views/Home/Index.cshtml");
}
#endregion
@@ -47,19 +47,19 @@ namespace COMCMS.Web.Controllers
}
#region 测试
- [Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
- public IActionResult Test(string path = "")
- {
- string tel = "13332835377";
- return Content(tel.Substring(tel.Length - 5) + ";path:" + path);
- }
- [Route("{path1:regex([[a-zA-Z0-9-]])}/{path2:regex([[a-zA-Z0-9-]])}/index.html")]
- public IActionResult Test2(string path1 = "", string path2 = "")
- {
- ArticleController ac = new ArticleController();
- return ac.Index(1);
- //return Content(";ath1:" + path1+";path2:"+path2);
- }
+ //[Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
+ //public IActionResult Test(string path = "")
+ //{
+ // string tel = "13332835377";
+ // return Content(tel.Substring(tel.Length - 5) + ";path:" + path);
+ //}
+ //[Route("{path1:regex([[a-zA-Z0-9-]])}/{path2:regex([[a-zA-Z0-9-]])}/index.html")]
+ //public IActionResult Test2(string path1 = "", string path2 = "")
+ //{
+ // ArticleController ac = new ArticleController();
+ // return ac.Index(1);
+ // //return Content(";ath1:" + path1+";path2:"+path2);
+ //}
#endregion
#region 测试拼音
@@ -69,8 +69,34 @@ namespace COMCMS.Web.Controllers
}
#endregion
- #region 系统文章、商品路由
-
+ #region 系统文章栏目、商品栏目路由
+ ///
+ /// 一级路径栏目
+ ///
+ ///
+ ///
+ [Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
+ [Route("{path:regex([[a-zA-Z0-9-]])}/index-{page:int}.html")]
+ [Route("{path:regex([[a-zA-Z0-9-]])}/")]
+ public IActionResult ShowCategory(string path,int page=1)
+ {
+ //先判断文章栏目
+ ArticleCategory articleCategory = ArticleCategory.FindByFilePath("/" + path);
+ if(articleCategory != null)
+ {
+ //return Content(articleCategory.Id.ToString());
+ ArticleController ac = new ArticleController();
+ return ac.Index(articleCategory.Id);
+ }
+ //再判断商品
+ Category category = Category.FindByFilePath("/" + path);
+ if(category != null)
+ {
+ ProductController pc = new ProductController();
+ return pc.Index(category.Id,page);
+ }
+ return EchoTip("系统找不到本栏目!"+"/"+path);
+ }
#endregion
}
diff --git a/COMCMS.Web/Views/Shared/EchoTip.cshtml b/COMCMS.Web/Views/Shared/EchoTip.cshtml
new file mode 100644
index 0000000..55d85fd
--- /dev/null
+++ b/COMCMS.Web/Views/Shared/EchoTip.cshtml
@@ -0,0 +1,46 @@
+@{
+ Layout = null;
+ ViewBag.Title = "信息提示";
+}
+
+
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 信息提示
+
+
+ @ViewBag.Message
+
+
+ 返回首页
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/COMCMS.Web/Views/_ViewImports.cshtml b/COMCMS.Web/Views/_ViewImports.cshtml
index 3d96f25..fc984f4 100644
--- a/COMCMS.Web/Views/_ViewImports.cshtml
+++ b/COMCMS.Web/Views/_ViewImports.cshtml
@@ -3,4 +3,5 @@
@using COMCMS.Core
@using COMCMS.Common
@using XCode
+@using COMCMS.Web.Common
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers