Skip to content

Commit 3729be6

Browse files
committed
fix: 修复任务详情弹窗中复制按钮点击失效问题
问题描述: - 任务详情弹窗中的复制下载链接、复制保存路径、复制文件路径按钮点击无响应 - 复制功能被对话框的事件处理拦截 修复方案: - 在 handleCopy 函数中添加事件参数,调用 preventDefault 和 stopPropagation 阻止事件冒泡 - 更新所有复制按钮的 onClick 事件处理器,传递事件对象确保复制功能正常工作 影响范围: - frontend/src/components/TaskDetailDialog.tsx
1 parent 632a856 commit 3729be6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

frontend/src/components/TaskDetailDialog.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ export default function TaskDetailDialog({
6666

6767
if (!task) return null
6868

69-
const handleCopy = async (text: string) => {
69+
const handleCopy = async (text: string, e?: React.MouseEvent) => {
70+
if (e) {
71+
e.preventDefault()
72+
e.stopPropagation()
73+
}
7074
const success = await copyToClipboard(text)
7175
if (success) {
7276
toast.success('已复制到剪贴板')
@@ -127,7 +131,7 @@ export default function TaskDetailDialog({
127131
<Button
128132
variant="ghost"
129133
size="sm"
130-
onClick={() => handleCopy(task.url)}
134+
onClick={(e) => handleCopy(task.url, e)}
131135
>
132136
<Copy className="h-4 w-4" />
133137
</Button>
@@ -151,7 +155,7 @@ export default function TaskDetailDialog({
151155
<Button
152156
variant="ghost"
153157
size="sm"
154-
onClick={() => handleCopy(task.file_path || '')}
158+
onClick={(e) => handleCopy(task.file_path || '', e)}
155159
title="复制文件路径"
156160
>
157161
<Copy className="h-4 w-4" />
@@ -220,7 +224,7 @@ export default function TaskDetailDialog({
220224
<Button
221225
variant="ghost"
222226
size="sm"
223-
onClick={() => handleCopy(file.path)}
227+
onClick={(e) => handleCopy(file.path, e)}
224228
className="flex-shrink-0"
225229
>
226230
<Copy className="h-3 w-3" />

0 commit comments

Comments
 (0)