diff --git a/Falcon.SugarApi/ApiClient/ApiClientException.cs b/Falcon.SugarApi/ApiClient/ApiClientException.cs
new file mode 100644
index 0000000..6d18e55
--- /dev/null
+++ b/Falcon.SugarApi/ApiClient/ApiClientException.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace Falcon.SugarApi.ApiClient
+{
+ ///
+ /// api客户端异常
+ ///
+ public class ApiClientException:Exception
+ {
+ ///
+ /// 通过提供异常消息,请求地址,请求数据,和内部异常构造异常
+ ///
+ /// 异常消息
+ /// 请求地址
+ /// 请求数据
+ /// 内部异常
+ public ApiClientException(string? message,string url,string data,Exception? innerException) : base(message,innerException) {
+ this.Data.Add("url",url);
+ this.Data.Add("data",data);
+ }
+ }
+}
diff --git a/Falcon.SugarApi/ApiClient/ApiClientOptions.cs b/Falcon.SugarApi/ApiClient/ApiClientOptions.cs
new file mode 100644
index 0000000..2cc4518
--- /dev/null
+++ b/Falcon.SugarApi/ApiClient/ApiClientOptions.cs
@@ -0,0 +1,27 @@
+using Microsoft.Extensions.Options;
+
+namespace Falcon.SugarApi.ApiClient
+{
+ ///
+ /// api客户端配置
+ ///
+ public class ApiClientOptions:IOptions
+ {
+ ///
+ /// 配置对象
+ ///
+ public ApiClientOptions Value => this;
+ ///
+ /// 客户端请求超时。秒
+ ///
+ public int ClientTimeout { get; set; } = 10;
+ ///
+ /// 媒体类型
+ ///
+ public string MediaType { get; set; } = "application/json";
+ ///
+ /// 保持链接
+ ///
+ public bool KeepAlive { get; set; }=true;
+ }
+}
diff --git a/Falcon.SugarApi/ApiClient/HttpClientHelper.cs b/Falcon.SugarApi/ApiClient/HttpClientHelper.cs
new file mode 100644
index 0000000..3acc2a5
--- /dev/null
+++ b/Falcon.SugarApi/ApiClient/HttpClientHelper.cs
@@ -0,0 +1,68 @@
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+
+namespace Falcon.SugarApi.ApiClient
+{
+ ///
+ /// 通过HttpClient调用api
+ ///
+ public class HttpClientHelper:IHttpClientHelper
+ {
+ ///
+ /// 实例化帮助对象
+ ///
+ /// 客户端配置
+ public HttpClientHelper(IOptions options) {
+ Options = options.Value;
+ }
+
+ ///
+ /// 记录日期的ILogger
+ ///
+ public ILogger Log { get; }
+
+ ///
+ /// 客户端配置
+ ///
+ public ApiClientOptions Options { get; set; }
+
+ ///
+ /// 向服务器发送POST请求
+ ///
+ /// api服务器url地址
+ /// 要发送的数据
+ /// 响应数据
+ /// 请求api时候发生的异常
+ public string Post(string url,string data) {
+ var result = "";
+ using(HttpClient client = new HttpClient()) {
+ try {
+ client.Timeout = TimeSpan.FromSeconds(this.Options.ClientTimeout);
+ HttpContent content = new StringContent(data);
+ content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(Options.MediaType);
+ if(this.Options.KeepAlive) {
+ client.DefaultRequestHeaders.Connection.Add("keep-alive");
+ }
+ Task res = client.PostAsync(url,content);
+ if(res.Result.StatusCode == System.Net.HttpStatusCode.OK) {
+ result = res.Result.Content.ReadAsStringAsync().Result;
+ }
+ else {
+ throw new ApiClientException("访问webapi方法状态码错误",url,data,null);
+ }
+ }
+ catch(Exception ex) {
+ throw new ApiClientException("访问webapi方法异常",url,data,ex);
+ }
+ finally {
+ client.Dispose();
+ }
+ }
+ return result;
+ }
+
+ }
+}
diff --git a/Falcon.SugarApi/ApiClient/IHttpClientHelper.cs b/Falcon.SugarApi/ApiClient/IHttpClientHelper.cs
new file mode 100644
index 0000000..8f0a839
--- /dev/null
+++ b/Falcon.SugarApi/ApiClient/IHttpClientHelper.cs
@@ -0,0 +1,17 @@
+namespace Falcon.SugarApi.ApiClient
+{
+ ///
+ /// 通过HttpClient调用api
+ ///
+ public interface IHttpClientHelper
+ {
+ ///
+ /// 向服务器发送POST请求
+ ///
+ /// api服务器url地址
+ /// 要发送的数据
+ /// 响应数据
+ /// 请求api时候发生的异常
+ string Post(string url,string data);
+ }
+}
\ No newline at end of file
diff --git a/Falcon.SugarApi/ApiClient/IServiceCollentionExtend.cs b/Falcon.SugarApi/ApiClient/IServiceCollentionExtend.cs
new file mode 100644
index 0000000..8192fa5
--- /dev/null
+++ b/Falcon.SugarApi/ApiClient/IServiceCollentionExtend.cs
@@ -0,0 +1,24 @@
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Falcon.SugarApi.ApiClient
+{
+ ///
+ /// 服务扩展,注册帮助方法
+ ///
+ public static class IServiceCollentionExtend
+ {
+ ///
+ /// 注册IHttpClientHelper实现
+ ///
+ /// 服务集合
+ /// 应用配置
+ /// 服务集合
+ public static IServiceCollection AddHttpClientHelper(this IServiceCollection services,IConfiguration config) {
+ //var sect = config.GetValue>("ApiClient");
+ services.Configure(config.GetSection("ApiClient"));
+ services.AddSingleton();
+ return services;
+ }
+ }
+}
\ No newline at end of file
diff --git a/JS/StaticData.js b/JS/StaticData.js
new file mode 100644
index 0000000..289cf1b
--- /dev/null
+++ b/JS/StaticData.js
@@ -0,0 +1,34 @@
+//洢̬
+function createSetStaticData() {
+ if (window.sessionStorage) {
+ return (k, v) => window.sessionStorage.setItem(k, v);
+ } else if ($ && $.cookie) {
+ return (k, v) => $.cookie(k, v);
+ } else {
+ throw new Error("ûҵֵ֧Ĵ洢");
+ }
+}
+var setStaticData = createSetStaticData();
+//ȡ洢ľ̬
+function CreateGetStaticData() {
+ if (window.sessionStorage) {
+ return (k) => window.sessionStorage.getItem(k);
+ } else if ($ && $.cookie) {
+ return (k) => $.cookie(k);
+ } else {
+ throw new Error("ûҵֵ֧Ĵ洢");
+ }
+}
+var getStaticData = CreateGetStaticData();
+//̬ݴȡ
+class StaticData {
+ constructor(k, v) {
+ this.key = k;
+ this.value = v;
+ if (v) {
+ setStaticData(k, v);
+ } else {
+ this.value = getStaticData(k);
+ }
+ }
+}
\ No newline at end of file