feat: 完成角色卡,智能体配置,加载,历史记录,清空等功能
This commit is contained in:
57
src/pages/role-chat/role-chat.vue
Normal file
57
src/pages/role-chat/role-chat.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<ChatBox
|
||||
:character-config="characterConfig"
|
||||
:ai-config="aiConfig"
|
||||
:ui-config="uiConfig"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import ChatBox from '@/components/ChatBox.vue';
|
||||
|
||||
// 角色配置
|
||||
const characterConfig = ref({});
|
||||
|
||||
// AI 配置
|
||||
const aiConfig = ref({
|
||||
modelId: 10,
|
||||
templateId: 6
|
||||
});
|
||||
|
||||
// UI 配置
|
||||
const uiConfig = ref({
|
||||
showBackButton: true // 角色聊天页面显示返回按钮
|
||||
});
|
||||
|
||||
// 初始化:解析 URL 参数
|
||||
onMounted(() => {
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const options = currentPage.options || {};
|
||||
|
||||
// 组装角色配置
|
||||
characterConfig.value = {
|
||||
id: options.characterId || '',
|
||||
roleId: options.roleId || '',
|
||||
name: decodeURIComponent(options.roleName || 'AI角色'),
|
||||
avatar: decodeURIComponent(options.avatar || '/static/logo.png'),
|
||||
greeting: decodeURIComponent(options.greeting || '你好!很高兴认识你!'),
|
||||
roleDesc: decodeURIComponent(options.roleDesc || '')
|
||||
};
|
||||
|
||||
// 组装 AI 配置
|
||||
aiConfig.value = {
|
||||
modelId: options.modelId ? parseInt(options.modelId) : 10,
|
||||
templateId: options.templateId ? parseInt(options.templateId) : (options.roleId ? parseInt(options.roleId) : 6),
|
||||
ttsId: options.ttsId || null,
|
||||
sttId: options.sttId || null,
|
||||
temperature: options.temperature ? parseFloat(options.temperature) : 0.7,
|
||||
topP: options.topP ? parseFloat(options.topP) : 0.9
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 无需额外样式,所有样式在 ChatBox 组件中 */
|
||||
</style>
|
||||
Reference in New Issue
Block a user