Browse Source

Add EnabledAllModules to DynamicJavaScriptProxyOptions

pull/10370/head
liangshiwei 5 years ago
parent
commit
eb2842baab
  1. 6
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
  2. 2
      framework/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/DynamicJavaScriptProxyOptions.cs
  3. 17
      framework/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs

6
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs

@ -9,6 +9,7 @@ using Volo.Abp.Cli.ServiceProxying.CSharp;
using Volo.Abp.Cli.ServiceProxying.JavaScript;
using Volo.Abp.Domain;
using Volo.Abp.Http;
using Volo.Abp.Http.ProxyScripting.Generators.JQuery;
using Volo.Abp.IdentityModel;
using Volo.Abp.Json;
using Volo.Abp.Json.SystemTextJson;
@ -71,6 +72,11 @@ namespace Volo.Abp.Cli
options.Generators[AngularServiceProxyGenerator.Name] = typeof(AngularServiceProxyGenerator);
options.Generators[CSharpServiceProxyGenerator.Name] = typeof(CSharpServiceProxyGenerator);
});
Configure<DynamicJavaScriptProxyOptions>(options =>
{
options.EnabledAllModules = true;
});
}
}
}

2
framework/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/DynamicJavaScriptProxyOptions.cs

@ -6,6 +6,8 @@ public class DynamicJavaScriptProxyOptions
{
public HashSet<string> EnabledModules { get; set; }
public bool EnabledAllModules { get; set; }
public DynamicJavaScriptProxyOptions()
{
EnabledModules = new HashSet<string> { "app" };

17
framework/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs

@ -36,7 +36,7 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery
foreach (var module in model.Modules)
{
if (_dynamicJavaScriptProxyOptions.EnabledModules.All(m => !m.Equals(module.Key, StringComparison.CurrentCultureIgnoreCase)))
if (!ShouldCreateModuleScript(module))
{
continue;
}
@ -50,6 +50,21 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery
return script.ToString();
}
private bool ShouldCreateModuleScript(KeyValuePair<string, ModuleApiDescriptionModel> module)
{
if (_dynamicJavaScriptProxyOptions.EnabledAllModules)
{
return true;
}
if (_dynamicJavaScriptProxyOptions.EnabledModules.Any(m => m.Equals(module.Key, StringComparison.CurrentCultureIgnoreCase)))
{
return true;
}
return false;
}
private static void AddModuleScript(StringBuilder script, ModuleApiDescriptionModel module)
{
//TODO: Eleminate repeating module.RootPath.Replace("/", ".").ToCamelCase() !

Loading…
Cancel
Save