Update tool panel and db
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Search, Filter, Plus, Wrench, Terminal, Globe, Camera, CameraOff, Image, Images, CloudSun, Calendar, TrendingUp, Coins, Trash2, Edit2, Box, Lock } from 'lucide-react';
|
||||
import { Search, Filter, Plus, Wrench, Terminal, Globe, Camera, CameraOff, Image, Images, CloudSun, Calendar, TrendingUp, Coins, Trash2, Edit2, Box } from 'lucide-react';
|
||||
import { Button, Input, Badge, Dialog } from '../components/UI';
|
||||
import { Tool } from '../types';
|
||||
import { createTool, deleteTool, fetchTools, updateTool } from '../services/backendApi';
|
||||
@@ -117,10 +117,6 @@ export const ToolLibraryPage: React.FC = () => {
|
||||
|
||||
const handleDeleteTool = async (e: React.MouseEvent, tool: Tool) => {
|
||||
e.stopPropagation();
|
||||
if (tool.isSystem) {
|
||||
alert('系统工具不可删除');
|
||||
return;
|
||||
}
|
||||
if (!confirm('确认删除该工具吗?')) return;
|
||||
|
||||
try {
|
||||
@@ -177,11 +173,7 @@ export const ToolLibraryPage: React.FC = () => {
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center justify-between mb-1 gap-2">
|
||||
<span className="text-base font-bold text-white truncate">{tool.name}</span>
|
||||
{tool.isSystem ? (
|
||||
<Badge variant="outline" className="text-[9px] h-4 px-1">SYSTEM</Badge>
|
||||
) : (
|
||||
<Badge variant="outline" className="text-[9px] h-4 px-1">CUSTOM</Badge>
|
||||
)}
|
||||
{tool.isSystem ? <Badge variant="outline" className="text-[9px] h-4 px-1">SYSTEM</Badge> : <Badge variant="outline" className="text-[9px] h-4 px-1">CUSTOM</Badge>}
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge variant="outline" className={`text-[10px] border-0 px-0 ${tool.category === 'system' ? 'text-primary' : 'text-blue-400'}`}>
|
||||
@@ -194,38 +186,22 @@ export const ToolLibraryPage: React.FC = () => {
|
||||
</div>
|
||||
|
||||
<div className="mt-4 pt-3 border-t border-white/10 flex items-center justify-between">
|
||||
{tool.isSystem ? (
|
||||
<span className="inline-flex items-center text-[11px] text-muted-foreground">
|
||||
<Lock className="w-3 h-3 mr-1.5" /> 系统工具只读
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-[11px] text-muted-foreground">可编辑自定义工具</span>
|
||||
)}
|
||||
<span className="text-[11px] text-muted-foreground">system/query 仅表示执行类型</span>
|
||||
<div className="flex space-x-1">
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (!tool.isSystem) openEdit(tool);
|
||||
openEdit(tool);
|
||||
}}
|
||||
disabled={tool.isSystem}
|
||||
title={tool.isSystem ? '系统工具不可编辑' : '编辑工具'}
|
||||
className={`p-1.5 rounded-md transition-colors ${
|
||||
tool.isSystem
|
||||
? 'text-muted-foreground/40 cursor-not-allowed'
|
||||
: 'hover:bg-primary/20 text-muted-foreground hover:text-primary'
|
||||
}`}
|
||||
title="编辑工具"
|
||||
className="p-1.5 rounded-md transition-colors hover:bg-primary/20 text-muted-foreground hover:text-primary"
|
||||
>
|
||||
<Edit2 className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => handleDeleteTool(e, tool)}
|
||||
disabled={tool.isSystem}
|
||||
title={tool.isSystem ? '系统工具不可删除' : '删除工具'}
|
||||
className={`p-1.5 rounded-md transition-colors ${
|
||||
tool.isSystem
|
||||
? 'text-muted-foreground/40 cursor-not-allowed'
|
||||
: 'hover:bg-destructive/20 text-muted-foreground hover:text-destructive'
|
||||
}`}
|
||||
title="删除工具"
|
||||
className="p-1.5 rounded-md transition-colors hover:bg-destructive/20 text-muted-foreground hover:text-destructive"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user