Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
875a56dd
Commit
875a56dd
authored
Jul 03, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: test env detect
parent
e9bdcd2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
index.tsx
web/app/components/app/overview/embedded/index.tsx
+8
-5
No files found.
web/app/components/app/overview/embedded/index.tsx
View file @
875a56dd
...
@@ -6,8 +6,9 @@ import Modal from '@/app/components/base/modal'
...
@@ -6,8 +6,9 @@ import Modal from '@/app/components/base/modal'
import
useCopyToClipboard
from
'@/hooks/use-copy-to-clipboard'
import
useCopyToClipboard
from
'@/hooks/use-copy-to-clipboard'
import
copyStyle
from
'@/app/components/app/chat/copy-btn/style.module.css'
import
copyStyle
from
'@/app/components/app/chat/copy-btn/style.module.css'
import
Tooltip
from
'@/app/components/base/tooltip'
import
Tooltip
from
'@/app/components/base/tooltip'
import
{
useAppContext
}
from
'@/context/app-context'
const
isDevelopment
=
process
.
env
.
NODE_ENV
===
'development'
//
const isDevelopment = process.env.NODE_ENV === 'development'
type
Props
=
{
type
Props
=
{
isShow
:
boolean
isShow
:
boolean
...
@@ -26,9 +27,9 @@ const OPTION_MAP = {
...
@@ -26,9 +27,9 @@ const OPTION_MAP = {
</iframe>`
,
</iframe>`
,
},
},
scripts
:
{
scripts
:
{
getContent
:
(
url
:
string
,
token
:
string
)
=>
getContent
:
(
url
:
string
,
token
:
string
,
isTestEnv
?:
boolean
)
=>
`<script>
`<script>
window.difyChatbotConfig = { token: '
${
token
}
'
${
is
Development
?
', isDev: true'
:
''
}
}
window.difyChatbotConfig = { token: '
${
token
}
'
${
is
TestEnv
?
', isDev: true'
:
''
}
}
</script>
</script>
<script
<script
src="
${
url
}
/embed.min.js"
src="
${
url
}
/embed.min.js"
...
@@ -47,8 +48,10 @@ const Embedded = ({ isShow, onClose, appBaseUrl, accessToken }: Props) => {
...
@@ -47,8 +48,10 @@ const Embedded = ({ isShow, onClose, appBaseUrl, accessToken }: Props) => {
const
[
isCopied
,
setIsCopied
]
=
useState
({
iframe
:
false
,
scripts
:
false
})
const
[
isCopied
,
setIsCopied
]
=
useState
({
iframe
:
false
,
scripts
:
false
})
const
[
_
,
copy
]
=
useCopyToClipboard
()
const
[
_
,
copy
]
=
useCopyToClipboard
()
const
{
langeniusVersionInfo
}
=
useAppContext
()
const
isTestEnv
=
langeniusVersionInfo
.
current_env
===
'TESTING'
||
langeniusVersionInfo
.
current_env
===
'DEVELOPMENT'
const
onClickCopy
=
()
=>
{
const
onClickCopy
=
()
=>
{
copy
(
OPTION_MAP
[
option
].
getContent
(
appBaseUrl
,
accessToken
))
copy
(
OPTION_MAP
[
option
].
getContent
(
appBaseUrl
,
accessToken
,
isTestEnv
))
setIsCopied
({
...
isCopied
,
[
option
]:
true
})
setIsCopied
({
...
isCopied
,
[
option
]:
true
})
}
}
...
@@ -96,7 +99,7 @@ const Embedded = ({ isShow, onClose, appBaseUrl, accessToken }: Props) => {
...
@@ -96,7 +99,7 @@ const Embedded = ({ isShow, onClose, appBaseUrl, accessToken }: Props) => {
</
div
>
</
div
>
<
div
className=
"self-stretch p-3 justify-start items-start gap-2 inline-flex"
>
<
div
className=
"self-stretch p-3 justify-start items-start gap-2 inline-flex"
>
<
div
className=
"grow shrink basis-0 text-slate-700 text-[13px] leading-tight font-mono"
>
<
div
className=
"grow shrink basis-0 text-slate-700 text-[13px] leading-tight font-mono"
>
<
pre
>
{
OPTION_MAP
[
option
].
getContent
(
appBaseUrl
,
accessToken
)
}
</
pre
>
<
pre
>
{
OPTION_MAP
[
option
].
getContent
(
appBaseUrl
,
accessToken
,
isTestEnv
)
}
</
pre
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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