balibabu
commited on
Commit
·
3726b19
1
Parent(s):
985fa34
feat: modify the background color of chat messages (#1262)
Browse files### What problem does this PR solve?
feat: modify the background color of chat messages #1215
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/pages/chat/chat-container/index.less
CHANGED
|
@@ -24,20 +24,24 @@
|
|
| 24 |
.messageItemContentReverse {
|
| 25 |
flex-direction: row-reverse;
|
| 26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
.messageText {
|
| 28 |
.chunkText();
|
| 29 |
-
|
| 30 |
-
background-color:
|
| 31 |
word-break: break-all;
|
| 32 |
-
border-radius: 10px;
|
| 33 |
}
|
| 34 |
.messageUserText {
|
| 35 |
.chunkText();
|
| 36 |
-
|
| 37 |
-
background-color: rgb(
|
| 38 |
word-break: break-all;
|
| 39 |
-
border-radius: 10px;
|
| 40 |
-
color: #fdfdfd;
|
| 41 |
text-align: justify;
|
| 42 |
}
|
| 43 |
.messageEmpty {
|
|
|
|
| 24 |
.messageItemContentReverse {
|
| 25 |
flex-direction: row-reverse;
|
| 26 |
}
|
| 27 |
+
.messageTextBase() {
|
| 28 |
+
padding: 6px 10px;
|
| 29 |
+
border-radius: 8px;
|
| 30 |
+
& > p {
|
| 31 |
+
margin: 0;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
.messageText {
|
| 35 |
.chunkText();
|
| 36 |
+
.messageTextBase();
|
| 37 |
+
background-color: #e6f4ff;
|
| 38 |
word-break: break-all;
|
|
|
|
| 39 |
}
|
| 40 |
.messageUserText {
|
| 41 |
.chunkText();
|
| 42 |
+
.messageTextBase();
|
| 43 |
+
background-color: rgb(248, 247, 247);
|
| 44 |
word-break: break-all;
|
|
|
|
|
|
|
| 45 |
text-align: justify;
|
| 46 |
}
|
| 47 |
.messageEmpty {
|
web/src/pages/chat/hooks.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { getFileExtension } from '@/utils';
|
|
| 36 |
import { message } from 'antd';
|
| 37 |
import dayjs, { Dayjs } from 'dayjs';
|
| 38 |
import omit from 'lodash/omit';
|
|
|
|
| 39 |
import {
|
| 40 |
ChangeEventHandler,
|
| 41 |
useCallback,
|
|
@@ -54,7 +55,6 @@ import {
|
|
| 54 |
} from './interface';
|
| 55 |
import { ChatModelState } from './model';
|
| 56 |
import { isConversationIdExist } from './utils';
|
| 57 |
-
import {public_path} from "@/utils/api";
|
| 58 |
|
| 59 |
export const useSelectCurrentDialog = () => {
|
| 60 |
const currentDialog: IDialog = useSelector(
|
|
@@ -533,7 +533,7 @@ export const useHandleMessageInputChange = () => {
|
|
| 533 |
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
| 534 |
const value = e.target.value;
|
| 535 |
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
|
| 536 |
-
setValue(nextValue);
|
| 537 |
};
|
| 538 |
|
| 539 |
return {
|
|
@@ -620,6 +620,8 @@ export const useSendMessage = (
|
|
| 620 |
}, [answer, addNewestAnswer]);
|
| 621 |
|
| 622 |
const handlePressEnter = useCallback(() => {
|
|
|
|
|
|
|
| 623 |
if (done) {
|
| 624 |
setValue('');
|
| 625 |
handleSendMessage(value.trim());
|
|
@@ -766,7 +768,7 @@ export const useGetSendButtonDisabled = () => {
|
|
| 766 |
};
|
| 767 |
|
| 768 |
export const useSendButtonDisabled = (value: string) => {
|
| 769 |
-
return value === '';
|
| 770 |
};
|
| 771 |
//#endregion
|
| 772 |
|
|
|
|
| 36 |
import { message } from 'antd';
|
| 37 |
import dayjs, { Dayjs } from 'dayjs';
|
| 38 |
import omit from 'lodash/omit';
|
| 39 |
+
import trim from 'lodash/trim';
|
| 40 |
import {
|
| 41 |
ChangeEventHandler,
|
| 42 |
useCallback,
|
|
|
|
| 55 |
} from './interface';
|
| 56 |
import { ChatModelState } from './model';
|
| 57 |
import { isConversationIdExist } from './utils';
|
|
|
|
| 58 |
|
| 59 |
export const useSelectCurrentDialog = () => {
|
| 60 |
const currentDialog: IDialog = useSelector(
|
|
|
|
| 533 |
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
| 534 |
const value = e.target.value;
|
| 535 |
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
|
| 536 |
+
setValue(trim(nextValue));
|
| 537 |
};
|
| 538 |
|
| 539 |
return {
|
|
|
|
| 620 |
}, [answer, addNewestAnswer]);
|
| 621 |
|
| 622 |
const handlePressEnter = useCallback(() => {
|
| 623 |
+
if (trim(value) === '') return;
|
| 624 |
+
|
| 625 |
if (done) {
|
| 626 |
setValue('');
|
| 627 |
handleSendMessage(value.trim());
|
|
|
|
| 768 |
};
|
| 769 |
|
| 770 |
export const useSendButtonDisabled = (value: string) => {
|
| 771 |
+
return trim(value) === '';
|
| 772 |
};
|
| 773 |
//#endregion
|
| 774 |
|
web/src/pages/chat/share/index.less
CHANGED
|
@@ -30,20 +30,24 @@
|
|
| 30 |
.messageItemContentReverse {
|
| 31 |
flex-direction: row-reverse;
|
| 32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
.messageText {
|
| 34 |
.chunkText();
|
| 35 |
-
|
| 36 |
-
background-color:
|
| 37 |
word-break: break-all;
|
| 38 |
-
border-radius: 10px;
|
| 39 |
}
|
| 40 |
.messageUserText {
|
| 41 |
.chunkText();
|
| 42 |
-
|
| 43 |
-
background-color: rgb(
|
| 44 |
word-break: break-all;
|
| 45 |
-
border-radius: 10px;
|
| 46 |
-
color: #fdfdfd;
|
| 47 |
text-align: justify;
|
| 48 |
}
|
| 49 |
.messageEmpty {
|
|
|
|
| 30 |
.messageItemContentReverse {
|
| 31 |
flex-direction: row-reverse;
|
| 32 |
}
|
| 33 |
+
.messageTextBase() {
|
| 34 |
+
padding: 6px 10px;
|
| 35 |
+
border-radius: 8px;
|
| 36 |
+
& > p {
|
| 37 |
+
margin: 0;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
.messageText {
|
| 41 |
.chunkText();
|
| 42 |
+
.messageTextBase();
|
| 43 |
+
background-color: #e6f4ff;
|
| 44 |
word-break: break-all;
|
|
|
|
| 45 |
}
|
| 46 |
.messageUserText {
|
| 47 |
.chunkText();
|
| 48 |
+
.messageTextBase();
|
| 49 |
+
background-color: rgb(248, 247, 247);
|
| 50 |
word-break: break-all;
|
|
|
|
|
|
|
| 51 |
text-align: justify;
|
| 52 |
}
|
| 53 |
.messageEmpty {
|
web/src/pages/chat/shared-hooks.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
|
| 8 |
import { IAnswer } from '@/interfaces/database/chat';
|
| 9 |
import api from '@/utils/api';
|
| 10 |
import omit from 'lodash/omit';
|
|
|
|
| 11 |
import {
|
| 12 |
Dispatch,
|
| 13 |
SetStateAction,
|
|
@@ -134,7 +135,7 @@ export const useSelectCurrentSharedConversation = (conversationId: string) => {
|
|
| 134 |
};
|
| 135 |
|
| 136 |
export const useSendButtonDisabled = (value: string) => {
|
| 137 |
-
return value === '';
|
| 138 |
};
|
| 139 |
|
| 140 |
export const useSendSharedMessage = (
|
|
@@ -205,6 +206,7 @@ export const useSendSharedMessage = (
|
|
| 205 |
}, [answer, addNewestAnswer]);
|
| 206 |
|
| 207 |
const handlePressEnter = useCallback(() => {
|
|
|
|
| 208 |
if (done) {
|
| 209 |
setValue('');
|
| 210 |
addNewestConversation(value);
|
|
|
|
| 8 |
import { IAnswer } from '@/interfaces/database/chat';
|
| 9 |
import api from '@/utils/api';
|
| 10 |
import omit from 'lodash/omit';
|
| 11 |
+
import trim from 'lodash/trim';
|
| 12 |
import {
|
| 13 |
Dispatch,
|
| 14 |
SetStateAction,
|
|
|
|
| 135 |
};
|
| 136 |
|
| 137 |
export const useSendButtonDisabled = (value: string) => {
|
| 138 |
+
return trim(value) === '';
|
| 139 |
};
|
| 140 |
|
| 141 |
export const useSendSharedMessage = (
|
|
|
|
| 206 |
}, [answer, addNewestAnswer]);
|
| 207 |
|
| 208 |
const handlePressEnter = useCallback(() => {
|
| 209 |
+
if (trim(value) === '') return;
|
| 210 |
if (done) {
|
| 211 |
setValue('');
|
| 212 |
addNewestConversation(value);
|