mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-23 04:46:07 +00:00
feat: marketplace page
This commit is contained in:
@@ -259,6 +259,18 @@ export class BackendClient extends BaseHttpClient {
|
||||
return this.postFile('/api/v1/plugins/install/local', formData);
|
||||
}
|
||||
|
||||
public installPluginFromMarketplace(
|
||||
author: string,
|
||||
name: string,
|
||||
version: string,
|
||||
): Promise<AsyncTaskCreatedResp> {
|
||||
return this.post('/api/v1/plugins/install/marketplace', {
|
||||
plugin_author: author,
|
||||
plugin_name: name,
|
||||
plugin_version: version,
|
||||
});
|
||||
}
|
||||
|
||||
public removePlugin(
|
||||
author: string,
|
||||
name: string,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { BaseHttpClient } from './BaseHttpClient';
|
||||
import { MarketPluginResponse } from '@/app/infra/entities/api';
|
||||
import {
|
||||
ApiRespMarketplacePluginDetail,
|
||||
ApiRespMarketplacePlugins,
|
||||
} from '@/app/infra/entities/api';
|
||||
|
||||
/**
|
||||
* 云服务客户端
|
||||
@@ -11,29 +14,59 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
super(baseURL, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件市场插件列表
|
||||
* @param page 页码
|
||||
* @param page_size 每页大小
|
||||
* @param query 搜索关键词
|
||||
* @param sort_by 排序字段
|
||||
* @param sort_order 排序顺序
|
||||
*/
|
||||
public getMarketPlugins(
|
||||
public getMarketplacePlugins(
|
||||
page: number,
|
||||
page_size: number,
|
||||
query: string,
|
||||
sort_by: string = 'stars',
|
||||
sort_order: string = 'DESC',
|
||||
): Promise<MarketPluginResponse> {
|
||||
return this.post(`/api/v1/market/plugins`, {
|
||||
page,
|
||||
page_size,
|
||||
query,
|
||||
sort_by,
|
||||
sort_order,
|
||||
sort_by?: string,
|
||||
sort_order?: string,
|
||||
): Promise<ApiRespMarketplacePlugins> {
|
||||
return this.get<ApiRespMarketplacePlugins>('/api/v1/marketplace/plugins', {
|
||||
params: { page, page_size, sort_by, sort_order },
|
||||
});
|
||||
}
|
||||
|
||||
// 未来可以在这里添加更多 cloud service 相关的方法
|
||||
public searchMarketplacePlugins(
|
||||
query: string,
|
||||
page: number,
|
||||
page_size: number,
|
||||
sort_by?: string,
|
||||
sort_order?: string,
|
||||
): Promise<ApiRespMarketplacePlugins> {
|
||||
return this.post<ApiRespMarketplacePlugins>(
|
||||
'/api/v1/marketplace/plugins/search',
|
||||
{
|
||||
query,
|
||||
page,
|
||||
page_size,
|
||||
sort_by,
|
||||
sort_order,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getPluginDetail(
|
||||
author: string,
|
||||
pluginName: string,
|
||||
): Promise<ApiRespMarketplacePluginDetail> {
|
||||
return this.get<ApiRespMarketplacePluginDetail>(
|
||||
`/api/v1/marketplace/plugins/${author}/${pluginName}`,
|
||||
);
|
||||
}
|
||||
|
||||
public getPluginREADME(
|
||||
author: string,
|
||||
pluginName: string,
|
||||
): Promise<{ readme: string }> {
|
||||
return this.get<{ readme: string }>(
|
||||
`/api/v1/marketplace/plugins/${author}/${pluginName}/resources/README`,
|
||||
);
|
||||
}
|
||||
|
||||
public getPluginIconURL(author: string, name: string): string {
|
||||
return `${this.baseURL}/api/v1/marketplace/plugins/${author}/${name}/resources/icon`;
|
||||
}
|
||||
|
||||
public getPluginMarketplaceURL(author: string, name: string): string {
|
||||
return `${this.baseURL}/market?author=${author}&plugin=${name}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,11 @@ const marketPlugins = await cloudClient.getMarketPlugins(1, 10, 'search term');
|
||||
// 使用云服务客户端(同步方式,可能使用默认 URL)
|
||||
import { cloudServiceClient } from '@/app/infra/http';
|
||||
|
||||
const marketPlugins = await cloudServiceClient.getMarketPlugins(1, 10, 'search term');
|
||||
const marketPlugins = await cloudServiceClient.getMarketPlugins(
|
||||
1,
|
||||
10,
|
||||
'search term',
|
||||
);
|
||||
```
|
||||
|
||||
### 向后兼容(不推荐)
|
||||
|
||||
Reference in New Issue
Block a user