Explorar o código

♻️ refactor(contracts): update react-query mutation syntax

- 将createContract、updateContract和deleteContract的mutation调用方式从数组形式改为对象形式
- 使用mutationFn字段明确指定突变函数,提高代码可读性

🔧 chore(config): remove openapi mcp server configuration

- 清理.mcp.json文件中不再使用的openapi服务器配置
- 将mcpServers设置为空对象,减少不必要的配置项
yourname hai 8 meses
pai
achega
1569caaf93
Modificáronse 2 ficheiros con 29 adicións e 47 borrados
  1. 1 13
      .roo/mcp.json
  2. 28 34
      src/client/admin/pages/Contracts.tsx

+ 1 - 13
.roo/mcp.json

@@ -1,15 +1,3 @@
 {
-  "mcpServers": {
-    "openapi": {
-      "command": "npx",
-      "args": [
-        "-y",
-        "mcp-openapi-schema-explorer@latest",
-        "https://pre-136-107-template-6.r.d8d.fun/doc",
-        "--output-format",
-        "json"
-      ],
-      "env": {}
-    }
-  }
+  "mcpServers": {}
 }

+ 28 - 34
src/client/admin/pages/Contracts.tsx

@@ -106,58 +106,52 @@ const Contracts: React.FC = () => {
   };
   
   // 创建合同记录
-  const createContract = useMutation(
-    async (data: any) => {
+  const createContract = useMutation({
+    mutationFn: async (data: any) => {
       const response = await hetongClient.$post({ json: data });
       if (!response.ok) throw new Error('Failed to create contract');
       return response.json();
     },
-    {
-      onSuccess: () => {
-        message.success('合同记录创建成功');
-        queryClient.invalidateQueries({ queryKey: ['contracts'] });
-        setModalVisible(false);
-      },
-      onError: () => {
-        message.error('操作失败,请重试');
-      }
+    onSuccess: () => {
+      message.success('合同记录创建成功');
+      queryClient.invalidateQueries({ queryKey: ['contracts'] });
+      setModalVisible(false);
+    },
+    onError: () => {
+      message.error('操作失败,请重试');
     }
-  );
+  });
   
   // 更新合同记录
-  const updateContract = useMutation(
-    async ({ id, data }: { id: string; data: any }) => {
+  const updateContract = useMutation({
+    mutationFn: async ({ id, data }: { id: string; data: any }) => {
       const response = await hetongClient[':id'].$put({ param: { id: parseInt(id, 10) }, json: data });
       if (!response.ok) throw new Error('Failed to update contract');
       return response.json();
     },
-    {
-      onSuccess: () => {
-        message.success('合同记录更新成功');
-        queryClient.invalidateQueries({ queryKey: ['contracts'] });
-        setModalVisible(false);
-      },
-      onError: () => {
-        message.error('操作失败,请重试');
-      }
+    onSuccess: () => {
+      message.success('合同记录更新成功');
+      queryClient.invalidateQueries({ queryKey: ['contracts'] });
+      setModalVisible(false);
+    },
+    onError: () => {
+      message.error('操作失败,请重试');
     }
-  );
+  });
   
   // 删除合同记录
-  const deleteContract = useMutation(
-    async (id: string) => {
+  const deleteContract = useMutation({
+    mutationFn: async (id: string) => {
       const response = await hetongClient[':id'].$delete({ param: { id: parseInt(id, 10) } });
       if (!response.ok) throw new Error('Failed to delete contract');
       return response.json();
     },
-    {
-      onSuccess: () => {
-        message.success('合同记录删除成功');
-        queryClient.invalidateQueries({ queryKey: ['contracts'] });
-      },
-      onError: () => {
-        message.error('删除失败,请重试');
-      }
+    onSuccess: () => {
+      message.success('合同记录删除成功');
+      queryClient.invalidateQueries({ queryKey: ['contracts'] });
+    },
+    onError: () => {
+      message.error('删除失败,请重试');
     }
   );