Introduce DynamicJavaScriptProxyOptions

pull/10378/head
liangshiwei 4 years ago
parent 9138aadec7
commit a5e9133371

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery;
public class DynamicJavaScriptProxyOptions
{
public HashSet<string> EnabledModules { get; set; }
public DynamicJavaScriptProxyOptions()
{
EnabledModules = new HashSet<string> { "app" };
}
}

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Modeling;
@ -19,6 +20,13 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery
/// </summary>
public const string Name = "jquery";
private readonly DynamicJavaScriptProxyOptions _dynamicJavaScriptProxyOptions;
public JQueryProxyScriptGenerator(IOptions<DynamicJavaScriptProxyOptions> dynamicJavaScriptProxyOptions)
{
_dynamicJavaScriptProxyOptions = dynamicJavaScriptProxyOptions.Value;
}
public string CreateScript(ApplicationApiDescriptionModel model)
{
var script = new StringBuilder();
@ -26,10 +34,16 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery
script.AppendLine("/* This file is automatically generated by ABP framework to use MVC Controllers from javascript. */");
script.AppendLine();
foreach (var module in model.Modules.Values)
foreach (var module in model.Modules)
{
if (!_dynamicJavaScriptProxyOptions.EnabledModules.Any(m =>
module.Key.Equals(m, StringComparison.CurrentCultureIgnoreCase)))
{
continue;
}
script.AppendLine();
AddModuleScript(script, module);
AddModuleScript(script, module.Value);
}
AddInitializedEventTrigger(script);

Loading…
Cancel
Save