This commit is contained in:
wangdan-fit2cloud 2023-12-18 18:26:59 +08:00
parent 55439aec0d
commit 1de6fca2df

View File

@ -127,7 +127,7 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, nextTick, onUpdated, computed, watch } from 'vue' import { ref, nextTick, onMounted, onUpdated, computed, watch } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import LogOperationButton from './LogOperationButton.vue' import LogOperationButton from './LogOperationButton.vue'
import OperationButton from './OperationButton.vue' import OperationButton from './OperationButton.vue'
@ -272,11 +272,13 @@ function chatMessage() {
const reader = response.body.getReader() const reader = response.body.getReader()
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/ /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
const write = ({ done, value }: { done: boolean; value: any }) => { const write = ({ done, value }: { done: boolean; value: any }) => {
let scrollInterval
try { try {
if (done) { if (done) {
ChatManagement.close(id) ChatManagement.close(id)
return return
} }
const decoder = new TextDecoder('utf-8') const decoder = new TextDecoder('utf-8')
const str = decoder.decode(value, { stream: true }) const str = decoder.decode(value, { stream: true })
if (str && str.startsWith('data:')) { if (str && str.startsWith('data:')) {
@ -288,8 +290,12 @@ function chatMessage() {
const content = chunk?.content const content = chunk?.content
if (content) { if (content) {
ChatManagement.append(id, content) ChatManagement.append(id, content)
scrollInterval = setInterval(() => {
handleScrollBottom()
}, 300)
} }
if (chunk.is_end) { if (chunk.is_end) {
clearInterval(scrollInterval)
// //
return Promise.resolve() return Promise.resolve()
} }