Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/web/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
"type.Plugin": "Plugin",
"type.Simple bot": "Simple App",
"type.Workflow bot": "Workflow",
"type.error.URLempty": "The URL cannot be empty",
"type.error.Workflow data is empty": "No workflow data was obtained",
"type.error.workflowresponseempty": "Response content is empty",
"type_not_recognized": "App type not recognized",
Expand Down
1 change: 0 additions & 1 deletion packages/web/i18n/zh-CN/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@
"type.Plugin": "插件",
"type.Simple bot": "简易应用",
"type.Workflow bot": "工作流",
"type.error.URLempty": "URL不能为空",
"type.error.Workflow data is empty": "没有获取到工作流数据",
"type.error.workflowresponseempty": "响应内容为空",
"type_not_recognized": "未识别到应用类型",
Expand Down
1 change: 0 additions & 1 deletion packages/web/i18n/zh-Hant/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
"type.Plugin": "外掛",
"type.Simple bot": "簡易應用程式",
"type.Workflow bot": "工作流程",
"type.error.URLempty": "URL不能為空",
"type.error.Workflow data is empty": "沒有獲取到工作流數據",
"type.error.workflowresponseempty": "響應內容為空",
"type_not_recognized": "未識別到應用程式類型",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { postCreateApp } from '@/web/core/app/api';
import { useRouter } from 'next/router';
import { form2AppWorkflow } from '@/web/core/app/utils';
import ImportAppConfigEditor from '@/pageComponents/app/ImportAppConfigEditor';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { getFetchWorkflow } from '@/web/core/app/api/app';
import { postFetchWorkflow } from '@/web/support/marketing/api';
import {
getUtmParams,
getUtmWorkflow,
Expand Down Expand Up @@ -50,7 +49,7 @@ const JsonImportModal = ({ onClose }: { onClose: () => void }) => {
const url = getUtmWorkflow();
if (!url) return;

const workflowData = await getFetchWorkflow({ url });
const workflowData = await postFetchWorkflow({ url });

setValue('workflowStr', JSON.stringify(workflowData, null, 2));

Expand Down
51 changes: 0 additions & 51 deletions projects/app/src/pages/api/core/app/fetchWorkflow.ts

This file was deleted.

46 changes: 46 additions & 0 deletions projects/app/src/pages/api/support/marketing/fetchWorkflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { NextAPI } from '@/service/middleware/entry';
import { ApiRequestProps } from '@fastgpt/service/type/next';
import axios from 'axios';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
import { isInternalAddress } from '@fastgpt/service/common/system/utils';
import { NextApiResponse } from 'next';

export type FetchWorkflowBody = {
url: string;
};

export type FetchWorkflowQuery = {};

export type FetchWorkflowResponseType = {
data: Record<string, any>;
};

async function handler(
req: ApiRequestProps<FetchWorkflowBody, FetchWorkflowQuery>,
res: NextApiResponse
): Promise<FetchWorkflowResponseType> {
await authCert({ req, authToken: true });

const url = req.body?.url;

if (!url) {
return Promise.reject('Url is empty');
}
if (isInternalAddress(url)) {
return Promise.reject('Url is invalid');
}

const { data } = await axios.get(url, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (compatible; FastGPT/1.0)'
},
timeout: 30000,
validateStatus: (status) => status < 500
});

return data;
}

export default NextAPI(handler);
6 changes: 4 additions & 2 deletions projects/app/src/web/context/useInitApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const useInitApp = () => {
});

// Marketing data track
useEffect(() => {
useMount(() => {
setInviterId(hiId);
setBdVId(bd_vid);
setUtmWorkflow(utm_workflow);
Expand All @@ -97,7 +97,9 @@ export const useInitApp = () => {
};
setUtmParams(utmParams);
setFastGPTSem({ keyword: k, ...utmParams });
}, [bd_vid, hiId, k, utm_workflow, sourceDomain, utm_source, utm_medium, utm_content]);

router.replace(router.pathname);
});

return {
feConfigs,
Expand Down
7 changes: 0 additions & 7 deletions projects/app/src/web/core/app/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import type {
} from '@/pages/api/core/app/transitionWorkflow';
import type { copyAppQuery, copyAppResponse } from '@/pages/api/core/app/copy';

import type {
FetchWorkflowQuery,
FetchWorkflowResponseType
} from '@/pages/api/core/app/fetchWorkflow';
/* folder */
export const postCreateAppFolder = (data: CreateAppFolderBody) =>
POST('/core/app/folder/create', data);
Expand All @@ -29,6 +25,3 @@ export const postTransition2Workflow = (data: transitionWorkflowBody) =>
POST<transitionWorkflowResponse>('/core/app/transitionWorkflow', data);

export const postCopyApp = (data: copyAppQuery) => POST<copyAppResponse>('/core/app/copy', data);

export const getFetchWorkflow = (data: FetchWorkflowQuery) =>
GET<FetchWorkflowResponseType>('/core/app/fetchWorkflow', data);
8 changes: 8 additions & 0 deletions projects/app/src/web/support/marketing/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { POST } from '@/web/common/api/request';
import {
FetchWorkflowQuery,
FetchWorkflowResponseType
} from '@/pages/api/support/marketing/fetchWorkflow';

export const postFetchWorkflow = (data: FetchWorkflowQuery) =>
POST<FetchWorkflowResponseType>('/support/marketing/fetchWorkflow', data);
Loading