2026-02-14 08:18:26 +00:00
|
|
|
import type { ChatConfig } from '@/app/components/base/chat/types'
|
|
|
|
|
import type { ExploreAppDetailResponse } from '@/contract/console/explore'
|
|
|
|
|
import type { AppMeta } from '@/models/share'
|
|
|
|
|
import { consoleClient } from './client'
|
2023-05-25 08:59:47 +00:00
|
|
|
|
2026-02-14 08:18:26 +00:00
|
|
|
export const fetchAppList = (language?: string) => {
|
|
|
|
|
if (!language)
|
|
|
|
|
return consoleClient.explore.apps({})
|
|
|
|
|
|
|
|
|
|
return consoleClient.explore.apps({
|
|
|
|
|
query: { language },
|
|
|
|
|
})
|
2023-05-25 08:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-14 08:18:26 +00:00
|
|
|
export const fetchAppDetail = async (id: string): Promise<ExploreAppDetailResponse> => {
|
|
|
|
|
const response = await consoleClient.explore.appDetail({
|
|
|
|
|
params: { id },
|
|
|
|
|
})
|
|
|
|
|
if (!response)
|
|
|
|
|
throw new Error('Recommended app not found')
|
|
|
|
|
return response
|
2023-05-25 08:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-14 08:18:26 +00:00
|
|
|
export const fetchInstalledAppList = (appId?: string | null) => {
|
|
|
|
|
if (!appId)
|
|
|
|
|
return consoleClient.explore.installedApps({})
|
|
|
|
|
|
|
|
|
|
return consoleClient.explore.installedApps({
|
|
|
|
|
query: { app_id: appId },
|
|
|
|
|
})
|
2023-05-25 08:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const uninstallApp = (id: string) => {
|
2026-02-14 08:18:26 +00:00
|
|
|
return consoleClient.explore.uninstallInstalledApp({
|
|
|
|
|
params: { id },
|
|
|
|
|
})
|
2023-05-25 08:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const updatePinStatus = (id: string, isPinned: boolean) => {
|
2026-02-14 08:18:26 +00:00
|
|
|
return consoleClient.explore.updateInstalledApp({
|
|
|
|
|
params: { id },
|
2023-05-25 08:59:47 +00:00
|
|
|
body: {
|
2023-06-01 15:19:36 +00:00
|
|
|
is_pinned: isPinned,
|
|
|
|
|
},
|
2023-05-25 08:59:47 +00:00
|
|
|
})
|
|
|
|
|
}
|
2023-07-27 05:27:34 +00:00
|
|
|
|
2025-07-17 02:52:10 +00:00
|
|
|
export const getAppAccessModeByAppId = (appId: string) => {
|
2026-02-14 08:18:26 +00:00
|
|
|
return consoleClient.explore.appAccessMode({
|
|
|
|
|
query: { appId },
|
|
|
|
|
})
|
2025-07-17 02:52:10 +00:00
|
|
|
}
|
2026-01-22 10:16:37 +00:00
|
|
|
|
2026-02-14 08:18:26 +00:00
|
|
|
export const fetchInstalledAppParams = (appId: string) => {
|
|
|
|
|
return consoleClient.explore.installedAppParameters({
|
|
|
|
|
params: { appId },
|
|
|
|
|
}) as Promise<ChatConfig>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const fetchInstalledAppMeta = (appId: string) => {
|
|
|
|
|
return consoleClient.explore.installedAppMeta({
|
|
|
|
|
params: { appId },
|
|
|
|
|
}) as Promise<AppMeta>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const fetchBanners = (language?: string) => {
|
|
|
|
|
if (!language)
|
|
|
|
|
return consoleClient.explore.banners({})
|
|
|
|
|
|
|
|
|
|
return consoleClient.explore.banners({
|
|
|
|
|
query: { language },
|
|
|
|
|
})
|
2026-01-22 10:16:37 +00:00
|
|
|
}
|