From cd773b8cc9f8d8ae8db5f0173323be1a8185b994 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Sun, 3 Mar 2024 14:25:50 +0800 Subject: [PATCH] app import supported --- web/app/components/explore/app-list/index.tsx | 12 ++++-------- web/service/apps.ts | 4 ++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx index 0fa0003e4a..9572325397 100644 --- a/web/app/components/explore/app-list/index.tsx +++ b/web/app/components/explore/app-list/index.tsx @@ -13,13 +13,12 @@ import type { App } from '@/models/explore' import Category from '@/app/components/explore/category' import AppCard from '@/app/components/explore/app-card' import { fetchAppDetail, fetchAppList } from '@/service/explore' -import { createApp } from '@/service/apps' +import { importApp } from '@/service/apps' import { useTabSearchParams } from '@/hooks/use-tab-searchparams' import CreateAppModal from '@/app/components/explore/create-app-modal' import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal' import Loading from '@/app/components/base/loading' import { NEED_REFRESH_APP_LIST_KEY } from '@/config' -import { type AppMode } from '@/types/app' import { useAppContext } from '@/context/app-context' type AppsProps = { @@ -73,19 +72,16 @@ const Apps = ({ icon_background, description, }) => { - const { app_model_config: model_config } = await fetchAppDetail( + const { export_data } = await fetchAppDetail( currApp?.app.id as string, ) - // #TODO# need yaml config from app detail - // #TODO# use import api try { - const app = await createApp({ + const app = await importApp({ + data: export_data, name, icon, icon_background, - mode: currApp?.app.mode as AppMode, description, - config: model_config, }) setIsShowCreateModal(false) Toast.notify({ diff --git a/web/service/apps.ts b/web/service/apps.ts index 08897ee95d..abc3a73e07 100644 --- a/web/service/apps.ts +++ b/web/service/apps.ts @@ -28,6 +28,10 @@ export const exportAppConfig: Fetcher<{ data: string }, string> = (appID) => { return post<{ data: string }>(`apps/${appID}/export`) } +export const importApp: Fetcher = ({ name, description, icon, icon_background }) => { + return post('apps/import', { body: { name, description, icon, icon_background } }) +} + export const deleteApp: Fetcher = (appID) => { return del(`apps/${appID}`) }