wangzhibo
10 天以前 220e4fab27b7f419b3e89e2f2d28ae789aac09d7
xiaozhi-esp32-server/main/manager-mobile/src/pages/agent/index.vue
@@ -9,12 +9,13 @@
</route>
<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { onMounted, ref } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onMounted, ref, watch } from 'vue'
import CustomTabs from '@/components/custom-tabs/index.vue'
import { t } from '@/i18n'
import ChatHistory from '@/pages/chat-history/index.vue'
import DeviceManagement from '@/pages/device/index.vue'
import ParentTaskList from '@/pages/parent-task/index.vue'
import VoiceprintManagement from '@/pages/voiceprint/index.vue'
import AgentEdit from './edit.vue'
@@ -44,7 +45,7 @@
// #endif
// 智能体ID
const currentAgentId = ref('default')
const currentAgentId = ref('')
// 当前 tab
const currentTab = ref('agent-config')
@@ -57,6 +58,7 @@
const deviceRef = ref()
const chatRef = ref()
const voiceprintRef = ref()
const parentTaskRef = ref()
// 更新刷新器状态
function updateRefresherEnabled(value: boolean) {
@@ -88,6 +90,12 @@
    value: 'voiceprint-management',
    icon: '/static/tabbar/microphone.png',
    activeIcon: '/static/tabbar/microphone_activate.png',
  },
  {
    label: t('agent.parentTasks'),
    value: 'parent-tasks',
    icon: '/static/tabbar/system.png',
    activeIcon: '/static/tabbar/system_activate.png',
  },
]
@@ -127,6 +135,11 @@
          await voiceprintRef.value.refresh()
        }
        break
      case 'parent-tasks':
        if (parentTaskRef.value?.refresh) {
          await parentTaskRef.value.refresh()
        }
        break
    }
  }
  catch (error) {
@@ -154,6 +167,12 @@
  if (options?.agentId) {
    currentAgentId.value = options.agentId
    console.log('接收到智能体ID:', options.agentId)
  }
})
onShow(() => {
  if (currentTab.value === 'parent-tasks' && parentTaskRef.value?.refresh) {
    parentTaskRef.value.refresh()
  }
})
@@ -192,7 +211,7 @@
      <!-- Tab 内容 -->
      <view class="flex-1">
        <AgentEdit
          v-if="currentTab === 'agent-config'"
          v-if="currentTab === 'agent-config' && currentAgentId"
          :agent-id="currentAgentId"
        />
        <DeviceManagement
@@ -211,6 +230,12 @@
          :agent-id="currentAgentId"
          @update-refresher-enabled="updateRefresherEnabled"
        />
        <ParentTaskList
          v-else-if="currentTab === 'parent-tasks'"
          ref="parentTaskRef"
          embedded
          :agent-id="currentAgentId"
        />
      </view>
    </scroll-view>
  </view>