diff --git a/AMESCoreStudio.Web/Code/VirtualPathConfig.cs b/AMESCoreStudio.Web/Code/VirtualPathConfig.cs new file mode 100644 index 00000000..757b3c2b --- /dev/null +++ b/AMESCoreStudio.Web/Code/VirtualPathConfig.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace AMESCoreStudio.Web.Code +{ + /// + /// 虛擬路徑 + /// + public class VirtualPathConfig + { + public List VirtualPath { get; set; } + } + + public class PathContent + { + /// + /// 真實路徑 + /// + public string RealPath { get; set; } + + /// + /// 目錄名稱 + /// + public string RequestPath { get; set; } + + //public string Alias { get; set; } + } +} diff --git a/AMESCoreStudio.Web/Startup.cs b/AMESCoreStudio.Web/Startup.cs index 31dfc6f1..7a8b2cab 100644 --- a/AMESCoreStudio.Web/Startup.cs +++ b/AMESCoreStudio.Web/Startup.cs @@ -14,6 +14,7 @@ using WebApiClient; using System.Globalization; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Localization; +using AMESCoreStudio.Web.Code; namespace AMESCoreStudio.Web { @@ -34,31 +35,45 @@ namespace AMESCoreStudio.Web // ɮץؿ //Add our IFileServerProvider implementation as a singleton - services.AddSingleton(new FileServerProvider( - new List + //services.AddSingleton(new FileServerProvider( + // new List + // { + // new FileServerOptions + // { + // // | + // FileProvider = new PhysicalFileProvider(@"\\10.0.8.7\\shop"), + // // | + // RequestPath = new PathString("/aa"), + // EnableDirectoryBrowsing = true + // } + // new FileServerOptions + // { + // FileProvider = new PhysicalFileProvider(@"//qasrv-n/Web/ISOZone/"), + // RequestPath = new PathString("/DocEsop"), + // EnableDirectoryBrowsing = true + // } + // })); + + var config = Configuration.Get().VirtualPath; + var fileServerOptions = new List(); + if (config != null) + { + config.ForEach(f => { - //new FileServerOptions - //{ - // // | - // FileProvider = new PhysicalFileProvider(@"\\10.0.8.7\\shop"), - // // | - // RequestPath = new PathString("/aa"), - // EnableDirectoryBrowsing = true - //} - new FileServerOptions + fileServerOptions.Add(new FileServerOptions { - FileProvider = new PhysicalFileProvider(@"//qasrv-n/Web/ISOZone/"), - RequestPath = new PathString("/DocEsop"), - EnableDirectoryBrowsing = true - } - })); + FileProvider = new PhysicalFileProvider(@f.RealPath), + RequestPath = new PathString(f.RequestPath), + }); + }); + }; + services.AddSingleton(new FileServerProvider(fileServerOptions)); - // ÿԴ services.AddCors(options => - options.AddPolicy("AMESPolicy", - p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod())); - + options.AddPolicy("AMESPolicy", + p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod())); + services.AddLocalization(o => { diff --git a/AMESCoreStudio.Web/appsettings.json b/AMESCoreStudio.Web/appsettings.json index 51b4cf49..a45e4292 100644 --- a/AMESCoreStudio.Web/appsettings.json +++ b/AMESCoreStudio.Web/appsettings.json @@ -11,6 +11,17 @@ } }, "AllowedHosts": "*", - // ww u򥻸ƲΤ@}u{T - "WipSpecial": "Y" + "WipSpecial": "Y", + // 虛擬路徑設定 + "VirtualPath": [ + //{ + // "RealPath": "//qasrv-n/Web/ISOZone/", //真實路徑 + // "RequestPath": "/DocEsop" // 虛擬路徑名稱 + //} + //{ + // "RealPath": "//10.1.8.1/sop/機種", //真實路徑 + // "RequestPath": "/test" + // //"Alias": "second" + //} + ] }