diff --git a/plugins/market/src/node/locales/schema.de-DE.yml b/plugins/market/src/node/locales/schema.de-DE.yml index 6568f16c..b22c93b7 100644 --- a/plugins/market/src/node/locales/schema.de-DE.yml +++ b/plugins/market/src/node/locales/schema.de-DE.yml @@ -6,4 +6,5 @@ search: $description: 搜索设置 endpoint: 用于搜索插件市场的网址。默认跟随插件源设置。 timeout: 搜索插件市场的超时时间。 + delay: 延迟多久后再开始首次同步。 proxyAgent: 用于搜索插件市场的代理。 diff --git a/plugins/market/src/node/locales/schema.en-US.yml b/plugins/market/src/node/locales/schema.en-US.yml index 6568f16c..b22c93b7 100644 --- a/plugins/market/src/node/locales/schema.en-US.yml +++ b/plugins/market/src/node/locales/schema.en-US.yml @@ -6,4 +6,5 @@ search: $description: 搜索设置 endpoint: 用于搜索插件市场的网址。默认跟随插件源设置。 timeout: 搜索插件市场的超时时间。 + delay: 延迟多久后再开始首次同步。 proxyAgent: 用于搜索插件市场的代理。 diff --git a/plugins/market/src/node/locales/schema.fr-FR.yml b/plugins/market/src/node/locales/schema.fr-FR.yml index 6568f16c..b22c93b7 100644 --- a/plugins/market/src/node/locales/schema.fr-FR.yml +++ b/plugins/market/src/node/locales/schema.fr-FR.yml @@ -6,4 +6,5 @@ search: $description: 搜索设置 endpoint: 用于搜索插件市场的网址。默认跟随插件源设置。 timeout: 搜索插件市场的超时时间。 + delay: 延迟多久后再开始首次同步。 proxyAgent: 用于搜索插件市场的代理。 diff --git a/plugins/market/src/node/locales/schema.ja-JP.yml b/plugins/market/src/node/locales/schema.ja-JP.yml index 6568f16c..b22c93b7 100644 --- a/plugins/market/src/node/locales/schema.ja-JP.yml +++ b/plugins/market/src/node/locales/schema.ja-JP.yml @@ -6,4 +6,5 @@ search: $description: 搜索设置 endpoint: 用于搜索插件市场的网址。默认跟随插件源设置。 timeout: 搜索插件市场的超时时间。 + delay: 延迟多久后再开始首次同步。 proxyAgent: 用于搜索插件市场的代理。 diff --git a/plugins/market/src/node/locales/schema.ru-RU.yml b/plugins/market/src/node/locales/schema.ru-RU.yml index 6568f16c..b22c93b7 100644 --- a/plugins/market/src/node/locales/schema.ru-RU.yml +++ b/plugins/market/src/node/locales/schema.ru-RU.yml @@ -6,4 +6,5 @@ search: $description: 搜索设置 endpoint: 用于搜索插件市场的网址。默认跟随插件源设置。 timeout: 搜索插件市场的超时时间。 + delay: 延迟多久后再开始首次同步。 proxyAgent: 用于搜索插件市场的代理。 diff --git a/plugins/market/src/node/locales/schema.zh-CN.yml b/plugins/market/src/node/locales/schema.zh-CN.yml index 51247f56..c61a4e7d 100644 --- a/plugins/market/src/node/locales/schema.zh-CN.yml +++ b/plugins/market/src/node/locales/schema.zh-CN.yml @@ -7,4 +7,5 @@ search: $description: 搜索设置 endpoint: 用于搜索插件市场的网址。默认跟随插件源设置。 timeout: 搜索插件市场的超时时间。 + delay: 延迟多久后再开始首次同步。 proxyAgent: 用于搜索插件市场的代理。 diff --git a/plugins/market/src/node/locales/schema.zh-TW.yml b/plugins/market/src/node/locales/schema.zh-TW.yml index ceecf895..aa549c6c 100644 --- a/plugins/market/src/node/locales/schema.zh-TW.yml +++ b/plugins/market/src/node/locales/schema.zh-TW.yml @@ -6,4 +6,5 @@ search: $description: 搜尋設定 endpoint: 用於搜尋外掛程式市場的網址。默認跟隨外掛程式源設置。 timeout: 搜尋外掛程式市場的超時時間。 + delay: 延遲多久後再開始首次同步。 proxyAgent: 用於搜尋外掛程式市場的代理。 diff --git a/plugins/market/src/node/market.ts b/plugins/market/src/node/market.ts index faf19451..23a4d8fb 100644 --- a/plugins/market/src/node/market.ts +++ b/plugins/market/src/node/market.ts @@ -1,4 +1,4 @@ -import { Context, Dict, HTTP, Schema, Time } from 'koishi' +import { Context, Dict, HTTP, Schema, Time, sleep } from 'koishi' import Scanner, { SearchObject, SearchResult } from '@koishijs/registry' import { MarketProvider as BaseMarketProvider } from '../shared' @@ -29,6 +29,9 @@ class MarketProvider extends BaseMarketProvider { this.fullCache = {} this.tempCache = {} if (refresh) this.ctx.installer.refresh(true) + if (!refresh && this.config.delay) { + await sleep(this.config.delay) + } await this.prepare() super.start() } @@ -101,11 +104,13 @@ namespace MarketProvider { export interface Config { endpoint?: string timeout?: number + delay?: number } export const Config: Schema = Schema.object({ endpoint: Schema.string().role('link'), timeout: Schema.number().role('time').default(Time.second * 30), + delay: Schema.number().role('time').default(0).description('执行首次同步前的等待时间。'), proxyAgent: Schema.string().role('link'), }) }