From 0c2dd5c9e641226ac024e3537be528529c8cd7bc Mon Sep 17 00:00:00 2001 From: magisk317 <93979778+magisk317@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:31:09 +0800 Subject: [PATCH] feat(market): add startup delay option --- plugins/market/src/node/locales/schema.de-DE.yml | 1 + plugins/market/src/node/locales/schema.en-US.yml | 1 + plugins/market/src/node/locales/schema.fr-FR.yml | 1 + plugins/market/src/node/locales/schema.ja-JP.yml | 1 + plugins/market/src/node/locales/schema.ru-RU.yml | 1 + plugins/market/src/node/locales/schema.zh-CN.yml | 1 + plugins/market/src/node/locales/schema.zh-TW.yml | 1 + plugins/market/src/node/market.ts | 7 ++++++- 8 files changed, 13 insertions(+), 1 deletion(-) 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'), }) }