diff --git a/desktop/src/components/chat/OpenWithMenu.test.tsx b/desktop/src/components/chat/OpenWithMenu.test.tsx new file mode 100644 index 00000000..30f93c00 --- /dev/null +++ b/desktop/src/components/chat/OpenWithMenu.test.tsx @@ -0,0 +1,17 @@ +import '@testing-library/jest-dom' +import { fireEvent, render, screen } from '@testing-library/react' +import { describe, expect, it, vi } from 'vitest' +import { OpenWithMenu } from './OpenWithMenu' + +describe('OpenWithMenu', () => { + it('offers in-app and system browser choices', () => { + const onInApp = vi.fn(); const onSystem = vi.fn() + render() + fireEvent.click(screen.getByLabelText('打开方式')) + fireEvent.click(screen.getByText('应用内浏览器')) + expect(onInApp).toHaveBeenCalledWith('https://example.com') + fireEvent.click(screen.getByLabelText('打开方式')) + fireEvent.click(screen.getByText('系统浏览器')) + expect(onSystem).toHaveBeenCalledWith('https://example.com') + }) +}) diff --git a/desktop/src/components/chat/OpenWithMenu.tsx b/desktop/src/components/chat/OpenWithMenu.tsx new file mode 100644 index 00000000..d4b49c0e --- /dev/null +++ b/desktop/src/components/chat/OpenWithMenu.tsx @@ -0,0 +1,21 @@ +import { useState } from 'react' +import { ChevronDown } from 'lucide-react' + +type Props = { url: string; onOpenInApp: (url: string) => void; onOpenSystem: (url: string) => void } + +export function OpenWithMenu({ url, onOpenInApp, onOpenSystem }: Props) { + const [open, setOpen] = useState(false) + return ( + + + {open && ( +
+ + +
+ )} +
+ ) +}