Skip to content

Commit

Permalink
fix(abc:lodop): support URL with parameters (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Aug 5, 2024
1 parent 40ae0dc commit a3dc917
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/abc/lodop/lodop.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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({
Expand Down
10 changes: 10 additions & 0 deletions packages/abc/lodop/lodop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/util/config/abc/lodop.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down

0 comments on commit a3dc917

Please sign in to comment.