90 lines
3.9 KiB
C#
90 lines
3.9 KiB
C#
using NaiBa.Util.Extension;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AllBase.Helper
|
|
{
|
|
public class NaiBaGlobalConfig
|
|
{
|
|
public static bool IsDevelopment { get; set; } // 判断是否是开发环境
|
|
public static bool IsNewFeature { get; set; }
|
|
public static bool IsNotNeedLogin = false;
|
|
public static DateTime DefaultDateTime = "2000-01-01 00:00:00".ParseToDateTime();
|
|
public static string Proxy = "127.0.0.1:8888"; // 请求Fiddler代理,仅做开发测试使用
|
|
public static string VersionUrl = "https://update.qixiaoke.com/updatex/kingdragorse.php";
|
|
public static string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36";
|
|
public static List<string> NoProxyDomainList = new List<string>(); // 不走系统代理的域名
|
|
public static string ResourcesFileRelativeDir = @"Resources\file\";
|
|
public static string ResourcesFileAbsolutePath = Path.Combine(FileHelper.GetApplicationDir(), ResourcesFileRelativeDir);
|
|
|
|
public const string Data = "data"; // data 文件目录
|
|
public const string Config = "config"; // config 文件目录
|
|
public const string Image = "image"; // image 文件目录
|
|
public const string Log = "log";
|
|
public const string Cache = "cache"; // cache 文件目录
|
|
public const int MillisecondsClose = 3000; // 默认3秒钟自动关闭信息弹出框
|
|
public const string DefaultDateFormat = "yyyy-MM-dd";
|
|
public const string DefaultTimeFormat = "HH:mm:ss";
|
|
public const string DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
|
public const string NoYearDateTimeFormat = "MM-dd HH:mm:ss";
|
|
public const string HtmlBR = "<br>";
|
|
|
|
public const string ConfirmDeleteText = "确认删除[{0}]条数据吗?";
|
|
public const string ConfirmClearText = "确认清空吗?";
|
|
public const string NoSelectDataText = "您还未选择任何数据";
|
|
public const string NoDataText = "没有需要处理的数据";
|
|
public const string ProcessingText = "正在{0}...";
|
|
|
|
public const string ChinaCountryCode = "cn";
|
|
|
|
public const char NumberSignSplitChar = '#';
|
|
public const char SplitChar = '♯';
|
|
public const char Tab = '\t';
|
|
|
|
public static List<string> UserAgentList { get; set; } // https://developers.whatismybrowser.com/useragents/explore/software_name/chrome/ $(".useragent").each(function(){console.log($(this).text()+'\r\n')});
|
|
|
|
#region 全局委托
|
|
public static Func<string, string> EvaluateScript; // 执行 JavaScript
|
|
#endregion
|
|
|
|
|
|
#region 开发代理
|
|
public static IWebProxy GetDevelopProxy(string url = "")
|
|
{
|
|
// 请求Fiddler代理,仅做开发测试使用
|
|
if (IsDevelopment && !string.IsNullOrEmpty(Proxy) && Process.GetProcessesByName("FF").Length > 0)
|
|
{
|
|
var proxyArr = Proxy.Split(':');
|
|
return new WebProxy(proxyArr[0], proxyArr[1].ParseToInt());
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
string host = new Uri(url).Host;
|
|
if (NoProxyDomainList.Contains(host))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
return WebRequest.DefaultWebProxy;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 计算软件版本
|
|
public static string GetVersionString(int major, int minor)
|
|
{
|
|
string versionNo = major + "." + minor.ToString().PadLeft(2, '0');
|
|
return versionNo;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|