Browse Source

1. 修改取虛擬路徑方式

PTD
Ray 2 years ago
parent
commit
0bef1b0c3e
  1. 27
      AMESCoreStudio.Web/Code/VirtualPathConfig.cs
  2. 35
      AMESCoreStudio.Web/Startup.cs
  3. 15
      AMESCoreStudio.Web/appsettings.json

27
AMESCoreStudio.Web/Code/VirtualPathConfig.cs

@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace AMESCoreStudio.Web.Code
{
/// <summary>
/// 虛擬路徑
/// </summary>
public class VirtualPathConfig
{
public List<PathContent> VirtualPath { get; set; }
}
public class PathContent
{
/// <summary>
/// 真實路徑
/// </summary>
public string RealPath { get; set; }
/// <summary>
/// 目錄名稱
/// </summary>
public string RequestPath { get; set; }
//public string Alias { get; set; }
}
}

35
AMESCoreStudio.Web/Startup.cs

@ -14,6 +14,7 @@ using WebApiClient;
using System.Globalization; using System.Globalization;
using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;
using AMESCoreStudio.Web.Code;
namespace AMESCoreStudio.Web namespace AMESCoreStudio.Web
{ {
@ -34,9 +35,9 @@ namespace AMESCoreStudio.Web
// 郎�ヘ魁 // 郎�ヘ魁
//Add our IFileServerProvider implementation as a singleton //Add our IFileServerProvider implementation as a singleton
services.AddSingleton<IFileServerProvider>(new FileServerProvider( //services.AddSingleton<IFileServerProvider>(new FileServerProvider(
new List<FileServerOptions> // new List<FileServerOptions>
{ // {
// new FileServerOptions // new FileServerOptions
// { // {
// // 龟砰隔畖 // // 龟砰隔畖
@ -45,14 +46,28 @@ namespace AMESCoreStudio.Web
// RequestPath = new PathString("/aa"), // RequestPath = new PathString("/aa"),
// EnableDirectoryBrowsing = true // EnableDirectoryBrowsing = true
// } // }
new FileServerOptions // new FileServerOptions
{ // {
FileProvider = new PhysicalFileProvider(@"//qasrv-n/Web/ISOZone/"), // FileProvider = new PhysicalFileProvider(@"//qasrv-n/Web/ISOZone/"),
RequestPath = new PathString("/DocEsop"), // RequestPath = new PathString("/DocEsop"),
EnableDirectoryBrowsing = true // EnableDirectoryBrowsing = true
} // }
})); // }));
var config = Configuration.Get<VirtualPathConfig>().VirtualPath;
var fileServerOptions = new List<FileServerOptions>();
if (config != null)
{
config.ForEach(f =>
{
fileServerOptions.Add(new FileServerOptions
{
FileProvider = new PhysicalFileProvider(@f.RealPath),
RequestPath = new PathString(f.RequestPath),
});
});
};
services.AddSingleton<IFileServerProvider>(new FileServerProvider(fileServerOptions));
// 配置跨域处理,允许所有来源 // 配置跨域处理,允许所有来源
services.AddCors(options => services.AddCors(options =>

15
AMESCoreStudio.Web/appsettings.json

@ -11,6 +11,17 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
// "WipSpecial": "Y",
"WipSpecial": "Y" //
"VirtualPath": [
//{
// "RealPath": "//qasrv-n/Web/ISOZone/", //
// "RequestPath": "/DocEsop" //
//}
//{
// "RealPath": "//10.1.8.1/sop/機種", //
// "RequestPath": "/test"
// //"Alias": "second"
//}
]
} }

Loading…
Cancel
Save