完善 SSE 功能

This commit is contained in:
RockYang
2025-05-27 08:16:02 +08:00
parent 41e4b1c7ac
commit e685876cc0
7 changed files with 487 additions and 547 deletions
+36 -22
View File
@@ -1,22 +1,36 @@
<template>
<el-dialog
class="config-dialog"
v-model="showDialog"
:close-on-click-modal="true"
:before-close="close"
style="max-width: 600px"
title="聊天配置"
class="config-dialog"
v-model="showDialog"
:close-on-click-modal="true"
:before-close="close"
style="max-width: 600px"
title="聊天配置"
>
<div class="chat-setting">
<el-form :model="data" label-width="100px" label-position="left">
<el-form-item label="聊天样式:">
<el-radio-group v-model="data.style" @change="(val) => {store.setChatListStyle(val)}">
<el-radio-group
v-model="data.style"
@change="
(val) => {
store.setChatListStyle(val)
}
"
>
<el-radio value="list">列表样式</el-radio>
<el-radio value="chat">对话样式</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="流式输出:">
<el-switch v-model="data.stream" @change="(val) => {store.setChatStream(val)}" />
<el-switch
v-model="data.stream"
@change="
(val) => {
store.setChatStream(val)
}
"
/>
</el-form-item>
<el-form-item label="语音音色:">
<el-select v-model="data.ttsModel" placeholder="请选择语音音色" @change="changeTTSModel">
@@ -31,10 +45,10 @@
</template>
<script setup>
import {computed, ref, onMounted} from "vue"
import {useSharedStore} from "@/store/sharedata";
import {httpGet} from "@/utils/http";
const store = useSharedStore();
import { computed, ref, onMounted } from 'vue'
import { useSharedStore } from '@/store/sharedata'
import { httpGet } from '@/utils/http'
const store = useSharedStore()
const data = ref({
style: store.chatListStyle,
@@ -44,28 +58,28 @@ const data = ref({
// eslint-disable-next-line no-undef
const props = defineProps({
show: Boolean,
});
})
const showDialog = computed(() => {
return props.show
})
const emits = defineEmits(['hide']);
const emits = defineEmits(['hide'])
const close = function () {
emits('hide', false);
emits('hide', false)
}
const models = ref([]);
const models = ref([])
onMounted(() => {
// 获取模型列表
httpGet("/api/model/list?type=tts").then((res) => {
models.value = res.data;
if (!data.ttsModel) {
store.setTtsModel(models.value[0].id);
httpGet('/api/model/list?type=tts').then((res) => {
models.value = res.data
if (!data.ttsModel && models.value.length > 0) {
store.setTtsModel(models.value[0].id)
}
})
})
const changeTTSModel = (item) => {
store.setTtsModel(item);
store.setTtsModel(item)
}
</script>
@@ -73,4 +87,4 @@ const changeTTSModel = (item) => {
.chat-setting {
}
</style>
</style>