|
|
@@ -194,6 +194,7 @@ import { ArrowUp, ArrowDown, Microphone, PhoneFilled, ChatDotRound, Mute } from
|
|
|
import { useVoiceRecognition } from './composables/useVoiceRecognition.js'
|
|
|
import { useStreamChat } from './composables/useStreamChat.js'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
+import { API_ENDPOINTS } from './config/api.js'
|
|
|
|
|
|
// 获取请求头(包含token)
|
|
|
const getHeaders = () => {
|
|
|
@@ -453,7 +454,7 @@ watch(showChat, async (newVal) => {
|
|
|
if (selectedAgent.value && currentConversationId.value) {
|
|
|
try {
|
|
|
const sessionId = currentConversationId.value
|
|
|
- await fetch(`http://localhost:8080/talk/agent/${selectedAgent.value}/hangup`, {
|
|
|
+ await fetch(API_ENDPOINTS.agentHangup(selectedAgent.value), {
|
|
|
method: 'POST',
|
|
|
headers: getHeaders(),
|
|
|
body: JSON.stringify({
|
|
|
@@ -581,7 +582,7 @@ const selectedAgent = ref(null)
|
|
|
// 获取发言人字典列表
|
|
|
const fetchTtsVcnList = async () => {
|
|
|
try {
|
|
|
- const response = await fetch('http://localhost:8080/talk/dict/ttsVcn', {
|
|
|
+ const response = await fetch(API_ENDPOINTS.ttsVcn, {
|
|
|
headers: getHeaders()
|
|
|
})
|
|
|
const data = await response.json()
|
|
|
@@ -594,7 +595,7 @@ const fetchTtsVcnList = async () => {
|
|
|
// 获取客服列表
|
|
|
const fetchAgents = async (silent = false) => {
|
|
|
try {
|
|
|
- const response = await fetch('http://localhost:8080/talk/agent/list', {
|
|
|
+ const response = await fetch(API_ENDPOINTS.agentList, {
|
|
|
headers: getHeaders()
|
|
|
})
|
|
|
const result = await response.json()
|
|
|
@@ -657,7 +658,7 @@ const stopAgentRefresh = () => {
|
|
|
const handleLogout = async () => {
|
|
|
try {
|
|
|
// 调用后端退出登录接口
|
|
|
- await fetch('http://localhost:8080/talk/auth/logout', {
|
|
|
+ await fetch(API_ENDPOINTS.logout, {
|
|
|
method: 'POST',
|
|
|
headers: getHeaders()
|
|
|
})
|
|
|
@@ -695,7 +696,7 @@ const getAvatarUrl = (avatarUrl) => {
|
|
|
if (avatarUrl.startsWith('http://') || avatarUrl.startsWith('https://')) {
|
|
|
return avatarUrl
|
|
|
}
|
|
|
- return 'http://localhost:8080' + avatarUrl
|
|
|
+ return API_ENDPOINTS.avatar(avatarUrl)
|
|
|
}
|
|
|
|
|
|
// 开始对话
|
|
|
@@ -723,7 +724,7 @@ const startChat = async () => {
|
|
|
|
|
|
try {
|
|
|
// 调用对话前端的开始对话接口(带并发控制)
|
|
|
- const response = await fetch(`http://localhost:8080/talk/agent/${selectedAgent.value}/start`, {
|
|
|
+ const response = await fetch(API_ENDPOINTS.agentStart(selectedAgent.value), {
|
|
|
method: 'POST',
|
|
|
headers: getHeaders()
|
|
|
})
|
|
|
@@ -747,7 +748,7 @@ const startChat = async () => {
|
|
|
}
|
|
|
|
|
|
// 更新客服的TTS配置
|
|
|
- await fetch(`http://localhost:8080/talk/agent/${selectedAgent.value}`, {
|
|
|
+ await fetch(API_ENDPOINTS.agentUpdate(selectedAgent.value), {
|
|
|
method: 'PUT',
|
|
|
headers: getHeaders(),
|
|
|
body: JSON.stringify({
|