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
7e647cc6
Commit
7e647cc6
authored
Mar 06, 2024
by
JzoNg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix page title update
parent
ec710d7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
layout.tsx
...p/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx
+20
-14
No files found.
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx
View file @
7e647cc6
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
,
{
use
Effect
,
useMemo
}
from
'react'
import
React
,
{
use
Callback
,
useEffect
,
useState
}
from
'react'
import
{
usePathname
,
useRouter
}
from
'next/navigation'
import
{
usePathname
,
useRouter
}
from
'next/navigation'
import
cn
from
'classnames'
import
cn
from
'classnames'
import
useSWR
from
'swr'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
s
from
'./style.module.css'
import
s
from
'./style.module.css'
import
{
useStore
}
from
'@/app/components/app/store'
import
{
useStore
}
from
'@/app/components/app/store'
import
AppSideBar
from
'@/app/components/app-sidebar'
import
AppSideBar
from
'@/app/components/app-sidebar'
import
type
{
NavIcon
}
from
'@/app/components/app-sidebar/navLink'
import
{
fetchAppDetail
}
from
'@/service/apps'
import
{
fetchAppDetail
}
from
'@/service/apps'
import
{
useAppContext
}
from
'@/context/app-context'
import
{
useAppContext
}
from
'@/context/app-context'
import
{
BarChartSquare02
,
FileHeart02
,
PromptEngineering
,
TerminalSquare
}
from
'@/app/components/base/icons/src/vender/line/development'
import
{
BarChartSquare02
,
FileHeart02
,
PromptEngineering
,
TerminalSquare
}
from
'@/app/components/base/icons/src/vender/line/development'
...
@@ -28,15 +28,19 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
...
@@ -28,15 +28,19 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
const
pathname
=
usePathname
()
const
pathname
=
usePathname
()
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
{
appDetail
,
setAppDetail
}
=
useStore
()
const
{
appDetail
,
setAppDetail
}
=
useStore
()
const
detailParams
=
{
url
:
'/apps'
,
id
:
appId
}
const
[
navigation
,
setNavigation
]
=
useState
<
Array
<
{
const
{
data
:
response
}
=
useSWR
(
detailParams
,
fetchAppDetail
)
name
:
string
href
:
string
icon
:
NavIcon
selectedIcon
:
NavIcon
}
>>
([])
const
navigation
=
useMemo
((
)
=>
{
const
getNavigations
=
useCallback
((
appId
:
string
,
isCurrentWorkspaceManager
:
boolean
,
mode
:
string
)
=>
{
const
navs
=
[
const
navs
=
[
...(
isCurrentWorkspaceManager
...(
isCurrentWorkspaceManager
?
[{
?
[{
name
:
t
(
'common.appMenus.promptEng'
),
name
:
t
(
'common.appMenus.promptEng'
),
href
:
`/app/
${
appId
}
/
${(
response
?.
mode
===
'workflow'
||
response
?.
mode
===
'advanced-chat'
)
?
'workflow'
:
'configuration'
}
`,
href
:
`/app/
${
appId
}
/
${(
mode
===
'workflow'
||
mode
===
'advanced-chat'
)
?
'workflow'
:
'configuration'
}
`
,
icon
:
PromptEngineering
,
icon
:
PromptEngineering
,
selectedIcon
:
PromptEngineeringSolid
,
selectedIcon
:
PromptEngineeringSolid
,
}]
}]
...
@@ -49,7 +53,7 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
...
@@ -49,7 +53,7 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
selectedIcon
:
TerminalSquareSolid
,
selectedIcon
:
TerminalSquareSolid
,
},
},
{
{
name:
response?.
mode !== 'workflow'
name
:
mode
!==
'workflow'
?
t
(
'common.appMenus.logAndAnn'
)
?
t
(
'common.appMenus.logAndAnn'
)
:
t
(
'common.appMenus.logs'
),
:
t
(
'common.appMenus.logs'
),
href
:
`/app/
${
appId
}
/logs`
,
href
:
`/app/
${
appId
}
/logs`
,
...
@@ -64,18 +68,20 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
...
@@ -64,18 +68,20 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
},
},
]
]
return
navs
return
navs
},
[
appId
,
isCurrentWorkspaceManager
,
response
?.
mode
,
t
])
},
[
t
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
response
&&
!
appDetail
)
if
(
appDetail
)
setAppDetail
(
response
)
},
[
appDetail
,
response
,
setAppDetail
])
useEffect
(()
=>
{
if
(
appDetail
?.
name
)
document
.
title
=
`
${(
appDetail
.
name
||
'App'
)}
- Dify`
document
.
title
=
`
${(
appDetail
.
name
||
'App'
)}
- Dify`
},
[
appDetail
])
},
[
appDetail
])
useEffect
(()
=>
{
fetchAppDetail
({
url
:
'/apps'
,
id
:
appId
}).
then
((
res
)
=>
{
setAppDetail
(
res
)
setNavigation
(
getNavigations
(
appId
,
isCurrentWorkspaceManager
,
res
.
mode
))
})
},
[
appId
,
getNavigations
,
isCurrentWorkspaceManager
,
setAppDetail
])
if
(
!
appDetail
)
if
(
!
appDetail
)
return
null
return
null
...
...
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