Skip to content

Commit 62147e8

Browse files
committed
Feat: It is possible to cancel the configuration of the upper-level unified setting by setting null in the option.
1 parent 6e6189e commit 62147e8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type LoaderCommonConfig = {
9191
}
9292

9393
type LoaderHasConfig = {
94-
timeout: number
94+
timeout?: number
9595
maxRetry: number
9696
priority: number
9797
}
@@ -378,14 +378,14 @@ function loaderCommonConfigToCrawlConfig(
378378
detail
379379

380380
// 1.1.baseUrl
381-
if (!isUndefined(xCrawlConfig.baseUrl)) {
381+
if (xCrawlConfig.baseUrl) {
382382
detail.url = xCrawlConfig.baseUrl + url
383383
}
384384

385385
// 1.2.timeout
386386
if (isUndefined(timeout)) {
387387
if (!isUndefined(advancedDetailTargetsConfig.timeout)) {
388-
detail.timeout = advancedDetailTargetsConfig.timeout
388+
detail.timeout = advancedDetailTargetsConfig.timeout ?? undefined
389389
} else {
390390
detail.timeout = xCrawlConfig.timeout
391391
}
@@ -394,7 +394,7 @@ function loaderCommonConfigToCrawlConfig(
394394
// 1.3.maxRetry
395395
if (isUndefined(maxRetry)) {
396396
if (!isUndefined(advancedDetailTargetsConfig.maxRetry)) {
397-
detail.maxRetry = advancedDetailTargetsConfig.maxRetry
397+
detail.maxRetry = advancedDetailTargetsConfig.maxRetry ?? 0
398398
} else {
399399
detail.maxRetry = xCrawlConfig.maxRetry
400400
}

src/types/api.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ export interface DetailTargetFingerprintCommon {
6969
}
7070

7171
export interface CrawlCommonConfig {
72-
timeout?: number
72+
timeout?: number | null
7373
proxy?: {
7474
urls: string[]
7575
switchByHttpStatus?: number[]
7676
switchByErrorCount?: number
77-
}
78-
maxRetry?: number
77+
} | null
78+
maxRetry?: number | null
7979
}
8080

8181
// 1.Detail target
@@ -140,7 +140,9 @@ export interface CrawlDataAdvancedConfig<T> extends CrawlCommonConfig {
140140

141141
headers?: AnyObject
142142

143-
onCrawlItemComplete?: (crawlDataSingleResult: CrawlDataSingleResult<T>) => void
143+
onCrawlItemComplete?: (
144+
crawlDataSingleResult: CrawlDataSingleResult<T>
145+
) => void
144146
}
145147

146148
export interface CrawlFileAdvancedConfig extends CrawlCommonConfig {

0 commit comments

Comments
 (0)