wangzhibo
2026-08-30 c8515170fd399b4d2dfaebb59128d4674e58915e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { AgentFunction, PluginDefinition } from '@/api/agent/types'
import { defineStore } from 'pinia'
import { ref } from 'vue'
 
export const usePluginStore = defineStore(
  'plugin',
  () => {
    // 所有可用插件
    const allFunctions = ref<PluginDefinition[]>([])
 
    // 当前智能体的插件配置
    const currentFunctions = ref<AgentFunction[]>([])
 
    // 当前编辑的智能体ID
    const currentAgentId = ref('')
 
    // 设置所有可用插件
    const setAllFunctions = (functions: PluginDefinition[]) => {
      allFunctions.value = functions
    }
 
    // 设置当前智能体的插件配置
    const setCurrentFunctions = (functions: AgentFunction[]) => {
      currentFunctions.value = functions
    }
 
    // 设置当前智能体ID
    const setCurrentAgentId = (agentId: string) => {
      currentAgentId.value = agentId
    }
 
    // 更新插件配置(用于保存时调用)
    const updateFunctions = (functions: AgentFunction[]) => {
      currentFunctions.value = functions
    }
 
    // 清空数据
    const clear = () => {
      allFunctions.value = []
      currentFunctions.value = []
      currentAgentId.value = ''
    }
 
    return {
      allFunctions,
      currentFunctions,
      currentAgentId,
      setAllFunctions,
      setCurrentFunctions,
      setCurrentAgentId,
      updateFunctions,
      clear,
    }
  },
  {
    persist: false, // 不持久化,每次进入页面重新加载
  },
)