From 8a109f9fa2743459b27aa1aefc00b738c7f1d896 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Sun, 18 Jan 2026 04:53:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86=E5=87=BD=E6=95=B0=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新事件处理函数类型以使用更精确的类型定义,提升代码可读性和类型安全性。 --- src/routes/todos.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/todos.tsx b/src/routes/todos.tsx index d446441..6414551 100644 --- a/src/routes/todos.tsx +++ b/src/routes/todos.tsx @@ -1,6 +1,6 @@ import { useMutation, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' -import type { ChangeEvent, FormEvent } from 'react' +import type { ChangeEventHandler, FormEventHandler } from 'react' import { useState } from 'react' import { orpc } from '@/orpc' @@ -19,7 +19,7 @@ function Todos() { const updateMutation = useMutation(orpc.todo.update.mutationOptions()) const deleteMutation = useMutation(orpc.todo.remove.mutationOptions()) - const handleCreateTodo = (e: FormEvent) => { + const handleCreateTodo: FormEventHandler = (e) => { e.preventDefault() if (newTodoTitle.trim()) { createMutation.mutate({ title: newTodoTitle.trim() }) @@ -27,7 +27,7 @@ function Todos() { } } - const handleInputChange = (e: ChangeEvent) => { + const handleInputChange: ChangeEventHandler = (e) => { setNewTodoTitle(e.target.value) }