Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions ui/src/views/system/resource-management/tool/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ onMounted(() => {
<template>
<MkViewLayout>
<template #default="{ Header, title }">
<component :is="Header"
><h4>{{ title }}</h4>
<MkComplexSearch :fields="searchFields" @change="handleSearchChange"
/></component>
<component :is="Header">
<h4>{{ title }}</h4>
<MkComplexSearch :fields="searchFields" @change="handleSearchChange" />
</component>
<MkTable
v-model:pagination-config="pagination"
v-loading="loading || operationLoading"
Expand All @@ -146,35 +146,34 @@ onMounted(() => {
resizable
>
<el-table-column prop="name" label="名称" min-width="220" show-overflow-tooltip>
<template #default="{ row }"
><div class="flex-align-center gap-2">
<ToolIcon :icon="row.icon" :type="row.tool_type" :size="20" class="shrink-0" /><span class="truncate" :title="row.name">{{
row.name
}}</span>
</div></template
>
<template #default="{ row }">
<div class="flex-align-center gap-2">
<ToolIcon :icon="row.icon" :type="row.tool_type" :size="20" class="shrink-0" />
<span class="truncate" :title="row.name">{{ row.name }}</span>
</div>
</template>
</el-table-column>
<el-table-column prop="tool_type" label="类型" width="120">
<template #default="{ row }">{{ toolTypeLabels.get(row.tool_type) ?? row.tool_type }}</template>
</el-table-column>
<el-table-column label="来源" width="120">
<template #default="{ row }">{{ row.template_id ? '工具商店' : '自定义' }}</template>
</el-table-column>
<el-table-column label="状态" width="120">
<template #default="{ row }"><MkStatusLabel :active="row.is_active" /></template>
</el-table-column>
<el-table-column prop="tool_type" label="类型" width="120"
><template #default="{ row }">{{ toolTypeLabels.get(row.tool_type) ?? row.tool_type }}</template></el-table-column
>
<el-table-column label="来源" width="120"
><template #default="{ row }">{{ row.template_id ? '工具商店' : '自定义' }}</template></el-table-column
>
<el-table-column label="状态" width="120"
><template #default="{ row }"><MkStatusLabel :active="row.is_active" /></template
></el-table-column>
<el-table-column v-if="auth.isEE" prop="workspace_name" label="工作空间" min-width="160" show-overflow-tooltip>
<template #header
><MkTableFilter v-model="selectedWorkspaceIds" label="工作空间" :options="workspaceOptions" @change="handleFilterChange"
/></template>
<template #header>
<MkTableFilter v-model="selectedWorkspaceIds" label="工作空间" :options="workspaceOptions" @change="handleFilterChange" />
</template>
</el-table-column>
<el-table-column prop="nick_name" label="创建者" min-width="120" show-overflow-tooltip />
<el-table-column label="更新时间" width="180"
><template #default="{ row }">{{ datetimeFormat(row.update_time) }}</template></el-table-column
>
<el-table-column label="创建时间" width="180"
><template #default="{ row }">{{ datetimeFormat(row.create_time) }}</template></el-table-column
>
<el-table-column label="更新时间" width="180">
<template #default="{ row }">{{ datetimeFormat(row.update_time) }}</template>
</el-table-column>
<el-table-column label="创建时间" width="180">
<template #default="{ row }">{{ datetimeFormat(row.create_time) }}</template>
</el-table-column>
<el-table-column label="操作" width="140" fixed="right">
<template #default="{ row }">
<div class="flex-align-center gap-1">
Expand All @@ -186,7 +185,8 @@ onMounted(() => {
<MkTableMoreDropdown persistent>
<!-- 打开工具工作流 -->
<MkDropdownItem v-if="row.tool_type === TOOL_TYPE.WORKFLOW" @click="handleOpenWorkflow(row, $event)">
<template #icon><MkIcon name="icon_setting" /></template>工作流
<template #icon><MkIcon name="icon_setting" /></template>
工作流
</MkDropdownItem>
<!-- 配置启动参数 -->
<InitParamAction
Expand All @@ -200,9 +200,6 @@ onMounted(() => {

<!-- 资源授权 -->
<AuthorizeToolAction label="资源授权" :tool="row" />

<!-- 导出工具 -->
<ExportToolAction v-if="!row.template_id" v-model:loading="operationLoading" label="导出" :api="SystemToolApi" :tool="row" />
<!-- 查看 MCP 配置 -->
<McpConfigAction
v-if="row.tool_type === TOOL_TYPE.MCP"
Expand All @@ -225,13 +222,16 @@ onMounted(() => {
<!-- 查看执行记录 -->
<ExecutionRecordToolAction
v-if="[TOOL_TYPE.CUSTOM, TOOL_TYPE.WORKFLOW].includes(row.tool_type)"
label="执行记录"
label="查看执行记录"
:api="SystemToolWorkflowApi"
:tool="row"
/>
<!-- 导出工具 -->
<ExportToolAction v-if="!row.template_id" v-model:loading="operationLoading" label="导出" :api="SystemToolApi" :tool="row" />
<!-- 删除工具 -->
<MkDropdownItem divided :disabled="operationLoading" @click="handleDeleteTool(row)">
<template #icon><MkIcon name="icon_delete-trash_outlined" /></template>删除
<template #icon><MkIcon name="icon_delete-trash_outlined" /></template>
删除
</MkDropdownItem>
</MkTableMoreDropdown>
</div>
Expand Down
1 change: 0 additions & 1 deletion ui/src/views/system/shared-resources/model/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ onMounted(() => {
<!-- 编辑 -->
<EditModelAction label="编辑" :api="SystemSharedModelApi" :model="model" :provider="getModelProvider(model)" @refresh="loadModels" />
<!-- // TODO 授权工作空间 -->

<!-- 模型参数设置 -->
<ParamSettingAction v-if="model.model_type !== 'RERANKER'" label="模型参数设置" :api="SystemSharedModelApi" :model="model" />

Expand Down
48 changes: 47 additions & 1 deletion ui/src/views/system/shared-resources/tool/index.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<script setup lang="ts">
import { computed, ref, useTemplateRef } from 'vue'
import { useRouter } from 'vue-router'
import SystemSharedRelatedResourcesApi from '@/api/admin/system/shared-resources/related-resources'
import SystemSharedToolApi from '@/api/admin/system/shared-resources/tool/tool'
import CommonSystemApi from '@/api/admin/system/common'
import SystemSharedToolWorkflowApi from '@/api/admin/system/shared-resources/tool/tool-workflow'
import type { ParamsPage } from '@/api/admin/core/types'
import type { Dict, OptionItem, ToolItem, ToolType } from '@/api/types'
import { TOOL_TYPE } from '@/api/enums'
import { TOOL_TYPE_OPTIONS } from '@/constants'
import ToolCard from '@/views/tool/tool-card/ToolCard.vue'
import ButtonCreateTool from '@/views/tool/components/ButtonCreateTool.vue'
import { DeleteToolAction, EditToolAction, ExportToolAction, InitParamAction, McpConfigAction } from '@/views/tool/tool-card/action-dropdown'
import {
RelatedResourcesToolAction,
DeleteToolAction,
EditToolAction,
ExportToolAction,
ExecutionRecordToolAction,
InitParamAction,
McpConfigAction,
CopyToolAction,
} from '@/views/tool/tool-card/action-dropdown'
import ButtonToolStore from '@/views/tool/components/ButtonToolStore.vue'

const router = useRouter()

Expand Down Expand Up @@ -63,6 +75,15 @@ function handleToolUpdate(tool: ToolItem) {
const toolIndex = toolsData.value.findIndex(({ id }) => id === tool.id)
if (toolIndex >= 0) toolsData.value.splice(toolIndex, 1, tool)
}

function handleOpenWorkflow(tool: ToolItem, event: MouseEvent) {
const target = { name: 'system-shared-workflow-tool', params: { toolId: tool.id } }
if (event.ctrlKey || event.metaKey) {
window.open(router.resolve(target).href)
return
}
return router.push(target)
}
</script>

<template>
Expand All @@ -78,6 +99,8 @@ function handleToolUpdate(tool: ToolItem) {
</div>
<div class="flex-align-center gap-3">
<MkComplexSearch :fields="searchFields" @change="handleSearchChange" />
<!-- 工具商店 -->
<ButtonToolStore folder-id="default" @refresh="refreshTools" />
<!-- 创建共享工具 -->
<ButtonCreateTool folder-id="default" :api="SystemSharedToolApi" @refresh="refreshTools" />
</div>
Expand Down Expand Up @@ -109,6 +132,19 @@ function handleToolUpdate(tool: ToolItem) {
:tool="tool"
@update="handleToolUpdate"
/>
<!-- 复制 -->
<CopyToolAction
v-model:loading="toolOperationLoading"
label="复制"
:api="SystemSharedToolApi"
:tool="tool"
@refresh="refreshTools"
/>
<!-- 工作流 -->
<MkDropdownItem v-if="tool.tool_type === TOOL_TYPE.WORKFLOW" @click="handleOpenWorkflow(tool, $event)">
<template #icon><MkIcon name="icon_setting" /></template>
工作流
</MkDropdownItem>
<!-- 配置启动参数 -->
<InitParamAction
v-if="(tool.init_field_list?.length ?? 0) > 0"
Expand All @@ -126,6 +162,16 @@ function handleToolUpdate(tool: ToolItem) {
:api="SystemSharedToolApi"
:tool="tool"
/>
<!-- 查看关联资源 -->
<RelatedResourcesToolAction label="查看关联资源" :api="SystemSharedRelatedResourcesApi" :tool="tool" />
<!-- 查看执行记录 -->
<ExecutionRecordToolAction
v-if="tool.tool_type === TOOL_TYPE.CUSTOM || tool.tool_type === TOOL_TYPE.WORKFLOW"
label="查看执行记录"
:api="SystemSharedToolWorkflowApi"
:tool="tool"
/>
<!-- TODO 授权工作空间 -->
<!-- 导出共享工具 -->
<ExportToolAction
v-if="!tool.template_id"
Expand Down
10 changes: 5 additions & 5 deletions ui/src/views/tool/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ onMounted(() => {
@update="handleToolUpdate"
>
<template #action-dropdown>
<ToolWorkflowAction v-if="tool.tool_type === TOOL_TYPE.WORKFLOW" label="工作流" :tool="tool" />
<!-- 编辑工具 -->
<EditToolAction
:ref="
Expand All @@ -278,6 +277,9 @@ onMounted(() => {
:tool="tool"
@update="handleToolUpdate"
/>
<ToolWorkflowAction v-if="tool.tool_type === TOOL_TYPE.WORKFLOW" label="工作流" :tool="tool" />
<!-- 复制 -->
<CopyToolAction v-model:loading="toolOperationLoading" label="复制" :api="ToolApi" :tool="tool" @refresh="refreshTool" />
<InitParamAction
v-if="(tool.init_field_list?.length ?? 0) > 0"
v-model:loading="toolOperationLoading"
Expand Down Expand Up @@ -313,8 +315,6 @@ onMounted(() => {
:api="WorkflowApi"
:tool="tool"
/>
<!-- 复制 -->
<CopyToolAction v-model:loading="toolOperationLoading" label="复制" :api="ToolApi" :tool="tool" @refresh="refreshTool" />
<!-- 移动到 -->
<MoveToolAction
v-model:loading="toolOperationLoading"
Expand Down Expand Up @@ -346,8 +346,8 @@ onMounted(() => {
@batch-cancel="cancelBatchSelection"
>
<template #footer-batch-actions>
<el-button type="primary" plain :disabled="!selectedToolCount" @click="handleOpenBatchMove"> 移动到 </el-button>
<el-button type="danger" plain :disabled="!selectedToolCount" @click="handleBatchDelete"> 删除 </el-button>
<el-button type="primary" plain :disabled="!selectedToolCount" @click="handleOpenBatchMove">移动到</el-button>
<el-button type="danger" plain :disabled="!selectedToolCount" @click="handleBatchDelete">删除</el-button>
</template>
</component>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { nextTick, ref, useTemplateRef } from 'vue'
import { cloneDeep } from 'lodash'
import type ToolApi from '@/api/admin/workspace/tool/tool'
import type SystemSharedToolApi from '@/api/admin/system/shared-resources/tool/tool'
import type { ToolItem } from '@/api/types'
import { TOOL_TYPE } from '@/api/enums'
import ToolFormDrawer from '@/views/tool/tool-form/tool-custom/ToolFormDrawer.vue'
Expand All @@ -12,7 +13,7 @@ import WorkflowFormDialog from '@/views/tool/tool-form/WorkflowFormDialog.vue'

defineOptions({ name: 'CopyToolAction' })

const props = defineProps<{ api: typeof ToolApi; label: string; tool: ToolItem }>()
const props = defineProps<{ api: typeof ToolApi | typeof SystemSharedToolApi; label: string; tool: ToolItem }>()

const loading = defineModel<boolean>('loading', { default: false })

Expand Down
Loading