App template market (#2337)
* feat: add app template market (#2012) * feat: add app template market * fix * fix * i18n * fix * perf: template market ux * perf: simple mode app ui * perf: tempalte modal ui * perf: tempalte market ui * perf: template position * feat: create app modal * regiter default app * perf: icon * change templates position (#2331) * change templates position * fix * perf: template market ux --------- Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
@@ -22,10 +22,11 @@ export type CreateAppBody = {
|
||||
type?: AppTypeEnum;
|
||||
modules: AppSchema['modules'];
|
||||
edges?: AppSchema['edges'];
|
||||
chatConfig?: AppSchema['chatConfig'];
|
||||
};
|
||||
|
||||
async function handler(req: ApiRequestProps<CreateAppBody>) {
|
||||
const { parentId, name, avatar, type, modules, edges } = req.body;
|
||||
const { parentId, name, avatar, type, modules, edges, chatConfig } = req.body;
|
||||
|
||||
if (!name || !type || !Array.isArray(modules)) {
|
||||
return Promise.reject(CommonErrEnum.inheritPermissionError);
|
||||
@@ -50,6 +51,7 @@ async function handler(req: ApiRequestProps<CreateAppBody>) {
|
||||
type,
|
||||
modules,
|
||||
edges,
|
||||
chatConfig,
|
||||
teamId,
|
||||
tmbId
|
||||
});
|
||||
@@ -67,6 +69,7 @@ export const onCreateApp = async ({
|
||||
type,
|
||||
modules,
|
||||
edges,
|
||||
chatConfig,
|
||||
teamId,
|
||||
tmbId,
|
||||
pluginData,
|
||||
@@ -78,6 +81,7 @@ export const onCreateApp = async ({
|
||||
type?: AppTypeEnum;
|
||||
modules?: AppSchema['modules'];
|
||||
edges?: AppSchema['edges'];
|
||||
chatConfig?: AppSchema['chatConfig'];
|
||||
intro?: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
@@ -96,6 +100,7 @@ export const onCreateApp = async ({
|
||||
tmbId,
|
||||
modules,
|
||||
edges,
|
||||
chatConfig,
|
||||
type,
|
||||
version: 'v2',
|
||||
pluginData,
|
||||
@@ -111,7 +116,8 @@ export const onCreateApp = async ({
|
||||
{
|
||||
appId,
|
||||
nodes: modules,
|
||||
edges
|
||||
edges,
|
||||
chatConfig
|
||||
}
|
||||
],
|
||||
{ session }
|
||||
|
||||
21
projects/app/src/pages/api/core/app/template/detail.ts
Normal file
21
projects/app/src/pages/api/core/app/template/detail.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { TemplateMarketItemType } from '@fastgpt/global/core/workflow/type';
|
||||
import { getTemplateMarketItemDetail } from '@/service/core/app/template';
|
||||
|
||||
type Props = {
|
||||
templateId: string;
|
||||
};
|
||||
|
||||
async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse<any>
|
||||
): Promise<TemplateMarketItemType | undefined> {
|
||||
await authCert({ req, authToken: true });
|
||||
const { templateId } = req.query as Props;
|
||||
|
||||
return getTemplateMarketItemDetail(templateId);
|
||||
}
|
||||
|
||||
export default NextAPI(handler);
|
||||
16
projects/app/src/pages/api/core/app/template/list.ts
Normal file
16
projects/app/src/pages/api/core/app/template/list.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { TemplateMarketListItemType } from '@fastgpt/global/core/workflow/type';
|
||||
import { getTemplateMarketItemList } from '@/service/core/app/template';
|
||||
|
||||
async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse<any>
|
||||
): Promise<TemplateMarketListItemType[]> {
|
||||
await authCert({ req, authToken: true });
|
||||
|
||||
return getTemplateMarketItemList();
|
||||
}
|
||||
|
||||
export default NextAPI(handler);
|
||||
Reference in New Issue
Block a user