lith 5 tahun lalu
induk
melakukan
992e6c0c4d
46 mengubah file dengan 628 tambahan dan 300 penghapusan
  1. 5 0
      dotnet/Doc/UpgradeLog/Sers2.1.1.txt
  2. 1 1
      dotnet/Sers/ApiLoader/Sers.NetcoreLoader/Sers.NetcoreLoader.csproj
  3. 1 1
      dotnet/Sers/ApiLoader/Sers.Serslot/Sers.Serslot.csproj
  4. 1 1
      dotnet/Sers/Sers.CL/Ipc/Sers.CL.Ipc.SharedMemory/Sers.CL.Ipc.SharedMemory.csproj
  5. 1 1
      dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.Iocp/Sers.CL.Socket.Iocp.csproj
  6. 1 1
      dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.ThreadWait/Sers.CL.Socket.ThreadWait.csproj
  7. 1 1
      dotnet/Sers/Sers.CL/WebSocket/Sers.CL.WebSocket/Sers.CL.WebSocket.csproj
  8. 1 1
      dotnet/Sers/Sers.CL/Zmq/FullDuplex/Sers.CL.Zmq.FullDuplex/Sers.CL.Zmq.FullDuplex.csproj
  9. 1 1
      dotnet/Sers/Sers.CL/Zmq/ThreadWait/Sers.CL.ClrZmq.ThreadWait/Sers.CL.ClrZmq.ThreadWait.csproj
  10. 12 31
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/Extensions/LocalApiService_StaticFileMap_Extensions.cs
  11. 23 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/Extensions/StaticFilesApiNodeConfig.cs
  12. 56 31
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFileMap.cs
  13. 82 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFilesConfig.cs
  14. 1 1
      dotnet/Sers/Sers.Core/Sers.Core/Sers.Core.csproj
  15. 10 52
      dotnet/Sers/Sers.Gateway/Sers.Gateway/GatewayHelp.cs
  16. 1 1
      dotnet/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj
  17. 1 1
      dotnet/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj
  18. 1 1
      dotnet/Sers/Sers.Ioc/Sers.Ioc/Sers.Ioc.csproj
  19. 1 1
      dotnet/Sers/Sers.ServiceCenter/Sers.ServiceCenter/ServiceCenter.cs
  20. 1 1
      dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj
  21. 1 1
      dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/ServiceStation.cs
  22. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Controllers/Demo/SampleController.cs
  23. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj
  24. 34 8
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/appsettings.json
  25. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj
  26. 16 6
      dotnet/StationDemo/Serslot/Did.Serslot.Demo/appsettings.json
  27. 1 1
      dotnet/Vit/Vit.Core/Vit.Core/Vit.Core.csproj
  28. 1 1
      dotnet/Vit/Vit.Ioc/Vit.Ioc/Vit.Ioc.csproj
  29. 1 1
      dotnet/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj
  30. 54 0
      dotnet/Vit/Vit.WebHost/Extensions/IApplicationBuilderExtensions_UseStaticFiles.cs
  31. 17 0
      dotnet/Vit/Vit.WebHost/Extensions/IWebHostBuilderExtensions_UseStaticFiles.cs
  32. 19 24
      dotnet/Vit/Vit.WebHost/Host.cs
  33. 52 0
      dotnet/Vit/Vit.WebHost/HostRunArg.cs
  34. 0 85
      dotnet/Vit/Vit.WebHost/RunArg.cs
  35. 118 0
      dotnet/Vit/Vit.WebHost/StaticFilesConfig.cs
  36. 1 1
      dotnet/Vit/Vit.WebHost/Vit.WebHost.csproj
  37. 1 1
      dotnet/netcore/Gateway/App.Gateway/App.Gateway.csproj
  38. 21 2
      dotnet/netcore/Gateway/App.Gateway/appsettings.json
  39. 1 1
      dotnet/netcore/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj
  40. 21 2
      dotnet/netcore/ServiceCenter/App.Gover.Gateway/appsettings.json
  41. 1 1
      dotnet/netcore/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj
  42. 36 7
      dotnet/netcore/ServiceCenter/App.ServiceCenter/appsettings.json
  43. 1 1
      dotnet/netcore/Station/App.Ioc.Station/App.Ioc.Station.csproj
  44. 1 1
      dotnet/netcore/Station/App.Robot.Station/App.Robot.Station.csproj
  45. 1 20
      dotnet/netcore/Station/App.Robot.Station/Controllers/TaskController.cs
  46. 24 5
      dotnet/netcore/Station/App.Robot.Station/appsettings.json

+ 5 - 0
dotnet/Doc/UpgradeLog/Sers2.1.1.txt

@@ -85,3 +85,8 @@ ServiceCenter
 
 [tag]Sers2.1.1.300
 ------------------------------------------------------------------------------------------------------------------
+映射静态文件。调整配置。添加手动指定headers功能。
+
+
+[tag]Sers2.1.1.303
+------------------------------------------------------------------------------------------------------------------

+ 1 - 1
dotnet/Sers/ApiLoader/Sers.NetcoreLoader/Sers.NetcoreLoader.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/ApiLoader/Sers.Serslot/Sers.Serslot.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Ipc/Sers.CL.Ipc.SharedMemory/Sers.CL.Ipc.SharedMemory.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.Iocp/Sers.CL.Socket.Iocp.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.ThreadWait/Sers.CL.Socket.ThreadWait.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/WebSocket/Sers.CL.WebSocket/Sers.CL.WebSocket.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Zmq/FullDuplex/Sers.CL.Zmq.FullDuplex/Sers.CL.Zmq.FullDuplex.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
   

+ 1 - 1
dotnet/Sers/Sers.CL/Zmq/ThreadWait/Sers.CL.ClrZmq.ThreadWait/Sers.CL.ClrZmq.ThreadWait.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
   

+ 12 - 31
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/Extensions/LocalApiService_StaticFileMap_Extensions.cs

@@ -1,5 +1,7 @@
-using Sers.Core.Module.Api.LocalApi;
+using Newtonsoft.Json;
+using Sers.Core.Module.Api.LocalApi;
 using Sers.Core.Module.Api.LocalApi.StaticFileTransmit;
+using Sers.Core.Module.Api.LocalApi.StaticFileTransmit.Extensions;
 using System;
 using Vit.Core.Module.Log;
 
@@ -8,21 +10,22 @@ namespace Vit.Extensions
 {
     public static partial class LocalApiService_StaticFileMap_Extensions
     {
+  
 
         #region LoadApi_StaticFileMap
 
         /// <summary>
-        /// 从配置文件(appsettings.json::Sers.LocalApiService.StaticFileMap)加载静态文件映射器
+        /// 从配置文件(appsettings.json::Sers.LocalApiService.staticFiles)加载静态文件映射器
         /// </summary>
 
-        public static void LoadApi_StaticFileMap(this LocalApiService data)
+        public static void LoadApi_StaticFiles(this LocalApiService data)
         {
             if (data == null)
             {
                 return;
             }
 
-            var configs = Vit.Core.Util.ConfigurationManager.ConfigurationManager.Instance.GetByPath<StaticFileMapConfig[]>("Sers.LocalApiService.StaticFileMap");
+            var configs = Vit.Core.Util.ConfigurationManager.ConfigurationManager.Instance.GetByPath<StaticFilesApiNodeConfig[]>("Sers.LocalApiService.staticFiles");
 
             if (configs == null || configs.Length == 0) return;
 
@@ -41,12 +44,11 @@ namespace Vit.Extensions
         }
 
 
-        static void LoadApi_StaticFileMap(LocalApiService data, StaticFileMapConfig config)
+        static void LoadApi_StaticFileMap(LocalApiService data, StaticFilesApiNodeConfig config)
         {
 
             #region (x.1)创建并初始化StaticFileMap
-            StaticFileMap staticFileMap = new StaticFileMap(config.staticFileDirectory);
-            var loadedContentTypeMap = staticFileMap.LoadContentTypeFromFile(config.ContentTypeMapFile);
+            StaticFileMap staticFileMap = new StaticFileMap(config);          
             #endregion
 
             #region (x.2)onInvoke
@@ -65,33 +67,12 @@ namespace Vit.Extensions
             msg += "," + Environment.NewLine + "apiName:  " + config.apiName;
             msg += ","+ "     route:  " + config.route;
             msg += "," + Environment.NewLine + "staticFileDirectory:  " + staticFileMap.fileBasePath;
-            if (loadedContentTypeMap)
+            if (!string.IsNullOrEmpty(config.contentTypeMapFile))
             {
-                msg += ","+Environment.NewLine+"ContentTypeMapFile:  "+ config.ContentTypeMapFile;
+                msg += ","+Environment.NewLine+"contentTypeMapFile:  "+ config.contentTypeMapFile;
             }
             Logger.Info(msg);
-        }
-
-        class StaticFileMapConfig
-        {
-            /// <summary>
-            /// api路由前缀,例如 "/demo/ui/*"
-            /// </summary>
-            public string route;
-
-            /// <summary>
-            /// api描述,静态文件描述
-            /// </summary>
-            public string apiName;
-            /// <summary>
-            /// 额外静态文件类型映射配置的文件路径(mappings.json),例如"wwwroot/mappings.json"。若不指定(或指定的文件不存在)则不添加额外文件类型映射配置
-            /// </summary>
-            public string ContentTypeMapFile;
-            /// <summary>
-            /// 静态文件的路径,如 "wwwroot/demo"
-            /// </summary>
-            public string staticFileDirectory;          
-        }
+        }     
 
 
         #endregion

+ 23 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/Extensions/StaticFilesApiNodeConfig.cs

@@ -0,0 +1,23 @@
+using Newtonsoft.Json;
+
+namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit.Extensions
+{
+    #region StaticFilesApiNodeConfig       
+    [JsonObject(MemberSerialization.OptIn)]
+    public class StaticFilesApiNodeConfig : StaticFilesConfig
+    {
+        /// <summary>
+        /// api路由前缀,例如 "/demo/ui/*"
+        /// </summary>
+        [JsonProperty]
+        public string route { get; set; }
+
+        /// <summary>
+        /// api描述,静态文件描述
+        /// </summary>
+        [JsonProperty]
+        public string apiName { get; set; }
+
+    }
+    #endregion
+}

+ 56 - 31
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFileMap.cs

@@ -1,22 +1,50 @@
 using Newtonsoft.Json.Linq;
 using Vit.Extensions;
 using Sers.Core.Module.Rpc;
-using System;
 using System.IO;
 using System.Web;
 using Vit.Core.Util.ComponentModel.SsError;
 using Vit.Core.Util.ConfigurationManager;
 using Vit.Core.Util.Common;
+using System.Collections.Generic;
 
 namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
 {
     public class StaticFileMap
-    { 
+    {
 
-        public readonly FileExtensionContentTypeProvider contentTypeProvider = new FileExtensionContentTypeProvider();
+        #region fileBasePath
+        private string _fileBasePath;
+        /// <summary>
+        /// D://fold1/wwwroot
+        /// 静态文件绝对路径
+        /// </summary>
+        public string fileBasePath
+        {
+            get => _fileBasePath;
+            set
+            {
+                #region (x.1) get fullPath
+                string fullPath = value;
+
+                if (string.IsNullOrEmpty(fullPath))
+                {
+                    fullPath = "wwwroot";
+                }
+                fullPath = CommonHelp.GetAbsPath(fullPath);
+                #endregion
+
+                _fileBasePath = fullPath;
+            }
+        }
+        #endregion
 
 
 
+
+        #region contentTypeProvider       
+        readonly FileExtensionContentTypeProvider contentTypeProvider = new FileExtensionContentTypeProvider();
+
         #region LoadContentTypeFromFile
         /// <summary>
         /// 
@@ -40,36 +68,14 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             return false;
         }
         #endregion
+        #endregion
 
 
-        #region fileBasePath
-        private string _fileBasePath;
-        /// <summary>
-        /// D://fold1/wwwroot
-        /// 静态文件绝对路径
-        /// </summary>
-        public string fileBasePath
-        {
-            get => _fileBasePath;
-            set
-            {
-                #region (x.1) get fullPath
-                string fullPath = value;
-
-                if (string.IsNullOrEmpty(fullPath))
-                {
-                    fullPath = "wwwroot";
-                }
-                fullPath = CommonHelp.GetAbsPath(fullPath);               
-                #endregion
-
-                _fileBasePath = fullPath;
-            }
-        }
+        #region responseHeaders
+        public IDictionary<string, string> responseHeaders { get; set; }
         #endregion
 
 
-
         /// <summary>
         /// fileBasePath:静态文件路径。可为相对路径或绝对路径。若不指定(null或空字符串)则默认为入口程序所在目录下的wwwroot文件夹。
         ///   demo  D://fold1/wwwroot 
@@ -80,6 +86,14 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             this.fileBasePath = fileBasePath;
         }
 
+        public StaticFileMap(StaticFilesConfig config) 
+        {
+            this.fileBasePath = config.rootPath;
+            responseHeaders = config.responseHeaders;
+            LoadContentTypeFromFile(config.contentTypeMapFile);
+        }
+
+
 
         /// <summary>
         /// 获取当前url对应的相对文件路径(若不合法,则返回null)。demo:"rpc/2.html"
@@ -120,13 +134,21 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             }
 
             #region reply header
-            var replyRpcData = RpcFactory.Instance.CreateRpcContextData();      
+            var replyRpcData = RpcFactory.Instance.CreateRpcContextData();
+
+            if (responseHeaders != null) 
+            {
+                foreach (var item in responseHeaders)
+                {
+                    replyRpcData.http_header_Set(item.Key, item.Value);
+                }
+            }
 
             if (contentTypeProvider.TryGetContentType(absFilePath, out var contentType))
             {
                 replyRpcData.http_header_Set("Content-Type", contentType);             
             }
-            replyRpcData.http_header_Set("Cache-Control", "public,max-age=6000");        
+            //replyRpcData.http_header_Set("Cache-Control", "public,max-age=6000");        
  
             RpcContext.Current.apiReplyMessage.rpcContextData_OriData= replyRpcData.PackageOriData();
             #endregion
@@ -140,12 +162,15 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             //Response.ContentEncoding = Encoding.UTF8;
             //Response.Charset = "utf-8";
 
+            // https://www.cnblogs.com/lonelyxmas/p/12441606.html
+            // https://www.cnblogs.com/Leo_wl/p/6059349.html
+
             //ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600");
             //(小知识: max - age:表示当访问此网页后的max - age秒内再次访问不会去服务器请求,其功能与Expires类似,只是Expires是根据某个特定日期值做比较。一但缓存者自身的时间不准确.则结果可能就是错误的,而max - age,显然无此问题.。Max - age的优先级也是高于Expires的。)
         }
 
 
- 
+
 
         public byte[] DownloadFile(string absFilePath, string fileName=null)
         {

+ 82 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFilesConfig.cs

@@ -0,0 +1,82 @@
+using System.IO;
+using Vit.Core.Util.Common;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+
+namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
+{
+
+    #region StaticFiles
+    [JsonObject(MemberSerialization.OptIn)]
+    public class StaticFilesConfig
+    {
+
+        #region rootPath       
+  
+        private string _rootPath = null;
+
+        /// <summary>
+        /// 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo"
+        /// </summary>
+        [JsonProperty]
+        public string rootPath
+        {
+            get => _rootPath?? CommonHelp.GetAbsPath("wwwroot");
+            set
+            {
+                #region (x.1) get fullPath
+                string fullPath = value;
+                if ("" == fullPath)
+                {
+                    fullPath = "wwwroot";
+                }
+
+                if (fullPath != null)
+                {
+                    fullPath = CommonHelp.GetAbsPath(fullPath);
+
+                    var dir = new DirectoryInfo(fullPath);
+                    if (dir.Exists)
+                    {
+                        fullPath = dir.FullName;
+                    }
+                    else
+                    {
+                        fullPath = null;
+                    }
+                }
+                #endregion
+
+                _rootPath = fullPath;
+            }
+        }
+        #endregion
+
+
+        /// <summary>
+        /// 回应静态文件时额外添加的http回应头。可不指定。
+        /// </summary>       
+        [JsonProperty]
+        public IDictionary<string,string> responseHeaders { get; set; }
+
+
+
+        #region contentTypeProvider
+ 
+
+        /// <summary>
+        /// 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置
+        /// </summary>
+        [JsonProperty]
+        public string contentTypeMapFile { get; set; }
+
+        #endregion
+
+
+ 
+
+
+    }
+    #endregion
+
+}

+ 1 - 1
dotnet/Sers/Sers.Core/Sers.Core/Sers.Core.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 10 - 52
dotnet/Sers/Sers.Gateway/Sers.Gateway/GatewayHelp.cs

@@ -25,8 +25,8 @@ namespace Sers.Gateway
 
         public static void Bridge()
         {
-            var webHostUrls = ConfigurationManager.Instance.GetByPath<string[]>("Sers.Gateway.WebHost.urls");
-            if (webHostUrls == null || webHostUrls.Length == 0) return;
+            HostRunArg arg = ConfigurationManager.Instance.GetByPath<HostRunArg>("Sers.Gateway.WebHost"); 
+            if (arg == null || arg.urls==null || arg.urls.Length == 0) return;
 
 
             #region (x.2)初始化GatewayHelp
@@ -44,72 +44,30 @@ namespace Sers.Gateway
 
             #endregion
 
-            #region (x.3)初始化WebHost
-
-            RunArg arg = new RunArg { allowAnyOrigin = true };
-
 
+            #region (x.3)初始化WebHost
 
             //(x.x.1)指定可以与iis集成(默认无法与iis集成)
             arg.OnCreateWebHostBuilder = () => Microsoft.AspNetCore.WebHost.CreateDefaultBuilder().UseVitConfig();
+            
 
-            //(x.x.2)配置web服务监听地址(urls)
-            arg.urls = webHostUrls;
-
-
-            #region (x.x.3)配置静态文件映射
-
-            arg.wwwrootPath = ConfigurationManager.Instance.GetByPath<string>("Sers.Gateway.WebHost.wwwroot");
-
-            if (arg.wwwrootPath != null)
-            {
-                #region 静态文件类型映射配置(mappings.json)
-                try
-                {
-                    var jsonFile = new JsonFile(new[] { "mappings.json" });
-                    if (File.Exists(jsonFile.configPath))
-                    {
-                        var provider = new FileExtensionContentTypeProvider();
-                        var map = provider.Mappings;
-                        foreach (var item in (jsonFile.root as JObject))
-                        {
-                            map.Remove(item.Key);
-                            map[item.Key] = item.Value.Value<string>();
-                        }
-
-                        arg.OnInitStaticFileOptions += (StaticFileOptions staticfileOptions) =>
-                        {
-                            staticfileOptions.ContentTypeProvider = provider;
-                        };
-
-                    }
-                }
-                catch (Exception ex)
-                {
-                    Logger.Error(ex);
-                }
-                #endregion
-            }
-            #endregion
-
-
-            #region (x.x.4)转发web请求到Sers(网关核心功能)
+            #region (x.x.2)转发web请求到Sers(网关核心功能)
             arg.OnConfigure = (app) =>
-            {
+            {               
                 app.Run(gatewayHelp.Bridge);
             };
             #endregion
 
 
-            //(x.x.5)设置异步启动
+            //(x.x.3)设置异步启动
             arg.RunAsync = true;
 
 
-            #region (x.x.6)启动           
+            #region (x.x.4)启动           
             Logger.Info("[WebHost]will listening on: " + string.Join(",", arg.urls));
 
-            if (arg.wwwrootPath != null)
-                Logger.Info("[WebHost]wwwroot : " + arg.wwwrootPath);
+            if (arg.staticFiles?.rootPath != null)
+                Logger.Info("[WebHost]wwwroot : " + arg.staticFiles?.rootPath);
 
             Vit.WebHost.Host.Run(arg);
             #endregion

+ 1 - 1
dotnet/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.Ioc/Sers.Ioc/Sers.Ioc.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.ServiceCenter/Sers.ServiceCenter/ServiceCenter.cs

@@ -170,7 +170,7 @@ namespace Sers.ServiceCenter
         /// </summary>
         public void LoadApi()
         {
-            localApiService.LoadApi_StaticFileMap();
+            localApiService.LoadApi_StaticFiles();
             localApiService.LoadApi();
         }
 

+ 1 - 1
dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj

@@ -3,7 +3,7 @@
  
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/ServiceStation.cs

@@ -160,7 +160,7 @@ namespace Sers.ServiceStation
         /// </summary>
         public void LoadApi()
         {
-            localApiService.LoadApi_StaticFileMap();
+            localApiService.LoadApi_StaticFiles();
             localApiService.LoadApi();
         }
 

+ 1 - 1
dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Controllers/Demo/SampleController.cs

@@ -563,7 +563,7 @@ namespace Did.SersLoader.Demo.Controllers.Demo
         #region (x.7) UseStaticFiles
 
         // wwwroot 路径从配置文件获取
-        static StaticFileMap staticFileMap = new StaticFileMap(ConfigurationManager.Instance.GetByPath<string>("Demo.wwwroot"));
+        static StaticFileMap staticFileMap = new StaticFileMap(ConfigurationManager.Instance.GetByPath<StaticFilesConfig>("Demo.staticFiles"));
 
         /// <summary>
         /// UseStaticFiles

+ 1 - 1
dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>

+ 34 - 8
dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/appsettings.json

@@ -128,21 +128,30 @@
 
 
       /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
-      "StaticFileMap": [
+      "//staticFiles": [
         {
           /* api路由前缀,例如 "/demo/ui/*" */
           "route": "/demo/ui/*",
           /* api描述,静态文件描述 */
           "apiName": "demo站点静态文件",
-          /* 静态文件路径。可为相对路径或绝对路径。若未指定存在的文件夹则默认为当前目录下的wwwroot文件夹。demo:"wwwroot/demo" */
-          "staticFileDirectory": "wwwroot/demo",
-          /* 额外静态文件类型映射配置的文件路径(mappings.json),例如"wwwroot/mappings.json"。若不指定(或指定的文件不存在)则不添加额外文件类型映射配置 */
-          "ContentTypeMapFile": "mappings.json"
+
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot/demo",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
         }
       ],
 
 
-
       /* 默认站点名称,可多个,可不指定 */
       "apiStationNames": [ "demo" ],
 
@@ -242,8 +251,25 @@
   },
 
   "Demo": {
-    /* 静态文件路径。可为相对路径或绝对路径。若不指定(null或空字符串)则默认为入口程序所在目录下的wwwroot文件夹。 */
-    "wwwroot": "wwwroot/demo"
+
+    /* 映射静态文件 */
+    "staticFiles": {
+
+      /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+      "rootPath": "wwwroot/demo",
+
+      /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+      "contentTypeMapFile": "mappings.json",
+
+      /* 回应静态文件时额外添加的http回应头。可不指定。 */
+      "responseHeaders": {
+
+        //设置浏览器静态文件缓存3600秒
+        "Cache-Control": "public,max-age=3600"
+      }
+    }
+
+
   },
 
 

+ 1 - 1
dotnet/StationDemo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 16 - 6
dotnet/StationDemo/Serslot/Did.Serslot.Demo/appsettings.json

@@ -45,7 +45,7 @@
       /* 后台服务的线程个数(单位个,默认0,代表不开启服务) */
       "workThreadCount": 4,
 
-      
+
       /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
       //"timeout_ms": 10000,
 
@@ -55,16 +55,26 @@
 
 
       /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
-      "//StaticFileMap": [
+      "//staticFiles": [
         {
           /* api路由前缀,例如 "/demo/ui/*" */
           "route": "/demo/ui/*",
           /* api描述,静态文件描述 */
           "apiName": "demo站点静态文件",
-          /* 静态文件路径。可为相对路径或绝对路径。若未指定存在的文件夹则默认为当前目录下的wwwroot文件夹。demo:"wwwroot/demo" */
-          "staticFileDirectory": "wwwroot/demo",
-          /* 额外静态文件类型映射配置的文件路径(mappings.json),例如"wwwroot/mappings.json"。若不指定(或指定的文件不存在)则不添加额外文件类型映射配置 */
-          "ContentTypeMapFile": "mappings.json"
+
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot/demo",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
         }
       ],
 

+ 1 - 1
dotnet/Vit/Vit.Core/Vit.Core/Vit.Core.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Vit/Vit.Ioc/Vit.Ioc/Vit.Ioc.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 54 - 0
dotnet/Vit/Vit.WebHost/Extensions/IApplicationBuilderExtensions_UseStaticFiles.cs

@@ -0,0 +1,54 @@
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.FileProviders;
+using Vit.WebHost;
+
+namespace Vit.Extensions
+{
+    public static class IApplicationBuilderExtensions_UseStaticFiles
+    { 
+        public static IApplicationBuilder UseStaticFiles(this IApplicationBuilder data, StaticFilesConfig config)
+        {
+            if (config == null || data==null) return data;         
+
+
+            //(x.1)
+            var staticfileOptions = new StaticFileOptions();
+
+            #region (x.2)FileProvider
+            if (!string.IsNullOrWhiteSpace(config.rootPath))
+            {
+                staticfileOptions.FileProvider = new PhysicalFileProvider(config.rootPath);
+            }
+            #endregion
+
+            //(x.3)OnInitStaticFileOptions
+            config.OnInitStaticFileOptions?.Invoke(staticfileOptions);
+
+            #region (x.4)Response Headers
+            if (config.responseHeaders != null)
+            {
+                staticfileOptions.OnPrepareResponse +=
+                ctx =>
+                {
+                    var Headers = ctx.Context.Response.Headers;
+                    foreach (var kv in config.responseHeaders)
+                    {
+                        Headers[kv.Key] = kv.Value;
+                    }
+                };
+            }
+            #endregion
+
+
+            //(x.5)contentTypeProvider
+            if (config.contentTypeProvider != null) 
+            {
+                staticfileOptions.ContentTypeProvider = config.contentTypeProvider;
+            }
+
+            data.UseStaticFiles(staticfileOptions);          
+
+            return data;
+        }
+    }
+}

+ 17 - 0
dotnet/Vit/Vit.WebHost/Extensions/IWebHostBuilderExtensions_UseStaticFiles.cs

@@ -0,0 +1,17 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.DependencyInjection;
+using Vit.WebHost;
+
+namespace Vit.Extensions
+{
+    public static class IWebHostBuilderExtensions_UseStaticFiles
+    {
+ 
+        public static IWebHostBuilder UseStaticFiles(this IWebHostBuilder data, StaticFilesConfig config)
+        {
+            data?.Configure(app=>  app.UseStaticFiles(config));             
+
+            return data;
+        }
+    }
+}

+ 19 - 24
dotnet/Vit/Vit.WebHost/Host.cs

@@ -3,27 +3,29 @@ using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.FileProviders;
+using Microsoft.Net.Http.Headers;
+using Vit.Extensions;
 
 namespace Vit.WebHost
 {
     public class Host
     {
         #region Run
-        public static void Run(int port = 8888, string wwwrootPath = null, Action<IApplicationBuilder> OnConfigure = null)
+        public static void Run(int port = 8888, string rootPath = null, Action<IApplicationBuilder> OnConfigure = null)
         {
-            Run(wwwrootPath, OnConfigure, "http://*:" + port);
+            Run(rootPath, OnConfigure, "http://*:" + port);
         }
-        public static void Run(string wwwrootPath = null, Action<IApplicationBuilder> OnConfigure = null, params string[] urls)
+        public static void Run(string rootPath = null, Action<IApplicationBuilder> OnConfigure = null, params string[] urls)
         {
-            Run(new RunArg
-            {
-                wwwrootPath = wwwrootPath,
+            Run(new HostRunArg
+            {                
                 OnConfigure = OnConfigure,
-                urls = urls
+                urls = urls,
+                staticFiles=new StaticFilesConfig { rootPath= rootPath }
             });
         }
 
-        public static void Run(RunArg arg)
+        public static void Run(HostRunArg arg)
         {
             Action<IServiceCollection> OnConfigureServices = null;
             Action<IApplicationBuilder> OnConfigure = null;
@@ -48,24 +50,17 @@ namespace Vit.WebHost
             }
             #endregion
 
-
             #region (x.2)UseStaticFiles
-            if (!string.IsNullOrWhiteSpace(arg.wwwrootPath) || arg.OnInitStaticFileOptions != null)
+            if (arg.staticFiles != null) 
             {
                 OnConfigure += (app) =>
-                {
-                    var staticfileOptions = new StaticFileOptions();
-                    if (!string.IsNullOrWhiteSpace(arg.wwwrootPath))
-                    {                          
-                        staticfileOptions.FileProvider = new PhysicalFileProvider(arg.wwwrootPath);
-                    }
-                    arg.OnInitStaticFileOptions?.Invoke(staticfileOptions);
-                    app.UseStaticFiles(staticfileOptions);
+                {                   
+                    app.UseStaticFiles(arg.staticFiles);
                 };
             }
             #endregion
 
-            #region test OnConfigure
+            #region demo OnConfigure
             //OnConfigure += (app) =>{
 
             //    app.Use(async (context, next) =>
@@ -91,11 +86,11 @@ namespace Vit.WebHost
             OnConfigure += arg.OnConfigure;
 
             var host =
-                  arg.OnCreateWebHostBuilder().
-                   UseUrls(arg.urls).
-                   ConfigureServices(OnConfigureServices).
-                   Configure(OnConfigure).
-                   Build();
+                arg.OnCreateWebHostBuilder()               
+                .UseUrls(arg.urls)    
+                .ConfigureServices(OnConfigureServices)
+                .Configure(OnConfigure)               
+                .Build();
             #endregion
 
 

+ 52 - 0
dotnet/Vit/Vit.WebHost/HostRunArg.cs

@@ -0,0 +1,52 @@
+using System;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
+
+namespace Vit.WebHost
+{
+    [JsonObject(MemberSerialization.OptIn)]
+    public partial class HostRunArg
+    {
+
+        public Func<IWebHostBuilder> OnCreateWebHostBuilder = () => new WebHostBuilder().UseKestrel();    
+
+        /// <summary>
+        /// 
+        /// </summary>       
+        [JsonProperty]
+        public string[] urls;
+
+        /// <summary>
+        /// 是否允许跨域访问,默认true
+        /// </summary>       
+        [JsonProperty]
+        public bool allowAnyOrigin = true;
+
+
+        /// <summary>
+        /// 映射静态文件,可不指定
+        /// </summary>       
+        [JsonProperty]
+        public StaticFilesConfig staticFiles;
+
+
+        /// <summary>
+        /// 是否异步运行.Runs a web application and returns a Task that only completes when the token is triggered or shutdown is triggered.
+        /// </summary>      
+        public bool RunAsync = false;
+
+        public Action<IServiceCollection> OnConfigureServices = null;
+        public Action<IApplicationBuilder> OnConfigure = null;
+
+
+
+        public HostRunArg SetPort(int port = 8888)
+        {
+            urls = new string[] { "http://*:" + port };
+            return this;
+        }
+ 
+    }
+}

+ 0 - 85
dotnet/Vit/Vit.WebHost/RunArg.cs

@@ -1,85 +0,0 @@
-using System;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-using System.IO;
-using Vit.Extensions;
-using Vit.Core.Util.Common;
-
-namespace Vit.WebHost
-{
-    public class RunArg
-    {
-
-
-        public Func<IWebHostBuilder> OnCreateWebHostBuilder = () => new WebHostBuilder().UseKestrel();
-
-        /// <summary>
-        /// 是否异步运行.Runs a web application and returns a Task that only completes when the token is triggered or shutdown is triggered.
-        /// </summary>
-        public bool RunAsync = false;
-
-        #region wwwrootPath       
-        /// <summary>
-        /// 静态文件路径。若不指定(null)则不映射静态文件
-        /// </summary>
-        private string _wwwrootPath = null;
-        /// <summary>
-        /// 静态文件路径。可为相对路径或绝对路径。若为空字符串则默认为入口程序所在目录下的wwwroot文件夹。若不指定(null)则不映射静态文件。
-        /// </summary>
-        public string wwwrootPath
-        {
-            get => _wwwrootPath;
-            set
-            {
-                #region (x.1) get fullPath
-                string fullPath = value;
-                if ("" == fullPath)
-                {
-                    fullPath = "wwwroot";
-                }
-
-                if (fullPath != null)
-                {
-                    fullPath = CommonHelp.GetAbsPath(fullPath);
-               
-                    var dir = new DirectoryInfo(fullPath);
-                    if (dir.Exists)
-                    {
-                        fullPath = dir.FullName;
-                    }
-                    else
-                    {
-                        fullPath = null;
-                    }
-                }
-                #endregion
-
-                _wwwrootPath = fullPath;
-            }
-        }
-        #endregion
-
-
-        /// <summary>
-        /// 初始化 wwwroot静态文件配置的操作
-        /// </summary>
-        public Action<StaticFileOptions> OnInitStaticFileOptions;
-
-        public Action<IServiceCollection> OnConfigureServices = null;
-        public Action<IApplicationBuilder> OnConfigure = null;
-        public string[] urls;
-
-        /// <summary>
-        /// 允许跨域访问
-        /// </summary>
-        public bool allowAnyOrigin = false;
-
-
-        public RunArg SetPort(int port = 8888)
-        {
-            urls = new string[] { "http://*:" + port };
-            return this;
-        }
-    }
-}

+ 118 - 0
dotnet/Vit/Vit.WebHost/StaticFilesConfig.cs

@@ -0,0 +1,118 @@
+using System;
+using Microsoft.AspNetCore.Builder;
+using System.IO;
+using Vit.Core.Util.Common;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System.Collections.Generic;
+using Microsoft.AspNetCore.StaticFiles;
+using Vit.Core.Util.ConfigurationManager;
+
+namespace Vit.WebHost
+{
+
+    #region StaticFiles
+    [JsonObject(MemberSerialization.OptIn)]
+    public class StaticFilesConfig
+    {
+
+        #region rootPath       
+ 
+        private string _rootPath = null;
+
+        /// <summary>
+        /// 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo"
+        /// </summary>
+        [JsonProperty]
+        public string rootPath
+        {
+            get => _rootPath ?? CommonHelp.GetAbsPath("wwwroot");
+            set
+            {
+                #region (x.1) get fullPath
+                string fullPath = value;
+                if ("" == fullPath)
+                {
+                    fullPath = "wwwroot";
+                }
+
+                if (fullPath != null)
+                {
+                    fullPath = CommonHelp.GetAbsPath(fullPath);
+
+                    var dir = new DirectoryInfo(fullPath);
+                    if (dir.Exists)
+                    {
+                        fullPath = dir.FullName;
+                    }
+                    else
+                    {
+                        fullPath = null;
+                    }
+                }
+                #endregion
+
+                _rootPath = fullPath;
+            }
+        }
+        #endregion
+
+
+        /// <summary>
+        /// 回应静态文件时额外添加的http回应头。可不指定。
+        /// </summary>       
+        [JsonProperty]
+        public IDictionary<string,string> responseHeaders { get; set; }
+
+
+
+        #region contentTypeProvider
+        internal IContentTypeProvider contentTypeProvider { get; set; }
+
+        /// <summary>
+        /// 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置
+        /// </summary>
+        [JsonProperty]
+        public string contentTypeMapFile
+        {            
+            set
+            {
+                if (string.IsNullOrWhiteSpace(value)) 
+                {
+                    contentTypeProvider = null;
+                    return;
+                }
+
+                var jsonFile = new JsonFile(value);
+                if (File.Exists(jsonFile.configPath))
+                {
+                    var provider = new FileExtensionContentTypeProvider();
+                    contentTypeProvider = provider;
+
+                    if (jsonFile.root is JObject jo)
+                    {
+                        var map = provider.Mappings;
+                        foreach (var item in jo)
+                        {
+                            map.Remove(item.Key);
+                            map[item.Key] = item.Value.Value<string>();
+                        }
+                    }
+                }
+         
+            }
+        }
+
+        #endregion
+
+
+        /// <summary>
+        /// 初始化 wwwroot静态文件配置的操作
+        /// </summary>
+        public Action<StaticFileOptions> OnInitStaticFileOptions { get; set; }
+
+
+    }
+    #endregion
+
+}

+ 1 - 1
dotnet/Vit/Vit.WebHost/Vit.WebHost.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/Gateway/App.Gateway/App.Gateway.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 21 - 2
dotnet/netcore/Gateway/App.Gateway/appsettings.json

@@ -58,11 +58,30 @@
         /* url,可多个 */
         "urls": [ "http://*:4582" ],
 
+        /* 是否允许跨域访问,默认true */
+        "allowAnyOrigin": true,
+
         /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset  */
         "//ResponseDefaultContentType": "application/json; charset=UTF-8",
 
-        /* 静态文件路径。可为相对路径或绝对路径。若为空字符串则默认为当前目录下的wwwroot文件夹。若不指定(null)则不映射静态文件。 */
-        "//wwwroot": ""
+
+        /* 映射静态文件。若不指定则不映射静态文件 */
+        "staticFiles": {
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+
       },
 
 

+ 1 - 1
dotnet/netcore/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 21 - 2
dotnet/netcore/ServiceCenter/App.Gover.Gateway/appsettings.json

@@ -53,11 +53,30 @@
         /* url,可多个 */
         "urls": [ "http://*:4581" ],
 
+        /* 是否允许跨域访问,默认true */
+        "allowAnyOrigin": true,
+
         /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset  */
         "//ResponseDefaultContentType": "application/json; charset=UTF-8",
 
-        /* 静态文件路径。可为相对路径或绝对路径。若为空字符串则默认为当前目录下的wwwroot文件夹。若不指定(null)则不映射静态文件。 */
-        "wwwroot": ""
+
+        /* 映射静态文件。若不指定则不映射静态文件 */
+        "staticFiles": {
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+
       },
 
       //调用api前的事件,可不指定

+ 1 - 1
dotnet/netcore/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 36 - 7
dotnet/netcore/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -143,16 +143,26 @@
 
 
       /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
-      "//StaticFileMap": [
+      "//staticFiles": [
         {
           /* api路由前缀,例如 "/demo/ui/*" */
           "route": "/demo/ui/*",
           /* api描述,静态文件描述 */
           "apiName": "demo站点静态文件",
-          /* 静态文件路径。可为相对路径或绝对路径。若未指定存在的文件夹则默认为当前目录下的wwwroot文件夹。demo:"wwwroot/demo" */
-          "staticFileDirectory": "wwwroot/demo",
-          /* 额外静态文件类型映射配置的文件路径(mappings.json),例如"wwwroot/mappings.json"。若不指定(或指定的文件不存在)则不添加额外文件类型映射配置 */
-          "ContentTypeMapFile": "mappings.json"
+
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot/demo",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
         }
       ],
 
@@ -307,11 +317,30 @@
         /* url,可多个 */
         "urls": [ "http://*:4580" ],
 
+        /* 是否允许跨域访问,默认true */
+        "allowAnyOrigin": true,
+
         /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset  */
         "//ResponseDefaultContentType": "application/json; charset=UTF-8",
 
-        /* 静态文件路径。可为相对路径或绝对路径。若为空字符串则默认为当前目录下的wwwroot文件夹。若不指定(null)则不映射静态文件。 */
-        "wwwroot": ""
+
+        /* 映射静态文件。若不指定则不映射静态文件 */
+        "staticFiles": {
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+
       },
 
 

+ 1 - 1
dotnet/netcore/Station/App.Ioc.Station/App.Ioc.Station.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/Station/App.Robot.Station/App.Robot.Station.csproj

@@ -4,7 +4,7 @@
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
     <RunPostBuildEvent>Always</RunPostBuildEvent>
-    <Version>2.1.1.300</Version>
+    <Version>2.1.1.303</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 20
dotnet/netcore/Station/App.Robot.Station/Controllers/TaskController.cs

@@ -3,12 +3,10 @@ using App.Robot.Station.Logical;
 using App.Robot.Station.Logical.Model;
 using Sers.SersLoader;
 using Sers.SersLoader.ApiDesc.Attribute.Valid;
-using Sers.Core.Module.Api.LocalApi.StaticFileTransmit;
 using Sers.Core.Module.Api.Rpc;
 using Sers.Core.Module.App;
 using Vit.Core.Util.ComponentModel.Api;
 using Vit.Core.Util.ComponentModel.Data;
-using Vit.Core.Util.ConfigurationManager;
 using Vit.Core.Util.Threading;
 
 namespace App.Robot.Station.Controllers
@@ -28,24 +26,7 @@ namespace App.Robot.Station.Controllers
             SersApplication.onStart += () => TaskController.MainTask.Start();
             SersApplication.onStop += () => TaskController.MainTask.Stop();
         }
-
-
-        #region UseStaticFiles
-
-        // wwwroot 路径从配置文件获取
-        static StaticFileMap staticFileMap = new StaticFileMap(ConfigurationManager.Instance.GetByPath<string>("Robot.wwwroot"));
-
-        /// <summary>
-        /// UseStaticFiles
-        /// </summary>
-        /// <returns></returns>
-        [SsRoute("*")]
-        public byte[] UseStaticFiles()
-        {
-            return staticFileMap.TransmitFile();
-        }
-        #endregion
-
+ 
 
         /// <summary>
         /// 保存到Cache

+ 24 - 5
dotnet/netcore/Station/App.Robot.Station/appsettings.json

@@ -111,6 +111,29 @@
       /* 后台服务的线程个数(单位个,默认0,代表不开启服务) */
       "workThreadCount": 1,
 
+      /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
+      "staticFiles": [
+        {
+          /* api路由前缀,例如 "/demo/ui/*" */
+          "route": "/_robot_/*",
+          /* api描述,静态文件描述 */
+          "apiName": "robot站点静态文件",
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot/_robot_",
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          //"contentTypeMapFile": "mappings.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+      ],
+
 
       /* Api加载器配置 */
       "ApiLoaders": [
@@ -138,11 +161,7 @@
   },
 
 
-  "Robot": {
-
-    /* 可为相对路径或绝对路径。若不指定(null或空字符串)则默认为入口程序所在目录下的wwwroot文件夹。 */
-    "wwwroot": "wwwroot/_robot_"
-  },
+ 
 
   /* Vit工具配置,可不指定 */
   "Vit": {