feat: 助手配置与服务命令扩展及依赖更新
This commit is contained in:
		
							
								
								
									
										27
									
								
								assistant/src/routes/config/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								assistant/src/routes/config/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import { app, assistantConfig } from '@/app.ts'; | ||||
| // import { getCacheAssistantConfig, setConfig } from '@/modules/config/index.ts'; | ||||
| // import { reload } from '@/modules/parent-msg.ts'; | ||||
|  | ||||
| app | ||||
|   .route({ | ||||
|     path: 'config', | ||||
|     description: '获取配置', | ||||
|   }) | ||||
|   .define(async (ctx) => { | ||||
|     ctx.body = assistantConfig.getCacheAssistantConfig(); | ||||
|   }) | ||||
|   .addTo(app); | ||||
|  | ||||
| app | ||||
|   .route({ | ||||
|     path: 'config', | ||||
|     key: 'set', | ||||
|     description: '设置配置', | ||||
|   }) | ||||
|   .define(async (ctx) => { | ||||
|     const { data } = ctx.query; | ||||
|     // reload(); | ||||
|  | ||||
|     ctx.body = assistantConfig.setConfig(data); | ||||
|   }) | ||||
|   .addTo(app); | ||||
							
								
								
									
										2
									
								
								assistant/src/routes/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								assistant/src/routes/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| import './config/index.ts' | ||||
| import './shop-install/index.ts' | ||||
							
								
								
									
										61
									
								
								assistant/src/routes/shop-install/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								assistant/src/routes/shop-install/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| import { app } from '@/app.ts'; | ||||
| // import { getInstallList, installApp, uninstallApp } from '@/modules/install.ts'; | ||||
| const getInstallList = async () => { | ||||
|   return []; | ||||
| }; | ||||
| const installApp = async (pkg: string) => { | ||||
|   return { | ||||
|     code: 200, | ||||
|     message: 'success', | ||||
|     data: { | ||||
|       pkg, | ||||
|     }, | ||||
|   }; | ||||
| }; | ||||
| const uninstallApp = async (pkg: string) => { | ||||
|   return { | ||||
|     code: 200, | ||||
|     message: 'success', | ||||
|   }; | ||||
| }; | ||||
|  | ||||
| app | ||||
|   .route({ | ||||
|     path: 'shop', | ||||
|     key: 'list-installed', | ||||
|   }) | ||||
|   .define(async (ctx) => { | ||||
|     // https://localhost:51015/client/router?path=shop&key=list-installed | ||||
|     const list = await getInstallList(); | ||||
|     ctx.body = list; | ||||
|   }) | ||||
|   .addTo(app); | ||||
|  | ||||
| app | ||||
|   .route({ | ||||
|     path: 'shop', | ||||
|     key: 'install', | ||||
|   }) | ||||
|   .define(async (ctx) => { | ||||
|     // https://localhost:51015/client/router?path=shop&key=install | ||||
|     const { pkg } = ctx.query.data; | ||||
|     const res = await installApp(pkg); | ||||
|     if (res.code !== 200) { | ||||
|       ctx.throw(res.code, res.message); | ||||
|     } | ||||
|     ctx.body = res; | ||||
|   }) | ||||
|   .addTo(app); | ||||
|  | ||||
| app | ||||
|   .route({ | ||||
|     path: 'shop', | ||||
|     key: 'uninstall', | ||||
|   }) | ||||
|   .define(async (ctx) => { | ||||
|     // https://localhost:51015/client/router?path=shop&key=uninstall | ||||
|     const { pkg } = ctx.query.data; | ||||
|     const res = await uninstallApp(pkg); | ||||
|     ctx.body = res; | ||||
|   }) | ||||
|   .addTo(app); | ||||
		Reference in New Issue
	
	Block a user