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

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
+2 -1
View File
@@ -6,7 +6,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="NewLife.Core" Version="8.1.2019.415" />
<PackageReference Include="NewLife.Core" Version="8.1.2019.510" />
<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="ZKWeb.System.Drawing" Version="4.0.1" />
</ItemGroup>
+68
View File
@@ -0,0 +1,68 @@
using Microsoft.International.Converters.PinYinConverter;
using System;
using System.Collections.Generic;
using System.Text;
namespace COMCMS.Common
{
public class PinYinHelper
{
/// <summary>
/// 默认编码
/// </summary>
//private static Encoding gb2312 = Encoding.GetEncoding("GB2312");
#region 汉字转化为拼音
/// <summary>
/// 汉字转化为拼音
/// </summary>
/// <param name="str">汉字</param>
/// <returns>全拼</returns>
public static string GetPinyin(string str)
{
string r = string.Empty;
foreach (char obj in str)
{
try
{
ChineseChar chineseChar = new ChineseChar(obj);
string t = chineseChar.Pinyins[0].ToString();
r += t.Substring(0, t.Length - 1);
}
catch
{
r += obj.ToString();
}
}
return r;
}
#endregion
#region 汉字转化为拼音首字母
/// <summary>
/// 汉字转化为拼音首字母
/// </summary>
/// <param name="str">汉字</param>
/// <returns>首字母</returns>
public static string GetFirstPinyin(string str)
{
string r = string.Empty;
foreach (char obj in str)
{
try
{
ChineseChar chineseChar = new ChineseChar(obj);
string t = chineseChar.Pinyins[0].ToString();
r += t.Substring(0, 1);
}
catch
{
r += obj.ToString();
}
}
return r;
}
#endregion
}
}
+11
View File
@@ -99,6 +99,17 @@ namespace COMCMS.Common
return Regex.IsMatch(str, @"^[A-Za-z0-9]+$");
}
/// <summary>
/// 判断是否为正确的
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsFilePath(string str)
{
//A-Z, a-z, 0-9, -, /, =
return Regex.IsMatch(str, @"[A-Za-z0-9-\/]");
}
/// <summary>
/// 验证对象是否为货币格式
/// </summary>