mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-23 15:43:54 +08:00
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
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, // 不持久化,每次进入页面重新加载
|
|
},
|
|
)
|