fix: add config.endpoint, close #7
This commit is contained in:
		
							parent
							
								
									15b9c54b32
								
							
						
					
					
						commit
						2463dbbc2b
					
				
							
								
								
									
										10
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
									
									
									
									
								
							| @ -1,7 +1,7 @@ | |||||||
| { | { | ||||||
|   "name": "koishi-plugin-market-info", |   "name": "koishi-plugin-market-info", | ||||||
|   "description": "Koishi plugin market information", |   "description": "Koishi plugin market information", | ||||||
|   "version": "2.0.0", |   "version": "2.0.1", | ||||||
|   "main": "lib/index.js", |   "main": "lib/index.js", | ||||||
|   "typings": "lib/index.d.ts", |   "typings": "lib/index.d.ts", | ||||||
|   "files": [ |   "files": [ | ||||||
| @ -25,11 +25,6 @@ | |||||||
|     "description": { |     "description": { | ||||||
|       "en": "Plugin market information", |       "en": "Plugin market information", | ||||||
|       "zh": "插件市场查询与订阅,第一时间获知插件更新!" |       "zh": "插件市场查询与订阅,第一时间获知插件更新!" | ||||||
|     }, |  | ||||||
|     "service": { |  | ||||||
|       "required": [ |  | ||||||
|         "installer" |  | ||||||
|       ] |  | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   "keywords": [ |   "keywords": [ | ||||||
| @ -47,9 +42,8 @@ | |||||||
|     "koishi": "^4.15.0" |     "koishi": "^4.15.0" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@koishijs/plugin-market": "^2.3.1", |  | ||||||
|     "@koishijs/registry": "^6.0.4", |     "@koishijs/registry": "^6.0.4", | ||||||
|     "@types/node": "^18.15.5", |     "@types/node": "^20.8.10", | ||||||
|     "atsc": "^1.2.2", |     "atsc": "^1.2.2", | ||||||
|     "koishi": "^4.15.0", |     "koishi": "^4.15.0", | ||||||
|     "typescript": "^5.2.2" |     "typescript": "^5.2.2" | ||||||
|  | |||||||
| @ -6,8 +6,6 @@ const logger = new Logger('market') | |||||||
| 
 | 
 | ||||||
| export const name = 'market-info' | export const name = 'market-info' | ||||||
| 
 | 
 | ||||||
| export const using = ['installer'] |  | ||||||
| 
 |  | ||||||
| export interface Rule { | export interface Rule { | ||||||
|   platform: string |   platform: string | ||||||
|   channelId: string |   channelId: string | ||||||
| @ -24,6 +22,7 @@ export const Rule: Schema<Rule> = Schema.object({ | |||||||
| 
 | 
 | ||||||
| export interface Config { | export interface Config { | ||||||
|   rules: Rule[] |   rules: Rule[] | ||||||
|  |   endpoint: string | ||||||
|   interval: number |   interval: number | ||||||
|   showHidden: boolean |   showHidden: boolean | ||||||
|   showDeletion: boolean |   showDeletion: boolean | ||||||
| @ -33,6 +32,7 @@ export interface Config { | |||||||
| 
 | 
 | ||||||
| export const Config: Schema<Config> = Schema.object({ | export const Config: Schema<Config> = Schema.object({ | ||||||
|   rules: Schema.array(Rule).description('推送规则。'), |   rules: Schema.array(Rule).description('推送规则。'), | ||||||
|  |   endpoint: Schema.string().default('https://registry.koishi.chat/index.json').description('插件市场地址。'), | ||||||
|   interval: Schema.number().default(Time.minute * 30).description('轮询间隔 (毫秒)。'), |   interval: Schema.number().default(Time.minute * 30).description('轮询间隔 (毫秒)。'), | ||||||
|   showHidden: Schema.boolean().default(false).description('是否显示隐藏的插件。'), |   showHidden: Schema.boolean().default(false).description('是否显示隐藏的插件。'), | ||||||
|   showDeletion: Schema.boolean().default(false).description('是否显示删除的插件。'), |   showDeletion: Schema.boolean().default(false).description('是否显示删除的插件。'), | ||||||
| @ -53,7 +53,7 @@ export function apply(ctx: Context, config: Config) { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const getMarket = async () => { |   const getMarket = async () => { | ||||||
|     const data = await ctx.http.get<SearchResult>(ctx.installer.endpoint) |     const data = await ctx.http.get<SearchResult>(config.endpoint) | ||||||
|     return makeDict(data) |     return makeDict(data) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user