mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-25 22:06:06 +00:00
feat(web): add marketplace likes (#2352)
Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
This commit is contained in:
@@ -48,6 +48,8 @@ export interface PluginV4 {
|
||||
repository: string;
|
||||
tags: string[];
|
||||
install_count: number;
|
||||
like_count?: number;
|
||||
hot_score?: number;
|
||||
latest_version: string;
|
||||
components: Record<string, number>;
|
||||
status: PluginV4Status;
|
||||
|
||||
@@ -117,6 +117,32 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
.catch(() => this.searchMarketplaceExtensionsLegacy(data));
|
||||
}
|
||||
|
||||
public getMarketplaceLikedExtensions(
|
||||
fingerprint: string,
|
||||
): Promise<{ extensions: Array<{ type: string; extension_id: string }> }> {
|
||||
return this.post('/api/v1/marketplace/extensions/likes/status', {
|
||||
fingerprint,
|
||||
});
|
||||
}
|
||||
|
||||
public setMarketplaceExtensionLike(
|
||||
type: string,
|
||||
author: string,
|
||||
name: string,
|
||||
fingerprint: string,
|
||||
liked: boolean,
|
||||
): Promise<{
|
||||
type: string;
|
||||
extension_id: string;
|
||||
liked: boolean;
|
||||
like_count: number;
|
||||
}> {
|
||||
return this.put(
|
||||
`/api/v1/marketplace/extensions/${encodeURIComponent(type)}/${encodeURIComponent(author)}/${encodeURIComponent(name)}/like`,
|
||||
{ fingerprint, liked },
|
||||
);
|
||||
}
|
||||
|
||||
private async searchMarketplaceExtensionsLegacy(data: {
|
||||
query?: string;
|
||||
page: number;
|
||||
@@ -128,6 +154,8 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
tags_filter?: string[];
|
||||
}): Promise<ApiRespMarketplacePlugins> {
|
||||
const query = data.query || '';
|
||||
const legacySortBy =
|
||||
data.sort_by === 'hot_score' ? 'install_count' : data.sort_by;
|
||||
|
||||
if (
|
||||
data.type_filter === 'plugin' ||
|
||||
@@ -139,7 +167,7 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
query,
|
||||
data.page,
|
||||
data.page_size,
|
||||
data.sort_by,
|
||||
legacySortBy,
|
||||
data.sort_order,
|
||||
data.component_filter,
|
||||
data.tags_filter,
|
||||
@@ -157,7 +185,7 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
query,
|
||||
data.page,
|
||||
data.page_size,
|
||||
data.sort_by,
|
||||
legacySortBy,
|
||||
data.sort_order,
|
||||
undefined,
|
||||
data.tags_filter,
|
||||
@@ -167,7 +195,7 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
query,
|
||||
data.page,
|
||||
data.page_size,
|
||||
data.sort_by,
|
||||
legacySortBy,
|
||||
data.sort_order,
|
||||
undefined,
|
||||
data.tags_filter,
|
||||
@@ -177,7 +205,7 @@ export class CloudServiceClient extends BaseHttpClient {
|
||||
query,
|
||||
data.page,
|
||||
data.page_size,
|
||||
data.sort_by,
|
||||
legacySortBy,
|
||||
data.sort_order,
|
||||
undefined,
|
||||
data.tags_filter,
|
||||
|
||||
Reference in New Issue
Block a user