Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(abc:lodop): support URL with parameters #1824

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading