This commit is contained in:
weipengfei 2023-10-13 17:48:46 +08:00
parent 0a71909df0
commit c3799d8eb7
6 changed files with 32 additions and 10 deletions

View File

@ -26,7 +26,7 @@
.dots > div { .dots > div {
width: 4em; width: 4em;
height: 4em; height: 4em;
background-color: #3cefff; background-color: #7fe7c4;
border-radius: 50%; border-radius: 50%;
animation: fade 1.5s alternate ease-in-out infinite; animation: fade 1.5s alternate ease-in-out infinite;
} }

View File

@ -19,7 +19,7 @@ div::before {
left: -3px; left: -3px;
width: 20em; width: 20em;
height: 20em; height: 20em;
background-color: hsla(185, 100%, 62%, 0.75); background-color: hsla(185, 65%, 58%, 0.75);
transform-origin: center bottom; transform-origin: center bottom;
transform: scaleY(1); transform: scaleY(1);
animation: fill 3s linear infinite; animation: fill 3s linear infinite;

View File

@ -25,8 +25,8 @@
.middle, .middle,
.inner { .inner {
border: 3px solid transparent; border: 3px solid transparent;
border-top-color: #3cefff; border-top-color: #7fe7c4;
border-right-color: #3cefff; border-right-color: #7fe7c4;
border-radius: 50%; border-radius: 50%;
position: absolute; position: absolute;
top: 50%; top: 50%;

View File

@ -19,7 +19,7 @@
span { span {
width: 3em; width: 3em;
height: 6em; height: 6em;
background-color: #3cefff; background-color: #7fe7c4;
} }
span:nth-of-type(1) { span:nth-of-type(1) {

View File

@ -21,6 +21,7 @@ interface Props {
interface Emit { interface Emit {
(ev: 'regenerate'): void (ev: 'regenerate'): void
(ev: 'delete'): void (ev: 'delete'): void
(ev: 'changeNowStatus'): string
} }
const props = defineProps<Props>() const props = defineProps<Props>()
@ -97,6 +98,7 @@ let sok = false
async function radioPlay() { async function radioPlay() {
console.log('播放', props.mp3) console.log('播放', props.mp3)
audioElements.length = 0 audioElements.length = 0
emit('changeNowStatus', 'loding')
const socket = new WebSocket('wss://chat.lihaink.cn/zhanti/tts') const socket = new WebSocket('wss://chat.lihaink.cn/zhanti/tts')
sok = true sok = true
@ -166,8 +168,12 @@ const onAudioEnd = (index: any) => {
if (playing < audioElements.length) { if (playing < audioElements.length) {
playFlag = true playFlag = true
audioElements[playing].play() audioElements[playing].play()
emit('changeNowStatus', 'playing')
}
else {
playStatus.value = 'end';
emit('changeNowStatus', 'input')
} }
else { playStatus.value = 'end' }
} }
// //
const audioElements = reactive([]) const audioElements = reactive([])
@ -175,6 +181,7 @@ const audioElements = reactive([])
const playAudio = (playIndex: any) => { const playAudio = (playIndex: any) => {
// for (let i = 0; i < audioElements.length; i++) // for (let i = 0; i < audioElements.length; i++)
audioElements[0].play() audioElements[0].play()
emit('changeNowStatus', 'playing')
} }
watch(() => audioElements.length, (newVal, oldVal) => { watch(() => audioElements.length, (newVal, oldVal) => {
@ -191,11 +198,13 @@ let pauseIndex = -1
const pauseAudio = () => { const pauseAudio = () => {
pauseIndex = playing + 0 pauseIndex = playing + 0
playStatus.value = 'pause' playStatus.value = 'pause'
emit('changeNowStatus', 'input')
for (let i = 0; i < audioElements.length; i++) for (let i = 0; i < audioElements.length; i++)
audioElements[i].pause() audioElements[i].pause()
} }
const noPauseAudio = () => { const noPauseAudio = () => {
playStatus.value = 'playing' playStatus.value = 'playing'
emit('changeNowStatus', 'playing')
audioElements[pauseIndex].play() audioElements[pauseIndex].play()
pauseIndex = -1 pauseIndex = -1
} }

View File

@ -218,7 +218,7 @@ async function onConversation() {
// console.log(`: `, msg.payload.choices.text[0].content); // console.log(`: `, msg.payload.choices.text[0].content);
// console.log(`: `, dataSources.value[dataSources.value.length - 1].text); // console.log(`: `, dataSources.value[dataSources.value.length - 1].text);
lastText += msg.payload.choices.text[0].content lastText += msg.payload.choices.text[0].content
const loading = true const loading = false
nowStart.value = false nowStart.value = false
updateChat( updateChat(
+uuid, +uuid,
@ -588,6 +588,18 @@ const footerClass = computed(() => {
return classes return classes
}) })
//
const changeNowStatus = (e:any)=>{
console.log('收到数据',e);
if(e!=nowStatus.value){
switch(e){
case 'playing': nowStatus.value = 'record';break;
case 'loding': nowStatus.value = 'loding';break;
default: nowStatus.value = 'input';break;
}
}
}
onMounted(() => { onMounted(() => {
scrollToBottom() scrollToBottom()
if (inputRef.value && !isMobile.value) if (inputRef.value && !isMobile.value)
@ -606,9 +618,9 @@ window.addEventListener('test', (e) => {
prompt.value = window.winText prompt.value = window.winText
}) })
// setTimeout(() => { setTimeout(() => {
// nowStart.value = false nowStart.value = false
// }, 800) }, 800)
</script> </script>
<template> <template>
@ -669,6 +681,7 @@ window.addEventListener('test', (e) => {
:inversion="item.inversion" :inversion="item.inversion"
:error="item.error" :error="item.error"
:loading="item.loading" :loading="item.loading"
@changeNowStatus="changeNowStatus"
@regenerate="onRegenerate(index)" @regenerate="onRegenerate(index)"
@delete="handleDelete(index)" @delete="handleDelete(index)"
/> />