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
29bef1e3
Commit
29bef1e3
authored
Mar 07, 2024
by
JzoNg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app sidebar auto collapse
parent
e36d62f0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
27 deletions
+33
-27
layout.tsx
...p/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx
+12
-3
app-info.tsx
web/app/components/app-sidebar/app-info.tsx
+3
-3
index.tsx
web/app/components/app-sidebar/index.tsx
+11
-14
types.ts
web/app/components/app/configuration/debug/types.ts
+0
-1
index.tsx
web/app/components/app/configuration/index.tsx
+3
-6
store.ts
web/app/components/app/store.ts
+4
-0
No files found.
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx
View file @
29bef1e3
...
...
@@ -13,6 +13,7 @@ import { useAppContext } from '@/context/app-context'
import
Loading
from
'@/app/components/base/loading'
import
{
BarChartSquare02
,
FileHeart02
,
PromptEngineering
,
TerminalSquare
}
from
'@/app/components/base/icons/src/vender/line/development'
import
{
BarChartSquare02
as
BarChartSquare02Solid
,
FileHeart02
as
FileHeart02Solid
,
PromptEngineering
as
PromptEngineeringSolid
,
TerminalSquare
as
TerminalSquareSolid
}
from
'@/app/components/base/icons/src/vender/solid/development'
import
useBreakpoints
,
{
MediaType
}
from
'@/hooks/use-breakpoints'
export
type
IAppDetailLayoutProps
=
{
children
:
React
.
ReactNode
...
...
@@ -27,8 +28,10 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
const
{
t
}
=
useTranslation
()
const
router
=
useRouter
()
const
pathname
=
usePathname
()
const
media
=
useBreakpoints
()
const
isMobile
=
media
===
MediaType
.
mobile
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
{
appDetail
,
setAppDetail
}
=
useStore
()
const
{
appDetail
,
setAppDetail
,
setAppSiderbarExpand
}
=
useStore
()
const
[
navigation
,
setNavigation
]
=
useState
<
Array
<
{
name
:
string
href
:
string
...
...
@@ -72,9 +75,15 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
},
[
t
])
useEffect
(()
=>
{
if
(
appDetail
)
if
(
appDetail
)
{
document
.
title
=
`
${(
appDetail
.
name
||
'App'
)}
- Dify`
},
[
appDetail
])
const
localeMode
=
localStorage
.
getItem
(
'app-detail-collapse-or-expand'
)
||
'expand'
const
mode
=
isMobile
?
'collapse'
:
'expand'
setAppSiderbarExpand
(
isMobile
?
mode
:
localeMode
)
if
(
appDetail
.
mode
===
'advanced-chat'
||
appDetail
.
mode
===
'workflow'
)
setAppSiderbarExpand
(
'collapse'
)
}
},
[
appDetail
,
isMobile
,
setAppSiderbarExpand
])
useEffect
(()
=>
{
setAppDetail
()
...
...
web/app/components/app-sidebar/app-info.tsx
View file @
29bef1e3
...
...
@@ -156,7 +156,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
>
<
div
className=
{
cn
(
'flex cursor-pointer p-1 rounded-lg hover:bg-gray-100'
,
open
&&
'bg-gray-100'
)
}
>
<
div
className=
'shrink-0 mr-2'
>
<
AppIcon
size=
"large"
icon=
{
appDetail
.
icon
}
background=
{
appDetail
.
icon_background
}
/>
<
AppIcon
size=
{
expand
?
'large'
:
'medium'
}
icon=
{
appDetail
.
icon
}
background=
{
appDetail
.
icon_background
}
/>
</
div
>
{
expand
&&
(
<
div
className=
"grow w-0"
>
...
...
@@ -244,7 +244,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
}
}
>
<
span
className=
'text-gray-700 text-sm leading-5'
>
{
t
(
'app.editApp'
)
}
</
span
>
</
div
>
{
appDetail
.
mode
!==
'completion'
&&
appDetail
.
model_config
.
prompt_type
!==
'advanced'
&&
(
{
appDetail
.
mode
!==
'completion'
&&
appDetail
.
model_config
?
.
prompt_type
!==
'advanced'
&&
(
<>
<
div
className=
'h-9 py-2 px-3 mx-1 flex items-center hover:bg-gray-50 rounded-lg cursor-pointer'
onClick=
{
()
=>
{
setOpen
(
false
)
...
...
@@ -257,7 +257,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
</
div
>
</>
)
}
{
(
appDetail
.
mode
===
'completion'
||
appDetail
.
model_config
.
prompt_type
===
'advanced'
)
&&
(
{
(
appDetail
.
mode
===
'completion'
||
appDetail
.
model_config
?
.
prompt_type
===
'advanced'
)
&&
(
<>
<
Divider
className=
"!my-1"
/>
<
div
...
...
web/app/components/app-sidebar/index.tsx
View file @
29bef1e3
import
React
,
{
useCallback
,
useState
}
from
'react'
import
React
,
{
useCallback
,
use
Effect
,
use
State
}
from
'react'
import
NavLink
from
'./navLink'
import
type
{
NavIcon
}
from
'./navLink'
import
AppBasic
from
'./basic'
...
...
@@ -8,8 +8,7 @@ import {
AlignLeft01
,
AlignRight01
,
}
from
'@/app/components/base/icons/src/vender/line/layout'
import
{
useEventEmitterContextContext
}
from
'@/context/event-emitter'
import
{
APP_SIDEBAR_SHOULD_COLLAPSE
}
from
'@/app/components/app/configuration/debug/types'
import
{
useStore
as
useAppStore
}
from
'@/app/components/app/store'
export
type
IAppDetailNavProps
=
{
iconType
?:
'app'
|
'dataset'
|
'notion'
...
...
@@ -27,28 +26,26 @@ export type IAppDetailNavProps = {
}
const
AppDetailNav
=
({
title
,
desc
,
icon
,
icon_background
,
navigation
,
extraInfo
,
iconType
=
'app'
}:
IAppDetailNavProps
)
=>
{
const
localeMode
=
localStorage
.
getItem
(
'app-detail-collapse-or-expand'
)
||
'expand'
const
{
appSidebarExpand
,
setAppSiderbarExpand
}
=
useAppStore
()
const
media
=
useBreakpoints
()
const
isMobile
=
media
===
MediaType
.
mobile
const
mode
=
isMobile
?
'collapse'
:
'expand'
const
[
modeState
,
setModeState
]
=
useState
(
isMobile
?
mode
:
localeMode
)
const
[
modeState
,
setModeState
]
=
useState
(
appSidebarExpand
)
const
expand
=
modeState
===
'expand'
const
handleToggle
=
useCallback
(()
=>
{
setModeState
((
prev
)
=>
{
const
next
=
prev
===
'expand'
?
'collapse'
:
'expand'
localStorage
.
setItem
(
'app-detail-collapse-or-expand'
,
next
)
setAppSiderbarExpand
(
next
)
return
next
})
},
[])
},
[
setAppSiderbarExpand
])
const
{
eventEmitter
}
=
useEventEmitterContextContext
()
eventEmitter
?.
useSubscription
((
v
:
any
)
=>
{
if
(
v
.
type
===
APP_SIDEBAR_SHOULD_COLLAPSE
)
{
setModeState
(
'collapse'
)
localStorage
.
setItem
(
'app-detail-collapse-or-expand'
,
'collapse'
)
useEffect
(()
=>
{
if
(
appSidebarExpand
)
{
localStorage
.
setItem
(
'app-detail-collapse-or-expand'
,
appSidebarExpand
)
setModeState
(
appSidebarExpand
)
}
})
}
,
[
appSidebarExpand
]
)
return
(
<
div
...
...
web/app/components/app/configuration/debug/types.ts
View file @
29bef1e3
...
...
@@ -15,5 +15,4 @@ export type DebugWithSingleOrMultipleModelConfigs = {
}
export
const
APP_CHAT_WITH_MULTIPLE_MODEL
=
'APP_CHAT_WITH_MULTIPLE_MODEL'
export
const
APP_CHAT_WITH_MULTIPLE_MODEL_RESTART
=
'APP_CHAT_WITH_MULTIPLE_MODEL_RESTART'
export
const
APP_SIDEBAR_SHOULD_COLLAPSE
=
'APP_SIDEBAR_SHOULD_COLLAPSE'
export
const
ORCHESTRATE_CHANGED
=
'ORCHESTRATE_CHANGED'
web/app/components/app/configuration/index.tsx
View file @
29bef1e3
...
...
@@ -19,7 +19,6 @@ import {
useFormattingChangedDispatcher
,
}
from
'./debug/hooks'
import
type
{
ModelAndParameter
}
from
'./debug/types'
import
{
APP_SIDEBAR_SHOULD_COLLAPSE
}
from
'./debug/types'
import
PublishWithMultipleModel
from
'./debug/debug-with-multiple-model/publish-with-multiple-model'
import
type
{
AnnotationReplyConfig
,
...
...
@@ -57,7 +56,7 @@ import type { FormValue } from '@/app/components/header/account-setting/model-pr
import
{
useTextGenerationCurrentProviderAndModelAndModelList
}
from
'@/app/components/header/account-setting/model-provider-page/hooks'
import
{
fetchCollectionList
}
from
'@/service/tools'
import
{
type
Collection
}
from
'@/app/components/tools/types'
import
{
use
EventEmitterContextContext
}
from
'@/context/event-emitter
'
import
{
use
Store
as
useAppStore
}
from
'@/app/components/app/store
'
type
PublichConfig
=
{
modelConfig
:
ModelConfig
...
...
@@ -67,6 +66,7 @@ type PublichConfig = {
const
Configuration
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
setAppSiderbarExpand
}
=
useAppStore
()
const
[
formattingChanged
,
setFormattingChanged
]
=
useState
(
false
)
const
{
setShowAccountSettingModal
}
=
useModalContext
()
const
[
hasFetchedDetail
,
setHasFetchedDetail
]
=
useState
(
false
)
...
...
@@ -645,7 +645,6 @@ const Configuration: FC = () => {
const
[
showUseGPT4Confirm
,
setShowUseGPT4Confirm
]
=
useState
(
false
)
const
{
eventEmitter
}
=
useEventEmitterContextContext
()
const
{
debugWithMultipleModel
,
multipleModelConfigs
,
...
...
@@ -660,9 +659,7 @@ const Configuration: FC = () => {
{
id
:
`
${
Date
.
now
()}
-no-repeat`
,
model
:
''
,
provider
:
''
,
parameters
:
{}
},
],
)
eventEmitter
?.
emit
({
type
:
APP_SIDEBAR_SHOULD_COLLAPSE
,
}
as
any
)
setAppSiderbarExpand
(
'collapse'
)
}
if
(
isLoading
)
{
...
...
web/app/components/app/store.ts
View file @
29bef1e3
...
...
@@ -3,13 +3,17 @@ import type { App } from '@/types/app'
type
State
=
{
appDetail
?:
App
appSidebarExpand
:
string
}
type
Action
=
{
setAppDetail
:
(
appDetail
?:
App
)
=>
void
setAppSiderbarExpand
:
(
state
:
string
)
=>
void
}
export
const
useStore
=
create
<
State
&
Action
>
(
set
=>
({
appDetail
:
undefined
,
setAppDetail
:
appDetail
=>
set
(()
=>
({
appDetail
})),
appSidebarExpand
:
''
,
setAppSiderbarExpand
:
appSidebarExpand
=>
set
(()
=>
({
appSidebarExpand
})),
}))
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