增加连接按钮
This commit is contained in:
@@ -5,6 +5,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
@click="connectToAgent"
|
||||||
|
:disabled="isConnected"
|
||||||
|
circle
|
||||||
|
>
|
||||||
|
<el-icon><VideoPlay /></el-icon>
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
:class="{ 'is-listening': isListening }"
|
:class="{ 'is-listening': isListening }"
|
||||||
@@ -48,7 +56,7 @@
|
|||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useChatStore } from '../../stores/chat';
|
import { useChatStore } from '../../stores/chat';
|
||||||
import { ElButton, ElMessage, ElIcon } from 'element-plus';
|
import { ElButton, ElMessage, ElIcon } from 'element-plus';
|
||||||
import { Microphone, Headset, Close, Delete } from '@element-plus/icons-vue';
|
import { Microphone, Headset, Close, Delete, VideoPlay } from '@element-plus/icons-vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ControlPanel',
|
name: 'ControlPanel',
|
||||||
@@ -59,7 +67,8 @@ export default {
|
|||||||
Microphone,
|
Microphone,
|
||||||
Headset,
|
Headset,
|
||||||
Close,
|
Close,
|
||||||
Delete
|
Delete,
|
||||||
|
VideoPlay
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@@ -118,6 +127,21 @@ export default {
|
|||||||
ElMessage.success('消息已清除');
|
ElMessage.success('消息已清除');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Connect to agent
|
||||||
|
const connectToAgent = async () => {
|
||||||
|
try {
|
||||||
|
const success = await chatStore.initialize();
|
||||||
|
if (success) {
|
||||||
|
ElMessage.success('连接成功!');
|
||||||
|
} else {
|
||||||
|
ElMessage.error('连接失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error connecting to agent:', error);
|
||||||
|
ElMessage.error('连接失败: ' + error.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isListening,
|
isListening,
|
||||||
isSpeaking,
|
isSpeaking,
|
||||||
@@ -129,7 +153,8 @@ export default {
|
|||||||
statusText,
|
statusText,
|
||||||
toggleListening,
|
toggleListening,
|
||||||
endSession,
|
endSession,
|
||||||
clearMessages
|
clearMessages,
|
||||||
|
connectToAgent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user