mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 17:43:55 +08:00
fix: 修复 mobile 短信验证码错误重复提示、智能体插件保存异常问题
This commit is contained in:
@@ -587,15 +587,6 @@ function handleTools() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听插件配置更新
|
|
||||||
function watchPluginUpdates() {
|
|
||||||
// 监听store中的插件配置变化
|
|
||||||
watch(() => pluginStore.currentFunctions, (newFunctions) => {
|
|
||||||
console.log('插件配置已更新:', newFunctions)
|
|
||||||
formData.value.functions = newFunctions
|
|
||||||
}, { deep: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取智能体标签
|
// 获取智能体标签
|
||||||
async function loadAgentTags() {
|
async function loadAgentTags() {
|
||||||
try {
|
try {
|
||||||
@@ -611,9 +602,12 @@ async function handleUpdateAgentTags() {
|
|||||||
await updateAgentTags(agentId.value, { tagNames })
|
await updateAgentTags(agentId.value, { tagNames })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听store中的插件配置变化
|
||||||
|
watch(() => pluginStore.currentFunctions, (newFunctions) => {
|
||||||
|
formData.value.functions = newFunctions
|
||||||
|
}, { deep: true })
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 初始化插件配置监听
|
|
||||||
watchPluginUpdates()
|
|
||||||
loadAgentTags()
|
loadAgentTags()
|
||||||
|
|
||||||
// 先加载模型选项和角色模板
|
// 先加载模型选项和角色模板
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useMessage } from 'wot-design-uni'
|
import { useMessage } from 'wot-design-uni'
|
||||||
import { getMcpAddress, getMcpTools } from '@/api/agent/agent'
|
import { getMcpAddress, getMcpTools } from '@/api/agent/agent'
|
||||||
import { usePluginStore } from '@/store'
|
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
|
import { usePluginStore } from '@/store'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const pluginStore = usePluginStore()
|
const pluginStore = usePluginStore()
|
||||||
@@ -30,8 +30,8 @@ const mcpAddress = ref('')
|
|||||||
const mcpTools = ref<string[]>([])
|
const mcpTools = ref<string[]>([])
|
||||||
|
|
||||||
// 初始化时从本地存储加载MCP地址
|
// 初始化时从本地存储加载MCP地址
|
||||||
if (uni.getStorageSync('cachedMcpAddress_' + agentId.value)) {
|
if (uni.getStorageSync(`cachedMcpAddress_${agentId.value}`)) {
|
||||||
mcpAddress.value = uni.getStorageSync('cachedMcpAddress_' + agentId.value)
|
mcpAddress.value = uni.getStorageSync(`cachedMcpAddress_${agentId.value}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数编辑相关
|
// 参数编辑相关
|
||||||
@@ -67,8 +67,9 @@ async function mergeFunctions() {
|
|||||||
const address = await getMcpAddress(agentId.value)
|
const address = await getMcpAddress(agentId.value)
|
||||||
mcpAddress.value = address
|
mcpAddress.value = address
|
||||||
// 缓存到本地存储,下次打开页面可以立即显示
|
// 缓存到本地存储,下次打开页面可以立即显示
|
||||||
uni.setStorageSync('cachedMcpAddress_' + agentId.value, address)
|
uni.setStorageSync(`cachedMcpAddress_${agentId.value}`, address)
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
console.error('获取MCP地址失败:', error)
|
console.error('获取MCP地址失败:', error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,8 @@ async function mergeFunctions() {
|
|||||||
try {
|
try {
|
||||||
const tools = await getMcpTools(agentId.value)
|
const tools = await getMcpTools(agentId.value)
|
||||||
mcpTools.value = tools || []
|
mcpTools.value = tools || []
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
console.error('获取MCP工具列表失败:', error)
|
console.error('获取MCP工具列表失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,12 +87,12 @@ async function mergeFunctions() {
|
|||||||
// 添加插件到已选
|
// 添加插件到已选
|
||||||
function selectFunction(func: any) {
|
function selectFunction(func: any) {
|
||||||
// 添加到已选列表
|
// 添加到已选列表
|
||||||
selectedList.value.push({
|
selectedList.value = [...selectedList.value, {
|
||||||
id: func.id,
|
id: func.id,
|
||||||
name: func.name,
|
name: func.name,
|
||||||
params: { ...func.params },
|
params: { ...func.params },
|
||||||
fieldsMeta: func.fieldsMeta,
|
fieldsMeta: func.fieldsMeta,
|
||||||
})
|
}]
|
||||||
|
|
||||||
// 从未选列表中移除
|
// 从未选列表中移除
|
||||||
notSelectedList.value = notSelectedList.value.filter(
|
notSelectedList.value = notSelectedList.value.filter(
|
||||||
@@ -206,15 +208,6 @@ function closeParamEdit() {
|
|||||||
|
|
||||||
// 返回上一页并更新配置
|
// 返回上一页并更新配置
|
||||||
function goBack() {
|
function goBack() {
|
||||||
const finalFunctions = selectedList.value.map(f => ({
|
|
||||||
pluginId: f.id,
|
|
||||||
paramInfo: f.params,
|
|
||||||
}))
|
|
||||||
|
|
||||||
// 更新到store中
|
|
||||||
pluginStore.updateFunctions(finalFunctions)
|
|
||||||
|
|
||||||
// 直接返回
|
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,11 +222,11 @@ function copyMcpAddress() {
|
|||||||
data: mcpAddress.value,
|
data: mcpAddress.value,
|
||||||
showToast: false,
|
showToast: false,
|
||||||
success: () => {
|
success: () => {
|
||||||
message.alert(t('agent.tools.mcpAddressCopied'))
|
message.alert(t('agent.tools.mcpAddressCopied'))
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
message.alert(t('agent.tools.copyFailed'))
|
message.alert(t('agent.tools.copyFailed'))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,6 +247,15 @@ function getFieldRemark(field: any) {
|
|||||||
return description
|
return description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听已选列表变化,实时更新插件配置,避免用户不点击返回按钮导致配置丢失
|
||||||
|
watch(() => selectedList.value, (newSelectedList) => {
|
||||||
|
const finalFunctions = newSelectedList.map(f => ({
|
||||||
|
pluginId: f.id,
|
||||||
|
paramInfo: f.params,
|
||||||
|
}))
|
||||||
|
pluginStore.updateFunctions(finalFunctions)
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 直接从store获取数据并合并
|
// 直接从store获取数据并合并
|
||||||
await mergeFunctions()
|
await mergeFunctions()
|
||||||
@@ -407,11 +409,11 @@ onMounted(async () => {
|
|||||||
class="flex-1 rounded-[10rpx] bg-[#f5f7fb] p-[20rpx]"
|
class="flex-1 rounded-[10rpx] bg-[#f5f7fb] p-[20rpx]"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
class="ml-[20rpx] h-[70rpx] flex items-center justify-center rounded-[10rpx] bg-[#1677ff] px-[20rpx] text-[24rpx] text-white"
|
class="ml-[20rpx] h-[70rpx] flex items-center justify-center rounded-[10rpx] bg-[#1677ff] px-[20rpx] text-[24rpx] text-white"
|
||||||
@click="copyMcpAddress"
|
@click="copyMcpAddress"
|
||||||
>
|
>
|
||||||
{{ t('agent.tools.copy') }}
|
{{ t('agent.tools.copy') }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 工具列表 -->
|
<!-- 工具列表 -->
|
||||||
<view class="mt-[20rpx] flex-1 overflow-hidden">
|
<view class="mt-[20rpx] flex-1 overflow-hidden">
|
||||||
|
|||||||
@@ -240,14 +240,6 @@ async function handleLogin() {
|
|||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
// 登录失败重新获取验证码
|
// 登录失败重新获取验证码
|
||||||
refreshCaptcha()
|
refreshCaptcha()
|
||||||
// 处理验证码错误 - 从error.message中解析错误码
|
|
||||||
if (error.message.includes('请求错误[10067]')) {
|
|
||||||
toast.warning(t('login.captchaError'))
|
|
||||||
}
|
|
||||||
// 处理账号或密码错误
|
|
||||||
else if (error.message.includes('请求错误[10004]')) {
|
|
||||||
toast.warning(t('message.passwordError'))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user