From 48087582c2e87e18243a5d72f80fee9e92db5b4a Mon Sep 17 00:00:00 2001 From: zhuoqinglian <1035449612@qq.com> Date: Wed, 11 Mar 2026 17:10:18 +0800 Subject: [PATCH] =?UTF-8?q?update:=20mobile=20=E7=BC=96=E8=BE=91=E6=BA=90?= =?UTF-8?q?=E5=92=8C=E8=AF=AD=E9=80=9F=E9=9F=B3=E8=B0=83=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-mobile/src/api/agent/agent.ts | 7 +- main/manager-mobile/src/api/agent/types.ts | 9 + .../src/components/ContextProviderDialog.vue | 467 ------------------ .../src/components/VoiceSettingsDialog.vue | 270 ---------- main/manager-mobile/src/http/request/alova.ts | 6 + main/manager-mobile/src/pages/agent/edit.vue | 86 +--- .../src/pages/agent/provider.vue | 208 ++++++++ .../src/pages/agent/speedPitch.vue | 153 ++++++ main/manager-mobile/src/pages/login/index.vue | 12 +- .../src/pages/settings/index.vue | 37 +- main/manager-mobile/src/store/index.ts | 2 + main/manager-mobile/src/store/provider.ts | 23 + main/manager-mobile/src/store/speedPitch.ts | 26 + 13 files changed, 487 insertions(+), 819 deletions(-) delete mode 100644 main/manager-mobile/src/components/ContextProviderDialog.vue delete mode 100644 main/manager-mobile/src/components/VoiceSettingsDialog.vue create mode 100644 main/manager-mobile/src/pages/agent/provider.vue create mode 100644 main/manager-mobile/src/pages/agent/speedPitch.vue create mode 100644 main/manager-mobile/src/store/provider.ts create mode 100644 main/manager-mobile/src/store/speedPitch.ts diff --git a/main/manager-mobile/src/api/agent/agent.ts b/main/manager-mobile/src/api/agent/agent.ts index 936ccc9c..1b17f28a 100644 --- a/main/manager-mobile/src/api/agent/agent.ts +++ b/main/manager-mobile/src/api/agent/agent.ts @@ -208,11 +208,8 @@ export function updateAgentTags(agentId: string, data) { } // 获取所有语言 -export function getAllLanguage(modelId, voiceName) { - const queryParams = new URLSearchParams({ - voiceName: voiceName || '', - }).toString() - return http.Get(`/models/${modelId}/voices?${queryParams}`, { +export function getAllLanguage(modelId: string) { + return http.Get<{ id: string, name: string, languages: string }[]>(`/models/${modelId}/voices`, { meta: { ignoreAuth: false, toast: false, diff --git a/main/manager-mobile/src/api/agent/types.ts b/main/manager-mobile/src/api/agent/types.ts index 55764eb0..2c61c80f 100644 --- a/main/manager-mobile/src/api/agent/types.ts +++ b/main/manager-mobile/src/api/agent/types.ts @@ -48,6 +48,15 @@ export interface AgentDetail { ttsRate: number ttsPitch: number functions: AgentFunction[] + contextProviders: Providers[] +} + +export interface Providers { + url: string + headers: Array<{ + key: string + value: string + }> } export interface AgentFunction { diff --git a/main/manager-mobile/src/components/ContextProviderDialog.vue b/main/manager-mobile/src/components/ContextProviderDialog.vue deleted file mode 100644 index d4d75ba6..00000000 --- a/main/manager-mobile/src/components/ContextProviderDialog.vue +++ /dev/null @@ -1,467 +0,0 @@ - - - - - diff --git a/main/manager-mobile/src/components/VoiceSettingsDialog.vue b/main/manager-mobile/src/components/VoiceSettingsDialog.vue deleted file mode 100644 index b4ce25a5..00000000 --- a/main/manager-mobile/src/components/VoiceSettingsDialog.vue +++ /dev/null @@ -1,270 +0,0 @@ - - - - - diff --git a/main/manager-mobile/src/http/request/alova.ts b/main/manager-mobile/src/http/request/alova.ts index 3120cfed..e7887120 100644 --- a/main/manager-mobile/src/http/request/alova.ts +++ b/main/manager-mobile/src/http/request/alova.ts @@ -42,6 +42,12 @@ const alovaInstance = createAlova({ statesHook: VueHook, beforeRequest: onAuthRequired((method) => { + // h5动态获取最新的 baseURL,确保使用用户设置的服务器地址 + const currentBaseUrl = getEnvBaseUrl() + if (currentBaseUrl !== method.baseURL) { + method.baseURL = currentBaseUrl + } + // 检查混合内容错误(HTTPS页面请求HTTP接口) const currentProtocol = typeof window !== 'undefined' && window.location.protocol const requestProtocol = method.baseURL?.split(':')[0] diff --git a/main/manager-mobile/src/pages/agent/edit.vue b/main/manager-mobile/src/pages/agent/edit.vue index 107fe7b8..ca74ac09 100644 --- a/main/manager-mobile/src/pages/agent/edit.vue +++ b/main/manager-mobile/src/pages/agent/edit.vue @@ -2,10 +2,8 @@ import type { AgentDetail, ModelOption, PluginDefinition, RoleTemplate } from '@/api/agent/types' import { computed, nextTick, onMounted, ref, watch } from 'vue' import { getAgentDetail, getAgentTags, getAllLanguage, getModelOptions, getPluginFunctions, getRoleTemplates, updateAgent, updateAgentTags } from '@/api/agent/agent' -import ContextProviderDialog from '@/components/ContextProviderDialog.vue' -import VoiceSettingsDialog from '@/components/VoiceSettingsDialog.vue' import { t } from '@/i18n' -import { usePluginStore } from '@/store' +import { usePluginStore, useProvider, useSpeedPitch } from '@/store' import { toast } from '@/utils/toast' defineOptions({ @@ -105,29 +103,17 @@ const pickerShow = ref<{ report: false, }) -const ttsSettings = ref({ - volume: 0, - speed: 0, - pitch: 0, -}) - const allFunctions = ref([]) const dynamicTags = ref([]) const inputValue = ref('') const inputVisible = ref(false) -const showContextProviderDialog = ref(false) -const currentContextProviders = ref([]) -const showVoiceSettingsDialog = ref(false) -const voiceSettings = ref({ - volume: 0, - speed: 0, - pitch: 0, -}) const languageOptions = ref([]) const isVisibleReport = ref(false) // 使用插件store const pluginStore = usePluginStore() +const speedPitchStore = useSpeedPitch() +const providerStore = useProvider() // tabs const tabList = [ @@ -174,27 +160,15 @@ function handleInputConfirm() { // 打开上下文源编辑弹窗 function openContextProviderDialog() { - showContextProviderDialog.value = true -} - -// 处理上下文源更新 -function handleUpdateContext(providers: any[]) { - currentContextProviders.value = providers -} - -function openVoiceSettingsDialog() { - showVoiceSettingsDialog.value = true -} - -function handleUpdateVoiceSettings(settings: any) { - ttsSettings.value = settings - formData.value.ttsVolume = settings.volume - formData.value.ttsRate = settings.speed - formData.value.ttsPitch = settings.pitch + uni.navigateTo({ + url: '/pages/agent/provider', + }) } function handleRegulate() { - openVoiceSettingsDialog() + uni.navigateTo({ + url: '/pages/agent/speedPitch', + }) } // 加载智能体详情 @@ -211,14 +185,15 @@ async function loadAgentDetail() { pluginStore.setCurrentAgentId(agentId.value) pluginStore.setCurrentFunctions(detail.functions || []) + // 更新语速音调 + speedPitchStore.updateSpeedPitch({ + ttsVolume: detail.ttsVolume || 0, + ttsRate: detail.ttsRate || 0, + ttsPitch: detail.ttsPitch || 0, + }) + // 加载上下文配置 - currentContextProviders.value = (detail as any).contextProviders || [] - // 加载语音设置 - voiceSettings.value = { - volume: (detail as any).volume || 0, - speed: (detail as any).speed || 0, - pitch: (detail as any).pitch || 0, - } + providerStore.updateProviders(detail.contextProviders || []) // 如果有TTS模型,加载对应的音色选项 if (detail.ttsModelId) { @@ -373,17 +348,17 @@ function filterVoicesByLanguage() { } // 同步到ttsSettings(如果值为null,使用0作为显示默认值,但不修改form中的值) - ttsSettings.value = { - volume: formData.value.ttsVolume !== null && formData.value.ttsVolume !== undefined ? formData.value.ttsVolume : 0, - speed: formData.value.ttsRate !== null && formData.value.ttsRate !== undefined ? formData.value.ttsRate : 0, - pitch: formData.value.ttsPitch !== null && formData.value.ttsPitch !== undefined ? formData.value.ttsPitch : 0, - } + speedPitchStore.updateSpeedPitch({ + ttsVolume: formData.value.ttsVolume !== null && formData.value.ttsVolume !== undefined ? formData.value.ttsVolume : 0, + ttsRate: formData.value.ttsRate !== null && formData.value.ttsRate !== undefined ? formData.value.ttsRate : 0, + ttsPitch: formData.value.ttsPitch !== null && formData.value.ttsPitch !== undefined ? formData.value.ttsPitch : 0, + }) } // 根据语音合成模型加载语言 async function fetchAllLanguag(ttsModelId: string) { try { - const res = await getAllLanguage(ttsModelId, '') as any[] + const res = await getAllLanguage(ttsModelId) // 保存完整的音色信息 voiceDetails.value = res.reduce((acc, voice) => { acc[voice.id] = voice @@ -564,8 +539,9 @@ async function saveAgent() { // 构建保存数据,包含上下文配置和语音设置 const saveData = { ...formData.value, + ...speedPitchStore.speedPitch, ttsLanguage: formData.value.language, - contextProviders: currentContextProviders.value, + contextProviders: providerStore.providers, } await updateAgent(agentId.value, saveData) loadAgentDetail() @@ -726,7 +702,7 @@ onMounted(async () => { - {{ t('agent.contextProviderSuccess', { count: currentContextProviders.length }) }} + {{ t('agent.contextProviderSuccess', { count: providerStore.providers.length }) }} {{ t('agent.contextProviderDocLink') }} @@ -994,16 +970,6 @@ onMounted(async () => { @close="onPickerCancel('report')" @select="({ item }) => onPickerConfirm('report', item.value, item.name)" /> - - diff --git a/main/manager-mobile/src/pages/agent/provider.vue b/main/manager-mobile/src/pages/agent/provider.vue new file mode 100644 index 00000000..47bd56e0 --- /dev/null +++ b/main/manager-mobile/src/pages/agent/provider.vue @@ -0,0 +1,208 @@ + +{ + "layout": "default", + "style": { + "navigationBarTitleText": "编辑源", + "navigationStyle": "custom" + } +} + + + + + + + diff --git a/main/manager-mobile/src/pages/agent/speedPitch.vue b/main/manager-mobile/src/pages/agent/speedPitch.vue new file mode 100644 index 00000000..c8b7514a --- /dev/null +++ b/main/manager-mobile/src/pages/agent/speedPitch.vue @@ -0,0 +1,153 @@ + +{ + "layout": "default", + "style": { + "navigationBarTitleText": "语音设置", + "navigationStyle": "custom" + } +} + + + + + + + diff --git a/main/manager-mobile/src/pages/login/index.vue b/main/manager-mobile/src/pages/login/index.vue index 4729ccc2..a093694c 100644 --- a/main/manager-mobile/src/pages/login/index.vue +++ b/main/manager-mobile/src/pages/login/index.vue @@ -77,11 +77,6 @@ const areaCodeList = computed(() => { return configStore.config.mobileAreaList || [{ name: '中国大陆', key: '+86' }] }) -// SM2公钥 -const sm2PublicKey = computed(() => { - return configStore.config.sm2PublicKey -}) - // 切换登录方式 function toggleLoginType() { loginType.value = loginType.value === 'username' ? 'mobile' : 'username' @@ -131,8 +126,6 @@ function generateUUID() { }) } -let skipReLaunch = false // 全局或组件作用域 - // 跳转至服务端设置页面 function goToServerSetting() { uni.switchTab({ @@ -178,7 +171,8 @@ async function handleLogin() { } // 检查SM2公钥是否配置 - if (!sm2PublicKey.value) { + const sm2PublicKey = configStore.config.sm2PublicKey + if (!sm2PublicKey) { toast.warning(t('sm2.publicKeyNotConfigured')) return } @@ -191,7 +185,7 @@ async function handleLogin() { try { // 拼接验证码和密码 const captchaAndPassword = formData.value.captcha + formData.value.password - encryptedPassword = sm2Encrypt(sm2PublicKey.value, captchaAndPassword) + encryptedPassword = sm2Encrypt(sm2PublicKey, captchaAndPassword) } catch (error) { console.error('密码加密失败:', error) diff --git a/main/manager-mobile/src/pages/settings/index.vue b/main/manager-mobile/src/pages/settings/index.vue index 34871eca..e6bb5605 100644 --- a/main/manager-mobile/src/pages/settings/index.vue +++ b/main/manager-mobile/src/pages/settings/index.vue @@ -1,18 +1,21 @@ -{ + +{ "layout": "default", "style": { "navigationBarTitleText": "设置", "navigationStyle": "custom" } -} +} +