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
c5ccf382
Unverified
Commit
c5ccf382
authored
May 30, 2023
by
Joel
Committed by
GitHub
May 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: input area highlight and moblie hide tooltip (#251)
parent
8358d0ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
38 deletions
+52
-38
index.tsx
web/app/components/app/chat/index.tsx
+48
-38
style.module.css
web/app/components/app/chat/style.module.css
+4
-0
No files found.
web/app/components/app/chat/index.tsx
View file @
c5ccf382
...
@@ -8,6 +8,8 @@ import { UserCircleIcon } from '@heroicons/react/24/solid'
...
@@ -8,6 +8,8 @@ import { UserCircleIcon } from '@heroicons/react/24/solid'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
randomString
}
from
'../../app-sidebar/basic'
import
{
randomString
}
from
'../../app-sidebar/basic'
import
s
from
'./style.module.css'
import
s
from
'./style.module.css'
import
LoadingAnim
from
'./loading-anim'
import
CopyBtn
from
'./copy-btn'
import
Tooltip
from
'@/app/components/base/tooltip'
import
Tooltip
from
'@/app/components/base/tooltip'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
AutoHeightTextarea
from
'@/app/components/base/auto-height-textarea'
import
AutoHeightTextarea
from
'@/app/components/base/auto-height-textarea'
...
@@ -15,9 +17,8 @@ import Button from '@/app/components/base/button'
...
@@ -15,9 +17,8 @@ import Button from '@/app/components/base/button'
import
type
{
Annotation
,
MessageRating
}
from
'@/models/log'
import
type
{
Annotation
,
MessageRating
}
from
'@/models/log'
import
AppContext
from
'@/context/app-context'
import
AppContext
from
'@/context/app-context'
import
{
Markdown
}
from
'@/app/components/base/markdown'
import
{
Markdown
}
from
'@/app/components/base/markdown'
import
LoadingAnim
from
'./loading-anim'
import
{
formatNumber
}
from
'@/utils/format'
import
{
formatNumber
}
from
'@/utils/format'
import
CopyBtn
from
'./copy-btn
'
import
useBreakpoints
,
{
MediaType
}
from
'@/hooks/use-breakpoints
'
const
stopIcon
=
(
const
stopIcon
=
(
<
svg
width=
"14"
height=
"14"
viewBox=
"0 0 14 14"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<
svg
width=
"14"
height=
"14"
viewBox=
"0 0 14 14"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
...
@@ -285,8 +286,8 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
...
@@ -285,8 +286,8 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
<
div
key=
{
id
}
>
<
div
key=
{
id
}
>
<
div
className=
'flex items-start'
>
<
div
className=
'flex items-start'
>
<
div
className=
{
`${s.answerIcon} w-10 h-10 shrink-0`
}
>
<
div
className=
{
`${s.answerIcon} w-10 h-10 shrink-0`
}
>
{
isResponsing
&&
{
isResponsing
<
div
className=
{
s
.
typeingIcon
}
>
&&
<
div
className=
{
s
.
typeingIcon
}
>
<
LoadingAnim
type=
'avatar'
/>
<
LoadingAnim
type=
'avatar'
/>
</
div
>
</
div
>
}
}
...
@@ -301,13 +302,15 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
...
@@ -301,13 +302,15 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
<
div
className=
'text-xs text-gray-500'
>
{
t
(
'appDebug.openingStatement.title'
)
}
</
div
>
<
div
className=
'text-xs text-gray-500'
>
{
t
(
'appDebug.openingStatement.title'
)
}
</
div
>
</
div
>
</
div
>
)
}
)
}
{
(
isResponsing
&&
!
content
)
?
(
{
(
isResponsing
&&
!
content
)
<
div
className=
'flex items-center justify-center w-6 h-5'
>
?
(
<
LoadingAnim
type=
'text'
/>
<
div
className=
'flex items-center justify-center w-6 h-5'
>
</
div
>
<
LoadingAnim
type=
'text'
/>
)
:
(
</
div
>
<
Markdown
content=
{
content
}
/>
)
)
}
:
(
<
Markdown
content=
{
content
}
/>
)
}
{
!
showEdit
{
!
showEdit
?
(
annotation
?.
content
?
(
annotation
?.
content
&&
<>
&&
<>
...
@@ -384,13 +387,15 @@ const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar
...
@@ -384,13 +387,15 @@ const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar
</
div
>
</
div
>
{
more
&&
<
MoreInfo
more=
{
more
}
isQuestion=
{
true
}
/>
}
{
more
&&
<
MoreInfo
more=
{
more
}
isQuestion=
{
true
}
/>
}
</
div
>
</
div
>
{
useCurrentUserAvatar
?
(
{
useCurrentUserAvatar
<
div
className=
'w-10 h-10 shrink-0 leading-10 text-center mr-2 rounded-full bg-primary-600 text-white'
>
?
(
{
userName
?.[
0
].
toLocaleUpperCase
()
}
<
div
className=
'w-10 h-10 shrink-0 leading-10 text-center mr-2 rounded-full bg-primary-600 text-white'
>
</
div
>
{
userName
?.[
0
].
toLocaleUpperCase
()
}
)
:
(
</
div
>
<
div
className=
{
`${s.questionIcon} w-10 h-10 shrink-0 `
}
></
div
>
)
)
}
:
(
<
div
className=
{
`${s.questionIcon} w-10 h-10 shrink-0 `
}
></
div
>
)
}
</
div
>
</
div
>
)
)
}
}
...
@@ -411,7 +416,7 @@ const Chat: FC<IChatProps> = ({
...
@@ -411,7 +416,7 @@ const Chat: FC<IChatProps> = ({
controlClearQuery
,
controlClearQuery
,
controlFocus
,
controlFocus
,
isShowSuggestion
,
isShowSuggestion
,
suggestionList
suggestionList
,
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
...
@@ -436,27 +441,24 @@ const Chat: FC<IChatProps> = ({
...
@@ -436,27 +441,24 @@ const Chat: FC<IChatProps> = ({
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
controlClearQuery
)
{
if
(
controlClearQuery
)
setQuery
(
''
)
setQuery
(
''
)
}
},
[
controlClearQuery
])
},
[
controlClearQuery
])
const
handleSend
=
()
=>
{
const
handleSend
=
()
=>
{
if
(
!
valid
()
||
(
checkCanSend
&&
!
checkCanSend
()))
if
(
!
valid
()
||
(
checkCanSend
&&
!
checkCanSend
()))
return
return
onSend
(
query
)
onSend
(
query
)
if
(
!
isResponsing
)
{
if
(
!
isResponsing
)
setQuery
(
''
)
setQuery
(
''
)
}
}
}
const
handleKeyUp
=
(
e
:
any
)
=>
{
const
handleKeyUp
=
(
e
:
any
)
=>
{
if
(
e
.
code
===
'Enter'
)
{
if
(
e
.
code
===
'Enter'
)
{
e
.
preventDefault
()
e
.
preventDefault
()
// prevent send message when using input method enter
// prevent send message when using input method enter
if
(
!
e
.
shiftKey
&&
!
isUseInputMethod
.
current
)
{
if
(
!
e
.
shiftKey
&&
!
isUseInputMethod
.
current
)
handleSend
()
handleSend
()
}
}
}
}
}
...
@@ -468,6 +470,10 @@ const Chat: FC<IChatProps> = ({
...
@@ -468,6 +470,10 @@ const Chat: FC<IChatProps> = ({
}
}
}
}
const
media
=
useBreakpoints
()
const
isMobile
=
media
===
MediaType
.
mobile
const
sendBtn
=
<
div
className=
{
cn
(
!
(
!
query
||
query
.
trim
()
===
''
)
&&
s
.
sendBtnActive
,
`${s.sendBtn} w-8 h-8 cursor-pointer rounded-md`
)
}
onClick=
{
handleSend
}
></
div
>
return
(
return
(
<
div
className=
{
cn
(
!
feedbackDisabled
&&
'px-3.5'
,
'h-full'
)
}
>
<
div
className=
{
cn
(
!
feedbackDisabled
&&
'px-3.5'
,
'h-full'
)
}
>
{
/* Chat List */
}
{
/* Chat List */
}
...
@@ -506,7 +512,7 @@ const Chat: FC<IChatProps> = ({
...
@@ -506,7 +512,7 @@ const Chat: FC<IChatProps> = ({
<
div
className=
'flex items-center justify-center mb-2.5'
>
<
div
className=
'flex items-center justify-center mb-2.5'
>
<
div
className=
'grow h-[1px]'
<
div
className=
'grow h-[1px]'
style=
{
{
style=
{
{
background
:
'linear-gradient(270deg, #F3F4F6 0%, rgba(243, 244, 246, 0) 100%)'
background
:
'linear-gradient(270deg, #F3F4F6 0%, rgba(243, 244, 246, 0) 100%)'
,
}
}
></
div
>
}
}
></
div
>
<
div
className=
'shrink-0 flex items-center px-3 space-x-1'
>
<
div
className=
'shrink-0 flex items-center px-3 space-x-1'
>
{
TryToAskIcon
}
{
TryToAskIcon
}
...
@@ -514,7 +520,7 @@ const Chat: FC<IChatProps> = ({
...
@@ -514,7 +520,7 @@ const Chat: FC<IChatProps> = ({
</
div
>
</
div
>
<
div
className=
'grow h-[1px]'
<
div
className=
'grow h-[1px]'
style=
{
{
style=
{
{
background
:
'linear-gradient(270deg, rgba(243, 244, 246, 0) 0%, #F3F4F6 100%)'
background
:
'linear-gradient(270deg, rgba(243, 244, 246, 0) 0%, #F3F4F6 100%)'
,
}
}
></
div
>
}
}
></
div
>
</
div
>
</
div
>
<
div
className=
'flex justify-center overflow-x-scroll pb-2'
>
<
div
className=
'flex justify-center overflow-x-scroll pb-2'
>
...
@@ -544,17 +550,21 @@ const Chat: FC<IChatProps> = ({
...
@@ -544,17 +550,21 @@ const Chat: FC<IChatProps> = ({
/>
/>
<
div
className=
"absolute top-0 right-2 flex items-center h-[48px]"
>
<
div
className=
"absolute top-0 right-2 flex items-center h-[48px]"
>
<
div
className=
{
`${s.count} mr-4 h-5 leading-5 text-sm bg-gray-50 text-gray-500`
}
>
{
query
.
trim
().
length
}
</
div
>
<
div
className=
{
`${s.count} mr-4 h-5 leading-5 text-sm bg-gray-50 text-gray-500`
}
>
{
query
.
trim
().
length
}
</
div
>
<
Tooltip
{
isMobile
selector=
'send-tip'
?
sendBtn
htmlContent=
{
:
(
<
div
>
<
Tooltip
<
div
>
{
t
(
'common.operation.send'
)
}
Enter
</
div
>
selector=
'send-tip'
<
div
>
{
t
(
'common.operation.lineBreak'
)
}
Shift Enter
</
div
>
htmlContent=
{
</
div
>
<
div
>
}
<
div
>
{
t
(
'common.operation.send'
)
}
Enter
</
div
>
>
<
div
>
{
t
(
'common.operation.lineBreak'
)
}
Shift Enter
</
div
>
<
div
className=
{
`${s.sendBtn} w-8 h-8 cursor-pointer rounded-md`
}
onClick=
{
handleSend
}
></
div
>
</
div
>
</
Tooltip
>
}
>
{
sendBtn
}
</
Tooltip
>
)
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
web/app/components/app/chat/style.module.css
View file @
c5ccf382
...
@@ -102,6 +102,10 @@
...
@@ -102,6 +102,10 @@
background
:
url(./icons/send.svg)
center
center
no-repeat
;
background
:
url(./icons/send.svg)
center
center
no-repeat
;
}
}
.sendBtnActive
{
background-image
:
url(./icons/send-active.svg)
;
}
.sendBtn
:hover
{
.sendBtn
:hover
{
background-image
:
url(./icons/send-active.svg)
;
background-image
:
url(./icons/send-active.svg)
;
background-color
:
#EBF5FF
;
background-color
:
#EBF5FF
;
...
...
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