Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
d6fed3d2
authored
Apr 27, 2025
by
Archer
Committed by
GitHub
Apr 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: fetch url (#4687)
parent
1d202678
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
36 deletions
+30
-36
packages/web/i18n/en/app.json
+0
-1
packages/web/i18n/zh-CN/app.json
+0
-1
packages/web/i18n/zh-Hant/app.json
+0
-1
projects/app/src/pageComponents/dashboard/apps/JsonImportModal.tsx
+2
-3
projects/app/src/pages/api/support/marketing/fetchWorkflow.ts
+16
-21
projects/app/src/web/context/useInitApp.ts
+4
-2
projects/app/src/web/core/app/api/app.ts
+0
-7
projects/app/src/web/support/marketing/api.ts
+8
-0
No files found.
packages/web/i18n/en/app.json
View file @
d6fed3d2
...
@@ -187,7 +187,6 @@
...
@@ -187,7 +187,6 @@
"type.Plugin"
:
"Plugin"
,
"type.Plugin"
:
"Plugin"
,
"type.Simple bot"
:
"Simple App"
,
"type.Simple bot"
:
"Simple App"
,
"type.Workflow bot"
:
"Workflow"
,
"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.Workflow data is empty"
:
"No workflow data was obtained"
,
"type.error.workflowresponseempty"
:
"Response content is empty"
,
"type.error.workflowresponseempty"
:
"Response content is empty"
,
"type_not_recognized"
:
"App type not recognized"
,
"type_not_recognized"
:
"App type not recognized"
,
...
...
packages/web/i18n/zh-CN/app.json
View file @
d6fed3d2
...
@@ -196,7 +196,6 @@
...
@@ -196,7 +196,6 @@
"type.Plugin"
:
"插件"
,
"type.Plugin"
:
"插件"
,
"type.Simple bot"
:
"简易应用"
,
"type.Simple bot"
:
"简易应用"
,
"type.Workflow bot"
:
"工作流"
,
"type.Workflow bot"
:
"工作流"
,
"type.error.URLempty"
:
"URL不能为空"
,
"type.error.Workflow data is empty"
:
"没有获取到工作流数据"
,
"type.error.Workflow data is empty"
:
"没有获取到工作流数据"
,
"type.error.workflowresponseempty"
:
"响应内容为空"
,
"type.error.workflowresponseempty"
:
"响应内容为空"
,
"type_not_recognized"
:
"未识别到应用类型"
,
"type_not_recognized"
:
"未识别到应用类型"
,
...
...
packages/web/i18n/zh-Hant/app.json
View file @
d6fed3d2
...
@@ -187,7 +187,6 @@
...
@@ -187,7 +187,6 @@
"type.Plugin"
:
"外掛"
,
"type.Plugin"
:
"外掛"
,
"type.Simple bot"
:
"簡易應用程式"
,
"type.Simple bot"
:
"簡易應用程式"
,
"type.Workflow bot"
:
"工作流程"
,
"type.Workflow bot"
:
"工作流程"
,
"type.error.URLempty"
:
"URL不能為空"
,
"type.error.Workflow data is empty"
:
"沒有獲取到工作流數據"
,
"type.error.Workflow data is empty"
:
"沒有獲取到工作流數據"
,
"type.error.workflowresponseempty"
:
"響應內容為空"
,
"type.error.workflowresponseempty"
:
"響應內容為空"
,
"type_not_recognized"
:
"未識別到應用程式類型"
,
"type_not_recognized"
:
"未識別到應用程式類型"
,
...
...
projects/app/src/pageComponents/dashboard/apps/JsonImportModal.tsx
View file @
d6fed3d2
...
@@ -16,8 +16,7 @@ import { postCreateApp } from '@/web/core/app/api';
...
@@ -16,8 +16,7 @@ import { postCreateApp } from '@/web/core/app/api';
import
{
useRouter
}
from
'next/router'
;
import
{
useRouter
}
from
'next/router'
;
import
{
form2AppWorkflow
}
from
'@/web/core/app/utils'
;
import
{
form2AppWorkflow
}
from
'@/web/core/app/utils'
;
import
ImportAppConfigEditor
from
'@/pageComponents/app/ImportAppConfigEditor'
;
import
ImportAppConfigEditor
from
'@/pageComponents/app/ImportAppConfigEditor'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
postFetchWorkflow
}
from
'@/web/support/marketing/api'
;
import
{
getFetchWorkflow
}
from
'@/web/core/app/api/app'
;
import
{
import
{
getUtmParams
,
getUtmParams
,
getUtmWorkflow
,
getUtmWorkflow
,
...
@@ -50,7 +49,7 @@ const JsonImportModal = ({ onClose }: { onClose: () => void }) => {
...
@@ -50,7 +49,7 @@ const JsonImportModal = ({ onClose }: { onClose: () => void }) => {
const
url
=
getUtmWorkflow
();
const
url
=
getUtmWorkflow
();
if
(
!
url
)
return
;
if
(
!
url
)
return
;
const
workflowData
=
await
ge
tFetchWorkflow
({
url
});
const
workflowData
=
await
pos
tFetchWorkflow
({
url
});
setValue
(
'workflowStr'
,
JSON
.
stringify
(
workflowData
,
null
,
2
));
setValue
(
'workflowStr'
,
JSON
.
stringify
(
workflowData
,
null
,
2
));
...
...
projects/app/src/pages/api/
core/app
/fetchWorkflow.ts
→
projects/app/src/pages/api/
support/marketing
/fetchWorkflow.ts
View file @
d6fed3d2
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
{
ApiRequestProps
}
from
'@fastgpt/service/type/next'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
authCert
}
from
'@fastgpt/service/support/permission/auth/common'
;
import
{
authCert
}
from
'@fastgpt/service/support/permission/auth/common'
;
import
{
isInternalAddress
}
from
'@fastgpt/service/common/system/utils'
;
import
{
NextApiResponse
}
from
'next'
;
export
type
FetchWorkflowBody
=
{
export
type
FetchWorkflowBody
=
{
url
:
string
;
url
:
string
;
};
};
export
type
FetchWorkflowQuery
=
{
export
type
FetchWorkflowQuery
=
{};
url
:
string
;
};
export
type
FetchWorkflowResponseType
=
ApiResponseType
<
{
export
type
FetchWorkflowResponseType
=
{
data
:
JSON
;
data
:
Record
<
string
,
any
>
;
}
>
;
};
async
function
handler
(
async
function
handler
(
req
:
ApiRequestProps
<
FetchWorkflowBody
,
FetchWorkflowQuery
>
,
req
:
ApiRequestProps
<
FetchWorkflowBody
,
FetchWorkflowQuery
>
,
res
:
FetchWorkflowResponseTyp
e
res
:
NextApiRespons
e
)
{
)
:
Promise
<
FetchWorkflowResponseType
>
{
await
authCert
({
req
,
authToken
:
true
});
await
authCert
({
req
,
authToken
:
true
});
const
url
=
req
.
body
?.
url
||
req
.
query
?.
url
;
const
url
=
req
.
body
?.
url
;
if
(
!
url
)
{
if
(
!
url
)
{
return
Promise
.
reject
(
'app:type.error.URLempty'
);
return
Promise
.
reject
(
'Url is empty'
);
}
if
(
isInternalAddress
(
url
))
{
return
Promise
.
reject
(
'Url is invalid'
);
}
}
const
response
=
await
axios
.
get
(
url
,
{
const
{
data
}
=
await
axios
.
get
(
url
,
{
headers
:
{
headers
:
{
Accept
:
'application/json'
,
Accept
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
...
@@ -37,15 +40,7 @@ async function handler(
...
@@ -37,15 +40,7 @@ async function handler(
validateStatus
:
(
status
)
=>
status
<
500
validateStatus
:
(
status
)
=>
status
<
500
});
});
const
contentType
=
response
.
headers
[
'content-type'
]
||
''
;
return
data
;
if
(
!
response
.
data
||
response
.
data
.
length
===
0
)
{
return
Promise
.
reject
(
'app:type.error.workflowresponseempty'
);
}
JSON
.
parse
(
JSON
.
stringify
(
response
.
data
));
return
response
.
data
;
}
}
export
default
NextAPI
(
handler
);
export
default
NextAPI
(
handler
);
projects/app/src/web/context/useInitApp.ts
View file @
d6fed3d2
...
@@ -84,7 +84,7 @@ export const useInitApp = () => {
...
@@ -84,7 +84,7 @@ export const useInitApp = () => {
});
});
// Marketing data track
// Marketing data track
use
Effec
t
(()
=>
{
use
Moun
t
(()
=>
{
setInviterId
(
hiId
);
setInviterId
(
hiId
);
setBdVId
(
bd_vid
);
setBdVId
(
bd_vid
);
setUtmWorkflow
(
utm_workflow
);
setUtmWorkflow
(
utm_workflow
);
...
@@ -97,7 +97,9 @@ export const useInitApp = () => {
...
@@ -97,7 +97,9 @@ export const useInitApp = () => {
};
};
setUtmParams
(
utmParams
);
setUtmParams
(
utmParams
);
setFastGPTSem
({
keyword
:
k
,
...
utmParams
});
setFastGPTSem
({
keyword
:
k
,
...
utmParams
});
},
[
bd_vid
,
hiId
,
k
,
utm_workflow
,
sourceDomain
,
utm_source
,
utm_medium
,
utm_content
]);
router
.
replace
(
router
.
pathname
);
});
return
{
return
{
feConfigs
,
feConfigs
,
...
...
projects/app/src/web/core/app/api/app.ts
View file @
d6fed3d2
...
@@ -10,10 +10,6 @@ import type {
...
@@ -10,10 +10,6 @@ import type {
}
from
'@/pages/api/core/app/transitionWorkflow'
;
}
from
'@/pages/api/core/app/transitionWorkflow'
;
import
type
{
copyAppQuery
,
copyAppResponse
}
from
'@/pages/api/core/app/copy'
;
import
type
{
copyAppQuery
,
copyAppResponse
}
from
'@/pages/api/core/app/copy'
;
import
type
{
FetchWorkflowQuery
,
FetchWorkflowResponseType
}
from
'@/pages/api/core/app/fetchWorkflow'
;
/* folder */
/* folder */
export
const
postCreateAppFolder
=
(
data
:
CreateAppFolderBody
)
=>
export
const
postCreateAppFolder
=
(
data
:
CreateAppFolderBody
)
=>
POST
(
'/core/app/folder/create'
,
data
);
POST
(
'/core/app/folder/create'
,
data
);
...
@@ -29,6 +25,3 @@ export const postTransition2Workflow = (data: transitionWorkflowBody) =>
...
@@ -29,6 +25,3 @@ export const postTransition2Workflow = (data: transitionWorkflowBody) =>
POST
<
transitionWorkflowResponse
>
(
'/core/app/transitionWorkflow'
,
data
);
POST
<
transitionWorkflowResponse
>
(
'/core/app/transitionWorkflow'
,
data
);
export
const
postCopyApp
=
(
data
:
copyAppQuery
)
=>
POST
<
copyAppResponse
>
(
'/core/app/copy'
,
data
);
export
const
postCopyApp
=
(
data
:
copyAppQuery
)
=>
POST
<
copyAppResponse
>
(
'/core/app/copy'
,
data
);
export
const
getFetchWorkflow
=
(
data
:
FetchWorkflowQuery
)
=>
GET
<
FetchWorkflowResponseType
>
(
'/core/app/fetchWorkflow'
,
data
);
projects/app/src/web/support/marketing/api.ts
0 → 100644
View file @
d6fed3d2
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
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment