【问题标题】:TypeScript API in .NET Core version.NET Core 版本中的 TypeScript API
【发布时间】:2018-01-08 08:03:45
【问题描述】:

.NET Core 的 ABP 模板是否具有Javascript-API 中列出的功能?

更重要的是,.NET Core 版本能否生成我的服务器端实体对应的动态代理(services.ts)?

【问题讨论】:

    标签: angular typescript .net-core aspnetboilerplate dynamic-proxy


    【解决方案1】:

    是的,.NET Core 的 ABP 模板具有Javascript-API 中列出的所有功能。

    ABP 不生成动态代理。推荐工具used by the ABP team是NSwag:

    我们正在使用 nswag 来生成 typescript 服务代理。 Nswag 使用 swagger 端点来获取服务定义并自动创建 typescript 类。既然有这么棒的工具,我们就不想研究了。

    【讨论】:

    • 我发现存在自动生成 .ts 代理的文件 nswag\refresh.bat(进入 abp 核心模板的角部分)。这是一个很棒的功能,必须记录在案!!!非常有用,谢谢大家
    【解决方案2】:

    是的,它支持核心版本的所有功能。但没有动态代理创建。您在 Angular 版本中使用 abp.ajax 处理应用服务请求。

    abp.ajax({
        url: AppConsts.remoteServiceBaseUrl + '/AbpUserConfiguration/GetAll',
        method: 'GET',
    }
    }).done(result => {
        //....
    });
    

    nswag 生成服务的使用示例;

      constructor(
            injector: Injector,
            private _accountService: AccountServiceProxy,
            private _router: Router,
            private readonly _loginService: LoginService
        ) {
            super(injector);
        }
    
        save(): void {
            this.saving = true;
            this._accountService.register(this.model)
                .finally(() => { this.saving = false; })
                .subscribe((result:RegisterOutput) => {
                    if (!result.canLogin) {
                        this.notify.success(this.l('SuccessfullyRegistered'));
                        this._router.navigate(['/login']);
                        return;
                    }
    
                    //Autheticate
                    this.saving = true;
                    this._loginService.authenticateModel.userNameOrEmailAddress = this.model.userName;
                    this._loginService.authenticateModel.password = this.model.password;
                    this._loginService.authenticate(() => { this.saving = false; });
                });
        }
    

    【讨论】:

      猜你喜欢
      • 2021-09-11
      • 2016-12-17
      • 1970-01-01
      • 1970-01-01
      • 2019-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-19
      相关资源
      最近更新 更多