diff --git a/packages/abc/lodop/lodop.service.ts b/packages/abc/lodop/lodop.service.ts index e482dc9e5..f8e0fcc2d 100644 --- a/packages/abc/lodop/lodop.service.ts +++ b/packages/abc/lodop/lodop.service.ts @@ -21,7 +21,7 @@ export class LodopService implements OnDestroy { constructor(configSrv: AlainConfigService) { this.defaultConfig = configSrv.merge('lodop', { - url: '//localhost:8443/CLodopfuncs.js', + url: 'http://localhost:8443/CLodopfuncs.js', name: 'CLODOP', companyName: '', checkMaxCount: 100 @@ -88,8 +88,10 @@ export class LodopService implements OnDestroy { private request(): void { this.pending = true; + const urlObj = new URL(this.cog.url!); + urlObj.searchParams.set('name', this.cog.name!); + const url = urlObj.toString(); - const url = `${this.cog.url}?name=${this.cog.name}`; let checkMaxCount = this.cog.checkMaxCount as number; const onResolve = (status: NzSafeAny, error?: NzSafeAny): void => { this._init.next({ diff --git a/packages/abc/lodop/lodop.spec.ts b/packages/abc/lodop/lodop.spec.ts index 1c8ab8d9a..d38dcbcd5 100644 --- a/packages/abc/lodop/lodop.spec.ts +++ b/packages/abc/lodop/lodop.spec.ts @@ -163,6 +163,16 @@ describe('abc: lodop', () => { }); srv.reset(); }); + it('should be custom url', () => { + const url = 'http://a.com/lodop.js?aa=1'; + cog.lodop!.url = url; + genModule(); + const scriptSrv = (srv as NzSafeAny).scriptSrv; + spyOn(scriptSrv, 'loadScript').and.callFake(() => Promise.resolve({ status: 'ok' })); + srv.reset(); + expect(scriptSrv.loadScript).toHaveBeenCalled(); + expect(scriptSrv.loadScript.calls.first().args[0]).toBe(`${url}&name=LODOP`); + }); }); describe('#attachCode', () => { diff --git a/packages/util/config/abc/lodop.type.ts b/packages/util/config/abc/lodop.type.ts index 2e184474a..097c09598 100644 --- a/packages/util/config/abc/lodop.type.ts +++ b/packages/util/config/abc/lodop.type.ts @@ -18,8 +18,8 @@ export interface AlainLodopConfig { /** * Lodop 远程脚本URL地址,**注意**务必使用 `name` 属性指定变量值 * - * - http://localhost:18000/CLodopfuncs.js - * - https://localhost:8443/CLodopfuncs.js [默认] + * - http://localhost:18000/CLodopfuncs.js [默认] + * - https://localhost:8443/CLodopfuncs.js */ url?: string; /**