@@ -10,6 +10,15 @@ import {
1010 DialogTitle ,
1111 DialogTrigger ,
1212} from "@/components/ui/dialog"
13+ import {
14+ Drawer ,
15+ DrawerContent ,
16+ DrawerDescription ,
17+ DrawerFooter ,
18+ DrawerHeader ,
19+ DrawerTitle ,
20+ DrawerTrigger ,
21+ } from "@/components/ui/drawer"
1322import { Input } from "@/components/ui/input"
1423import { insertMark } from "@/db/marks"
1524import useMarkStore from "@/stores/mark"
@@ -21,13 +30,16 @@ import { v4 as uuidv4 } from 'uuid'
2130import emitter from '@/lib/emitter'
2231import { useRouter } from 'next/navigation'
2332import { handleRecordComplete } from '@/lib/record-navigation'
33+ import { useIsMobile } from '@/hooks/use-mobile'
34+ import { isMobileDevice as checkIsMobileDevice } from '@/lib/check'
2435
2536export function ControlLink ( ) {
2637 const t = useTranslations ( ) ;
2738 const router = useRouter ( ) ;
2839 const [ open , setOpen ] = useState ( false ) ;
2940 const [ url , setUrl ] = useState ( '' )
3041 const [ loading , setLoading ] = useState ( false )
42+ const isMobile = useIsMobile ( ) || checkIsMobileDevice ( )
3143
3244 const { currentTagId, fetchTags, getCurrentTag } = useTagStore ( )
3345 const { fetchMarks, addQueue, setQueue, removeQueue } = useMarkStore ( )
@@ -186,36 +198,74 @@ export function ControlLink() {
186198 }
187199
188200 return (
189- < Dialog open = { open } onOpenChange = { setOpen } >
190- < DialogTrigger asChild >
191- < TooltipButton icon = { < Link /> } tooltipText = { t ( 'record.mark.type.link' ) || '链接' } />
192- </ DialogTrigger >
193- < DialogContent className = "min-w-full md:min-w-[500px]" >
194- < DialogHeader >
195- < DialogTitle > { t ( 'record.mark.link.title' ) || '链接记录' } </ DialogTitle >
196- < DialogDescription >
197- { t ( 'record.mark.link.description' ) || '输入网页链接,系统将自动爬取页面内容并保存' }
198- </ DialogDescription >
199- </ DialogHeader >
200- < Input
201- placeholder = "https://example.com"
202- value = { url }
203- onChange = { ( e ) => setUrl ( e . target . value ) }
204- disabled = { loading }
205- />
206- < DialogFooter className = "flex items-center justify-between" >
207- < p className = "text-sm text-zinc-500 mr-4" >
208- { loading ? '正在爬取页面内容...' : '' }
209- </ p >
210- < Button
211- type = "submit"
212- onClick = { handleSuccess }
213- disabled = { ! url || loading }
214- >
215- { loading ? '处理中...' : ( t ( 'record.mark.link.save' ) || '保存' ) }
216- </ Button >
217- </ DialogFooter >
218- </ DialogContent >
219- </ Dialog >
201+ < >
202+ { isMobile ? (
203+ < Drawer open = { open } onOpenChange = { setOpen } >
204+ < DrawerTrigger asChild >
205+ < TooltipButton icon = { < Link /> } tooltipText = { t ( 'record.mark.type.link' ) || '链接' } />
206+ </ DrawerTrigger >
207+ < DrawerContent >
208+ < DrawerHeader >
209+ < DrawerTitle > { t ( 'record.mark.link.title' ) || '链接记录' } </ DrawerTitle >
210+ < DrawerDescription >
211+ { t ( 'record.mark.link.description' ) || '输入网页链接,系统将自动爬取页面内容并保存' }
212+ </ DrawerDescription >
213+ </ DrawerHeader >
214+ < div className = "px-4" >
215+ < Input
216+ placeholder = "https://example.com"
217+ value = { url }
218+ onChange = { ( e ) => setUrl ( e . target . value ) }
219+ disabled = { loading }
220+ />
221+ </ div >
222+ < DrawerFooter className = "flex items-center justify-between" >
223+ < p className = "text-sm text-zinc-500 mr-4" >
224+ { loading ? '正在爬取页面内容...' : '' }
225+ </ p >
226+ < Button
227+ type = "submit"
228+ onClick = { handleSuccess }
229+ disabled = { ! url || loading }
230+ >
231+ { loading ? '处理中...' : ( t ( 'record.mark.link.save' ) || '保存' ) }
232+ </ Button >
233+ </ DrawerFooter >
234+ </ DrawerContent >
235+ </ Drawer >
236+ ) : (
237+ < Dialog open = { open } onOpenChange = { setOpen } >
238+ < DialogTrigger asChild >
239+ < TooltipButton icon = { < Link /> } tooltipText = { t ( 'record.mark.type.link' ) || '链接' } />
240+ </ DialogTrigger >
241+ < DialogContent className = "min-w-full md:min-w-[500px]" >
242+ < DialogHeader >
243+ < DialogTitle > { t ( 'record.mark.link.title' ) || '链接记录' } </ DialogTitle >
244+ < DialogDescription >
245+ { t ( 'record.mark.link.description' ) || '输入网页链接,系统将自动爬取页面内容并保存' }
246+ </ DialogDescription >
247+ </ DialogHeader >
248+ < Input
249+ placeholder = "https://example.com"
250+ value = { url }
251+ onChange = { ( e ) => setUrl ( e . target . value ) }
252+ disabled = { loading }
253+ />
254+ < DialogFooter className = "flex items-center justify-between" >
255+ < p className = "text-sm text-zinc-500 mr-4" >
256+ { loading ? '正在爬取页面内容...' : '' }
257+ </ p >
258+ < Button
259+ type = "submit"
260+ onClick = { handleSuccess }
261+ disabled = { ! url || loading }
262+ >
263+ { loading ? '处理中...' : ( t ( 'record.mark.link.save' ) || '保存' ) }
264+ </ Button >
265+ </ DialogFooter >
266+ </ DialogContent >
267+ </ Dialog >
268+ ) }
269+ </ >
220270 )
221271}
0 commit comments