“停用”是全局紧急开关,生效后任何 Token 都无法调用该工具。
diff --git a/xiaoqu-agent-service/front/src/App.vue b/xiaoqu-agent-service/front/src/App.vue index 4ca28d8..f17dbe0 100644 --- a/xiaoqu-agent-service/front/src/App.vue +++ b/xiaoqu-agent-service/front/src/App.vue @@ -24,8 +24,10 @@ const tokens = ref([]) const openClients = ref([]) const scopes = ref([]) const tools = ref([]) +const allTools = ref([]) const audits = ref([]) const toolFilter = reactive({ category: '', kind: '', keyword: '' }) +const toolPage = reactive({ page: 1, pageSize: 20, total: 0 }) const auditFilter = reactive({ person: '', tokenPrefix: '', tool: '', result: '', client: '', from: '', to: '' }) const tokenDialog = ref(false) const tokenForm = reactive({ id: null, memo: '', scopeIds: [], scopeId: null, expireTime: null }) @@ -40,8 +42,8 @@ const activeScope = ref(null) const selectedToolIds = ref([]) const title = computed(() => menus.find(item => item.id === current.value)?.label || '') -const categories = computed(() => [...new Set(tools.value.map(tool => tool.category))]) -const groupedTools = computed(() => tools.value.reduce((groups, tool) => { +const categories = computed(() => [...new Set(allTools.value.map(tool => tool.category))]) +const groupedTools = computed(() => allTools.value.reduce((groups, tool) => { const category = tool.category || '其他' ;(groups[category] ||= []).push(tool) return groups @@ -96,9 +98,9 @@ async function switchMenu(id) { current.value = id if (id === 'tokens') await loadUsers() if (id === 'clients') await loadOpenClients() - if (id === 'tools') await loadTools() + if (id === 'tools') await Promise.all([loadTools(), loadAllTools()]) if (id === 'scopes') await loadScopes() - if (id === 'audit') await Promise.all([loadAudit(), api('/tools').then(data => { tools.value = data })]) + if (id === 'audit') await Promise.all([loadAudit(), loadAllTools()]) } async function loadUsers(resetPage = false) { @@ -214,8 +216,21 @@ async function rotateClient(client) { }).catch(() => {}) } -async function loadTools() { - tools.value = await api(`/tools${qs(toolFilter)}`) +async function loadTools(resetPage = false) { + if (resetPage) toolPage.page = 1 + const data = await api(`/tools${qs({ ...toolFilter, page: toolPage.page, pageSize: toolPage.pageSize })}`) + tools.value = data.records + toolPage.total = data.total +} + +async function loadAllTools() { + const data = await api('/tools?pageSize=0') + allTools.value = data.records +} + +async function changeToolPage(page) { + toolPage.page = page + await run(loadTools) } async function setToolStatus(tool) { @@ -261,7 +276,7 @@ async function deleteScope(scope) { async function openScopeTools(scope) { activeScope.value = scope - ;[selectedToolIds.value, tools.value] = await Promise.all([api(`/scopes/${scope.id}/tools`), api('/tools')]) + ;[selectedToolIds.value] = await Promise.all([api(`/scopes/${scope.id}/tools`), loadAllTools()]) scopeToolsDialog.value = true } @@ -411,8 +426,8 @@ onMounted(async () => {
“停用”是全局紧急开关,生效后任何 Token 都无法调用该工具。