feat:交接
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// AI角色配置文件
|
||||
export const aiCharacters = [
|
||||
{
|
||||
id: 5,
|
||||
name: '萌妹小甜',
|
||||
id: 9,
|
||||
name: '萌妹陪你聊天',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '可爱活泼,喜欢撒娇',
|
||||
greeting: '你好呀~我是小甜,今天想聊什么呢?',
|
||||
greeting: '你好呀~我是萌妹,今天想聊什么呢?',
|
||||
voiceStyle: '甜美可爱',
|
||||
responseStyle: '活泼俏皮,喜欢用表情符号',
|
||||
interests: ['美食', '宠物', '音乐', '旅行'],
|
||||
@@ -18,11 +18,11 @@ export const aiCharacters = [
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: '御姐温柔',
|
||||
id: 10,
|
||||
name: '御姐的温柔夜话',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '知性优雅,温柔体贴',
|
||||
greeting: '你好,我是温柔,有什么心事可以和我分享。',
|
||||
greeting: '你好,我是御姐,有什么心事可以和我分享。',
|
||||
voiceStyle: '温柔知性',
|
||||
responseStyle: '成熟稳重,善解人意',
|
||||
interests: ['阅读', '艺术', '哲学', '心理学'],
|
||||
@@ -35,11 +35,11 @@ export const aiCharacters = [
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: '童真小天使',
|
||||
id: 11,
|
||||
name: '童真世界探索',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '纯真可爱,充满好奇心',
|
||||
greeting: '嗨!我是小天使,我们一起探索有趣的世界吧!',
|
||||
greeting: '嗨!我是童真小天使,我们一起探索有趣的世界吧!',
|
||||
voiceStyle: '天真烂漫',
|
||||
responseStyle: '充满好奇,喜欢提问',
|
||||
interests: ['游戏', '动画', '童话', '科学'],
|
||||
@@ -52,8 +52,8 @@ export const aiCharacters = [
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: '贴心男友',
|
||||
id: 12,
|
||||
name: '温暖男友陪伴',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '温暖体贴,善解人意',
|
||||
greeting: '宝贝,今天过得怎么样?有什么想聊的吗?',
|
||||
@@ -70,7 +70,7 @@ export const aiCharacters = [
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
name: '搞笑达人',
|
||||
name: '搞笑达人的日常',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '幽默风趣,善于调节气氛',
|
||||
greeting: '哈哈,我是搞笑达人!准备好笑到肚子疼了吗?',
|
||||
@@ -87,10 +87,10 @@ export const aiCharacters = [
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
name: '博学智者',
|
||||
name: '博学者的深度对话',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '知识渊博,思维深刻',
|
||||
greeting: '你好,我是博学智者,让我们进行一场深度对话吧。',
|
||||
greeting: '你好,我是博学者,让我们进行一场深度对话吧。',
|
||||
voiceStyle: '沉稳睿智',
|
||||
responseStyle: '引经据典,富有哲理',
|
||||
interests: ['历史', '文学', '科学', '哲学'],
|
||||
@@ -104,10 +104,10 @@ export const aiCharacters = [
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
name: '活力健将',
|
||||
name: '运动健将的正能量',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '充满活力,积极向上',
|
||||
greeting: '嘿!我是活力健将,让我们一起充满正能量!',
|
||||
greeting: '嘿!我是运动健将,让我们一起充满正能量!',
|
||||
voiceStyle: '充满活力',
|
||||
responseStyle: '积极向上,充满正能量',
|
||||
interests: ['运动', '健身', '户外', '挑战'],
|
||||
@@ -121,7 +121,7 @@ export const aiCharacters = [
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
name: '文艺青年',
|
||||
name: '文艺青年的灵感分享',
|
||||
avatar: '/static/logo.png',
|
||||
personality: '文艺浪漫,富有想象力',
|
||||
greeting: '你好,我是文艺青年,让我们一起感受生活的美好。',
|
||||
@@ -145,6 +145,12 @@ export const getCharacterById = (id) => {
|
||||
|
||||
// 根据角色性格生成回复
|
||||
export const generateResponse = (character, userMessage) => {
|
||||
// 检查character和sampleResponses是否存在
|
||||
if (!character || !character.sampleResponses || !Array.isArray(character.sampleResponses)) {
|
||||
console.warn('角色信息不完整,使用默认回复');
|
||||
return '抱歉,我现在有点困惑,能再说一遍吗?';
|
||||
}
|
||||
|
||||
const responses = character.sampleResponses;
|
||||
const randomIndex = Math.floor(Math.random() * responses.length);
|
||||
return responses[randomIndex];
|
||||
@@ -152,6 +158,17 @@ export const generateResponse = (character, userMessage) => {
|
||||
|
||||
// 根据用户消息内容智能选择回复
|
||||
export const getSmartResponse = (character, userMessage) => {
|
||||
// 检查参数有效性
|
||||
if (!character) {
|
||||
console.warn('角色信息为空,使用默认回复');
|
||||
return '抱歉,我现在有点困惑,能再说一遍吗?';
|
||||
}
|
||||
|
||||
if (!userMessage || typeof userMessage !== 'string') {
|
||||
console.warn('用户消息无效,使用默认回复');
|
||||
return '抱歉,我没有听清楚,能再说一遍吗?';
|
||||
}
|
||||
|
||||
const message = userMessage.toLowerCase();
|
||||
|
||||
// 根据关键词匹配不同的回复风格
|
||||
|
||||
452
src/utils/api.js
452
src/utils/api.js
@@ -1,8 +1,55 @@
|
||||
// API服务文件
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
// 文本清理函数 - 只保留文字和标点符号
|
||||
export const cleanText = (text) => {
|
||||
if (!text || typeof text !== 'string') {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 去除所有HTML标签
|
||||
let cleaned = text.replace(/<[^>]*>/g, '');
|
||||
|
||||
// 去除Markdown格式标记
|
||||
cleaned = cleaned
|
||||
// 去除粗体标记 **text** 或 __text__
|
||||
.replace(/\*\*([^*]+)\*\*/g, '$1')
|
||||
.replace(/__([^_]+)__/g, '$1')
|
||||
// 去除斜体标记 *text* 或 _text_
|
||||
.replace(/\*([^*]+)\*/g, '$1')
|
||||
.replace(/_([^_]+)_/g, '$1')
|
||||
// 去除删除线标记 ~~text~~
|
||||
.replace(/~~([^~]+)~~/g, '$1')
|
||||
// 去除代码标记 `code`
|
||||
.replace(/`([^`]+)`/g, '$1')
|
||||
// 去除链接标记 [text](url)
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
|
||||
// 去除图片标记 
|
||||
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')
|
||||
// 去除标题标记 # ## ###
|
||||
.replace(/^#{1,6}\s*/gm, '')
|
||||
// 去除列表标记 - * +
|
||||
.replace(/^[\s]*[-*+]\s*/gm, '')
|
||||
// 去除引用标记 >
|
||||
.replace(/^>\s*/gm, '')
|
||||
// 去除水平线标记 --- 或 ***
|
||||
.replace(/^[-*]{3,}$/gm, '');
|
||||
|
||||
// 去除多余的空白字符和换行
|
||||
cleaned = cleaned
|
||||
// 将多个连续空格和换行替换为单个空格
|
||||
.replace(/\s+/g, ' ')
|
||||
// 去除行首行尾空格
|
||||
.trim();
|
||||
|
||||
// 去除特殊字符(保留中文、英文、数字、标点符号)
|
||||
cleaned = cleaned.replace(/[^\u4e00-\u9fa5a-zA-Z0-9\s\.,;:!?()()【】""''""''、,。!?;:]/g, '');
|
||||
|
||||
return cleaned;
|
||||
};
|
||||
|
||||
// 基础配置
|
||||
const BASE_URL = 'http://8.145.52.111:8091'; // 根据后端地址调整
|
||||
const BASE_URL = 'http://localhost:8091'; // 根据后端地址调整
|
||||
|
||||
// 检查用户登录状态
|
||||
const checkLoginStatus = () => {
|
||||
@@ -43,7 +90,7 @@ const request = (options) => {
|
||||
method: options.method || 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': loginStatus.token || '',
|
||||
'Authorization': loginStatus.token ? (loginStatus.token.startsWith('Bearer ') ? loginStatus.token : 'Bearer ' + loginStatus.token) : '',
|
||||
...options.header
|
||||
},
|
||||
data: options.data || {},
|
||||
@@ -98,15 +145,20 @@ export const chatAPI = {
|
||||
}
|
||||
|
||||
try {
|
||||
const requestData = {
|
||||
message: params.message,
|
||||
useFunctionCall: false,
|
||||
modelId: params.modelId || null, // 支持传入modelId,默认为null使用后端默认
|
||||
templateId: params.templateId || params.characterId, // 支持templateId参数
|
||||
sessionId: params.sessionId || null // 支持sessionId参数
|
||||
};
|
||||
|
||||
console.log('发送AI聊天请求,参数:', requestData);
|
||||
|
||||
const response = await request({
|
||||
url: '/api/chat/sync',
|
||||
method: 'POST',
|
||||
data: {
|
||||
message: params.message,
|
||||
useFunctionCall: false,
|
||||
modelId: null, // 使用默认模型
|
||||
templateId: params.characterId // 使用角色模板ID
|
||||
}
|
||||
data: requestData
|
||||
});
|
||||
|
||||
console.log('API原始响应:', response);
|
||||
@@ -120,8 +172,13 @@ export const chatAPI = {
|
||||
}
|
||||
// 如果响应是对象,尝试提取AI回复
|
||||
else if (typeof response === 'object' && response !== null) {
|
||||
// 优先处理嵌套结构:res.data.data.response
|
||||
if (response.data && response.data.data && response.data.data.response) {
|
||||
// 优先处理根级别的response字段(根据实际后端响应结构)
|
||||
if (response.response && typeof response.response === 'string') {
|
||||
processedResponse = response.response;
|
||||
console.log('从根级别字段 response 提取回复:', processedResponse);
|
||||
}
|
||||
// 备用:处理嵌套结构:res.data.data.response
|
||||
else if (response.data && response.data.data && response.data.data.response) {
|
||||
processedResponse = response.data.data.response;
|
||||
console.log('从嵌套结构 data.data.response 提取回复:', processedResponse);
|
||||
}
|
||||
@@ -131,6 +188,17 @@ export const chatAPI = {
|
||||
console.log('从字段 data.response 提取回复:', processedResponse);
|
||||
}
|
||||
// 检查是否为状态消息
|
||||
else if (response.message) {
|
||||
if (response.message === '对话成功') {
|
||||
// 后端返回成功消息,使用默认回复
|
||||
processedResponse = '我收到了你的消息,很高兴和你聊天!';
|
||||
console.log('检测到对话成功状态,使用默认回复');
|
||||
} else {
|
||||
// 如果后端返回了错误信息,抛出错误
|
||||
throw new Error(response.message);
|
||||
}
|
||||
}
|
||||
// 检查data中的message字段
|
||||
else if (response.data && response.data.message) {
|
||||
if (response.data.message === '对话成功') {
|
||||
// 后端返回成功消息,使用默认回复
|
||||
@@ -172,9 +240,14 @@ export const chatAPI = {
|
||||
console.log('未找到有效回复,使用默认回复');
|
||||
}
|
||||
|
||||
// 清理文本,只保留文字和标点符号
|
||||
const cleanedResponse = cleanText(processedResponse);
|
||||
console.log('原始回复:', processedResponse);
|
||||
console.log('清理后回复:', cleanedResponse);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: processedResponse,
|
||||
data: cleanedResponse,
|
||||
originalResponse: response
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -369,7 +442,7 @@ export const voiceAPI = {
|
||||
}
|
||||
},
|
||||
|
||||
// 3. 语音对话 - 完整语音交互流程
|
||||
// 3. 语音对话 - 完整语音交互流程(前端发送aac格式,后端转换为wav处理)
|
||||
voiceChat: async (filePath, options = {}) => {
|
||||
try {
|
||||
const loginStatus = checkLoginStatus();
|
||||
@@ -384,6 +457,7 @@ export const voiceAPI = {
|
||||
}
|
||||
|
||||
console.log('开始语音对话,文件路径:', filePath);
|
||||
console.log('注意:前端发送aac格式音频,后端需要转换为wav格式进行处理');
|
||||
|
||||
// 构建认证头
|
||||
let authHeader = '';
|
||||
@@ -411,13 +485,55 @@ export const voiceAPI = {
|
||||
const data = JSON.parse(res.data);
|
||||
console.log('语音对话响应数据:', data);
|
||||
|
||||
if (data.code === 200 && data.data) {
|
||||
if (data.code === 200) {
|
||||
// 根据后端实际返回结构提取字段
|
||||
let aiResponse = null;
|
||||
let userText = null;
|
||||
let audioUrl = null;
|
||||
|
||||
// 从 data.llmResult.response 提取AI回复
|
||||
if (data.data && data.data.llmResult && data.data.llmResult.response) {
|
||||
aiResponse = data.data.llmResult.response;
|
||||
}
|
||||
|
||||
// 从 data.sttResult.text 提取用户文本(语音转文字)
|
||||
if (data.data && data.data.sttResult && data.data.sttResult.text) {
|
||||
userText = data.data.sttResult.text;
|
||||
}
|
||||
|
||||
// 从 data.ttsResult.audioPath 提取音频路径
|
||||
if (data.data && data.data.ttsResult && data.data.ttsResult.audioPath) {
|
||||
audioUrl = data.data.ttsResult.audioPath;
|
||||
}
|
||||
|
||||
// 备用字段提取(保持向后兼容)
|
||||
if (!aiResponse) {
|
||||
if (data.response && typeof data.response === 'string') {
|
||||
aiResponse = data.response;
|
||||
} else if (data.data && data.data.response) {
|
||||
aiResponse = data.data.response;
|
||||
}
|
||||
}
|
||||
|
||||
if (!userText) {
|
||||
userText = data.userText || data.data?.userText || data.data?.text || data.data?.user_text || data.data?.recognizedText || data.data?.transcription;
|
||||
}
|
||||
|
||||
if (!audioUrl) {
|
||||
audioUrl = data.audioPath || data.audioUrl || data.data?.audioUrl || data.data?.url || data.data?.audio_url || data.data?.speechUrl || data.data?.ttsUrl || data.data?.audioPath;
|
||||
}
|
||||
|
||||
// 清理AI回复文本
|
||||
const cleanedAiResponse = cleanText(aiResponse);
|
||||
console.log('原始AI回复:', aiResponse);
|
||||
console.log('清理后AI回复:', cleanedAiResponse);
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
data: {
|
||||
userText: data.data.userText || data.data.text,
|
||||
aiResponse: data.data.aiResponse || data.data.response,
|
||||
audioUrl: data.data.audioUrl || data.data.url
|
||||
userText: userText,
|
||||
aiResponse: cleanedAiResponse,
|
||||
audioUrl: audioUrl
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -452,7 +568,7 @@ export const voiceAPI = {
|
||||
}
|
||||
},
|
||||
|
||||
// 4. 音频文件上传语音对话
|
||||
// 4. 音频文件上传语音对话(前端发送aac格式,后端转换为wav处理)
|
||||
uploadVoiceChat: async (filePath, options = {}) => {
|
||||
try {
|
||||
const loginStatus = checkLoginStatus();
|
||||
@@ -467,6 +583,7 @@ export const voiceAPI = {
|
||||
}
|
||||
|
||||
console.log('开始上传音频文件语音对话,文件路径:', filePath);
|
||||
console.log('注意:前端发送aac格式音频,后端需要转换为wav格式进行处理');
|
||||
|
||||
// 构建认证头
|
||||
let authHeader = '';
|
||||
@@ -494,13 +611,55 @@ export const voiceAPI = {
|
||||
const data = JSON.parse(res.data);
|
||||
console.log('上传音频文件语音对话响应数据:', data);
|
||||
|
||||
if (data.code === 200 && data.data) {
|
||||
if (data.code === 200) {
|
||||
// 根据后端实际返回结构提取字段
|
||||
let aiResponse = null;
|
||||
let userText = null;
|
||||
let audioUrl = null;
|
||||
|
||||
// 从 data.llmResult.response 提取AI回复
|
||||
if (data.data && data.data.llmResult && data.data.llmResult.response) {
|
||||
aiResponse = data.data.llmResult.response;
|
||||
}
|
||||
|
||||
// 从 data.sttResult.text 提取用户文本(语音转文字)
|
||||
if (data.data && data.data.sttResult && data.data.sttResult.text) {
|
||||
userText = data.data.sttResult.text;
|
||||
}
|
||||
|
||||
// 从 data.ttsResult.audioPath 提取音频路径
|
||||
if (data.data && data.data.ttsResult && data.data.ttsResult.audioPath) {
|
||||
audioUrl = data.data.ttsResult.audioPath;
|
||||
}
|
||||
|
||||
// 备用字段提取(保持向后兼容)
|
||||
if (!aiResponse) {
|
||||
if (data.response && typeof data.response === 'string') {
|
||||
aiResponse = data.response;
|
||||
} else if (data.data && data.data.response) {
|
||||
aiResponse = data.data.response;
|
||||
}
|
||||
}
|
||||
|
||||
if (!userText) {
|
||||
userText = data.userText || data.data?.userText || data.data?.text || data.data?.user_text || data.data?.recognizedText || data.data?.transcription;
|
||||
}
|
||||
|
||||
if (!audioUrl) {
|
||||
audioUrl = data.audioPath || data.audioUrl || data.data?.audioUrl || data.data?.url || data.data?.audio_url || data.data?.speechUrl || data.data?.ttsUrl || data.data?.audioPath;
|
||||
}
|
||||
|
||||
// 清理AI回复文本
|
||||
const cleanedAiResponse = cleanText(aiResponse);
|
||||
console.log('原始AI回复:', aiResponse);
|
||||
console.log('清理后AI回复:', cleanedAiResponse);
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
data: {
|
||||
userText: data.data.userText || data.data.text,
|
||||
aiResponse: data.data.aiResponse || data.data.response,
|
||||
audioUrl: data.data.audioUrl || data.data.url
|
||||
userText: userText,
|
||||
aiResponse: cleanedAiResponse,
|
||||
audioUrl: audioUrl
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -550,5 +709,256 @@ export const voiceAPI = {
|
||||
}
|
||||
};
|
||||
|
||||
// 充值相关API
|
||||
export const rechargeAPI = {
|
||||
// 获取用户余额
|
||||
getUserBalance: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/api/recharge/balance',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取用户余额失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 创建充值订单
|
||||
createRechargeOrder: async (orderData) => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/api/recharge/create-order',
|
||||
method: 'POST',
|
||||
data: {
|
||||
amount: orderData.amount,
|
||||
paymentMethod: orderData.paymentMethod || 'wechat',
|
||||
bonusAmount: 0 // 已取消赠送服务
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('创建充值订单失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 查询订单状态
|
||||
getOrderStatus: async (orderId) => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: `/api/recharge/order-status/${orderId}`,
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('查询订单状态失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 获取充值记录
|
||||
getRechargeHistory: async (params = {}) => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/api/recharge/history',
|
||||
method: 'GET',
|
||||
data: {
|
||||
page: params.page || 1,
|
||||
pageSize: params.pageSize || 10,
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取充值记录失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 角色相关API
|
||||
export const roleAPI = {
|
||||
// 获取角色列表
|
||||
getRoles: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/api/role/query',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取角色列表失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 获取角色详情
|
||||
getRoleById: async (roleId) => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: `/api/role/query?roleId=${roleId}`,
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取角色详情失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 配置相关API
|
||||
export const configAPI = {
|
||||
// 获取所有配置
|
||||
getAllConfigs: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/app/config/query',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取所有配置失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 获取LLM模型配置
|
||||
getModels: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/app/config/models',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取LLM模型配置失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 获取STT配置
|
||||
getSTTConfigs: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/app/config/stt',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取STT配置失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 获取模板配置
|
||||
getTemplates: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/app/config/templates',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取模板配置失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 获取TTS配置
|
||||
getTTSConfigs: async () => {
|
||||
try {
|
||||
const response = await request({
|
||||
url: '/app/config/tts',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取TTS配置失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 导出默认请求方法
|
||||
export default request;
|
||||
|
||||
Reference in New Issue
Block a user