初步更新文章栏目路径功能

This commit is contained in:
comm5v8
2019-05-21 21:46:16 +08:00
parent ecc0c97c66
commit 34fdb431d4
96 changed files with 24881 additions and 162 deletions
@@ -65,6 +65,34 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
tip.Message = "文章栏目标题不能为空!";
return Json(tip);
}
if (string.IsNullOrEmpty(model.FilePath))
{
tip.Message = "文章栏目路径不能为空!";
return Json(tip);
}
if (!model.FilePath.StartsWith("/"))
{
tip.Message = "栏目路径请以/开头!";
return Json(tip);
}
if (!model.FilePath.EndsWith("/"))
{
tip.Message = "栏目路径结尾不用加上/";
return Json(tip);
}
if (model.FilePath.Count(x => x == '/') > 4)
{
tip.Message = "最多只能四级路径!";
return Json(tip);
}
if (!AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 0))
{
tip.Message = "栏目路径不可用,请重新填写!";
return Json(tip);
}
model.Insert();
Core.Admin.WriteLogActions("添加文章栏目(id:" + model.Id + ");");
tip.Status = JsonTip.SUCCESS;
@@ -127,6 +155,32 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
Json(tip);
}
if (string.IsNullOrEmpty(model.FilePath))
{
tip.Message = "文章栏目路径不能为空!";
return Json(tip);
}
if (!model.FilePath.StartsWith("/"))
{
tip.Message = "栏目路径请以/开头!";
return Json(tip);
}
if (!model.FilePath.EndsWith("/"))
{
tip.Message = "栏目路径结尾不用加上/";
return Json(tip);
}
if (model.FilePath.Count(x => x == '/') > 4)
{
tip.Message = "最多只能四级路径!";
return Json(tip);
}
if (!AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 0))
{
tip.Message = "栏目路径不可用,请重新填写!";
return Json(tip);
}
if (entity.PId != model.PId)
{
if (entity.Id == model.PId)
@@ -171,6 +225,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
entity.KindDomain = model.KindDomain;
entity.Rank = model.Rank;
entity.Pic = model.Pic;
model.FilePath = model.FilePath;
entity.Save();
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using COMCMS.Common;
using COMCMS.Core;
using XCode;
using Newtonsoft.Json;
using COMCMS.Web.Common;
using Microsoft.AspNetCore.Http;
namespace COMCMS.Web.Areas.AdminCP.Controllers
{
public class ServerController : AdminBaseController
{
#region 中文转拼音
public IActionResult Hanzi2Pinyin(string name)
{
string pinyin = "";
if (!string.IsNullOrEmpty(name))
{
pinyin = PinYinHelper.GetPinyin(name).ToLower().Replace(" ","-");
}
tip.Status = JsonTip.SUCCESS;
tip.Message = pinyin;
return Json(tip);
}
#endregion
}
}
@@ -28,7 +28,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">栏目名称:</label>
<div class="col-sm-8">
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写栏目名称">
<input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写栏目名称" onblur="aoutoTransform()">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">栏目路径:</label>
<div class="col-sm-8">
<input id="FilePath" name="FilePath" maxlength="100" type="text" class="form-control" required aria-required="true" placeholder="填写栏目路径,SEO优化使用,最多支持4级目录,可以输入字母、数字和-">
</div>
</div>
<div class="form-group">
@@ -154,4 +160,28 @@
DoPost("addArticleKindForm");
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 });
}
});
}
}
</script>