From 4a44d15a71e053eb677deda3d384177967d30c4d Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期五, 09 八月 2024 16:03:33 +0800
Subject: [PATCH] fix: 修改会话换色
---
src/views/authority/users/index.vue | 4
src/views/sessionManager/index.vue | 158 +++++++++++++++++++++++++++++-----------------------
2 files changed, 89 insertions(+), 73 deletions(-)
diff --git a/src/views/authority/users/index.vue b/src/views/authority/users/index.vue
index 634b0e1..caa282b 100644
--- a/src/views/authority/users/index.vue
+++ b/src/views/authority/users/index.vue
@@ -844,12 +844,12 @@
transform: translateY(-4px);
}
.table-page-search-wrapper {
- padding-top: 20px;
+ padding-top: 10px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
- padding-bottom: 20px;
+ padding-bottom: 10px;
border-bottom: 1px solid #e8e8e8;
.search-wrapper {
display: flex;
diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue
index 0578411..d66c825 100644
--- a/src/views/sessionManager/index.vue
+++ b/src/views/sessionManager/index.vue
@@ -49,7 +49,7 @@
@click="querySessionDetail(session)"
:class="{ isLeftActive: activeSessionId === session.id }"
>
- <div class="text" :class="{ light: theme === 'dark' }"
+ <div class="text" :class="{ time: theme === 'dark' }"
>{{ session.name }}
</div>
<div class="time"
@@ -163,7 +163,7 @@
/>
</template>
<template #content>
- <div class="chart-user-text"
+ <div :class="{ chartUserText: theme === 'light' }"
>{{ sessionDetail.content }}
</div>
</template>
@@ -177,7 +177,7 @@
/>
</template>
<template #content>
- <a-card class="chat-item-answer">
+ <a-card :class="{ chatItemAnswer: theme === 'light' }">
<div :class="{ light: theme === 'light' }"
>{{ sessionDetail.content }}
</div>
@@ -197,7 +197,7 @@
readonly
auto-size
v-model="displayedText"
- class="chat-item-answer"
+ :class="{ chatItemAnswer: theme === 'light' }"
>
</a-textarea>
</template>
@@ -222,6 +222,7 @@
</a-textarea> -->
<a-textarea
v-model="inputMsg"
+ @keydown.shift.enter="handleShiftEnter"
@keydown.enter="sendMessage"
placeholder="杈撳叆鎮ㄦ兂浜嗚В鐨勫唴瀹癸紝Shift+Enter鎹㈣锛孍nter鍙戦��"
allow-clear
@@ -359,83 +360,98 @@
}
}
};
+ const handleShiftEnter = (event) => {
+ event.preventDefault();
+ inputMsg.value += '\n';
+ };
const dialogChange = (val) => {
dialogId.value = val;
querySessionList();
};
- const sentClick = (event) => {
- sendMessage(event);
+ const sentClick = () => {
+ sendMessage('click');
};
const sendMessage = async (event) => {
- event.preventDefault();
- chatDis.value = true;
- loading.value = true;
- if (!activeSessionId.value) {
- Message.warning('璇烽�夋嫨浼氳瘽');
- chatDis.value = false;
- loading.value = false;
- return;
- }
-
- // if (displayedText.value) {
- // querySessionList();
- // }
-
- if (inputMsg.value) {
- sessionDetailList.value.push({ content: inputMsg.value, role: 'user' });
- sessionDetailList.value.push({ role: 'last' });
- refreshScroll();
- const response = await fetch(
- '/api/tech/cloudminds/query?modeltype=localragflow',
- {
- method: 'POST',
- headers: {
- 'Authorization': getAuthorization(),
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- conversation_id: activeSessionId.value,
- messages: inputMsg.value,
- }),
+ if (event.keyCode == 13 || event === 'click') {
+ if (!event.shiftKey) {
+ //鍙湁enter娌℃湁shift锛屾垨杩涜浣犵殑鍏朵粬閫昏緫
+ if (event !== 'click') {
+ event.preventDefault(); // 闃绘榛樿琛屼负锛屽嵆涓嶆崲琛�
}
- );
- const reader = response?.body
- ?.pipeThrough(new TextDecoderStream())
- .pipeThrough(new EventSourceParserStream())
- .getReader();
- currIndex.value = 0;
- while (true) {
- const x = await reader?.read();
- if (x) {
- const { done, value } = x;
- console.log(x, 999);
- try {
- const val = JSON.parse(value?.data || '');
- const d = val?.data;
- if (typeof d !== 'boolean') {
- console.info('data:', d);
- streamStr.value = d.content;
- startDisplayStr();
+ chatDis.value = true;
+ loading.value = true;
+ if (!activeSessionId.value) {
+ Message.warning('璇烽�夋嫨浼氳瘽');
+ chatDis.value = false;
+ loading.value = false;
+ return;
+ }
+
+ // if (displayedText.value) {
+ // querySessionList();
+ // }
+
+ if (inputMsg.value) {
+ sessionDetailList.value.push({
+ content: inputMsg.value,
+ role: 'user',
+ });
+ sessionDetailList.value.push({ role: 'last' });
+ refreshScroll();
+ const response = await fetch(
+ '/api/tech/cloudminds/query?modeltype=localragflow',
+ {
+ method: 'POST',
+ headers: {
+ 'Authorization': getAuthorization(),
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ conversation_id: activeSessionId.value,
+ messages: inputMsg.value,
+ }),
}
- } catch (e) {
- console.warn(e);
+ );
+
+ const reader = response?.body
+ ?.pipeThrough(new TextDecoderStream())
+ .pipeThrough(new EventSourceParserStream())
+ .getReader();
+ currIndex.value = 0;
+ while (true) {
+ const x = await reader?.read();
+ if (x) {
+ const { done, value } = x;
+ console.log(x, 999);
+ try {
+ const val = JSON.parse(value?.data || '');
+ const d = val?.data;
+ if (typeof d !== 'boolean') {
+ console.info('data:', d);
+ streamStr.value = d.content;
+ startDisplayStr();
+ }
+ } catch (e) {
+ console.warn(e);
+ }
+ if (done) {
+ console.info('done');
+ displayedText.value = '';
+ querySessionDetail(sectionList.value);
+ break;
+ }
+ }
}
- if (done) {
- console.info('done');
- displayedText.value = '';
- querySessionDetail(sectionList.value);
- break;
- }
+ chatDis.value = false;
+ loading.value = false;
+ inputMsg.value = '';
+ } else {
+ Message.warning('娑堟伅涓嶈兘涓虹┖');
+ chatDis.value = false;
+ loading.value = false;
}
}
- chatDis.value = false;
- loading.value = false;
- inputMsg.value = '';
- } else {
- Message.warning('娑堟伅涓嶈兘涓虹┖');
- chatDis.value = false;
- loading.value = false;
}
};
const querySessionDetail = async (session) => {
@@ -564,7 +580,7 @@
.card-btn-2 {
margin: 10px 10px;
}
- .chat-item-answer {
+ .chatItemAnswer {
box-sizing: border-box;
background: #f1f1f1;
border-radius: 14px;
@@ -663,7 +679,7 @@
}
.chat-item {
padding: 10px 0;
- .chart-user-text {
+ .chartUserText {
font-weight: 600;
font-size: 14px;
color: #333;
--
Gitblit v1.8.0