File tree Expand file tree Collapse file tree 5 files changed +88
-9
lines changed Expand file tree Collapse file tree 5 files changed +88
-9
lines changed Original file line number Diff line number Diff line change 1111 "markRead" : " Mark as read" ,
1212 "markUnread" : " Mark as unread" ,
1313 "refresh" : " Refresh" ,
14- "openExternal" : " Open in browser"
14+ "openExternal" : " Open in browser" ,
15+ "copy" : {
16+ "title" : " Copy url" ,
17+ "success" : " Copied"
18+ }
1519 },
1620
1721 "form" : {
Original file line number Diff line number Diff line change 1111 "markRead" : " 标记为已读" ,
1212 "markUnread" : " 标记为未读" ,
1313 "refresh" : " 刷新" ,
14- "openExternal" : " 在浏览器中打开"
14+ "openExternal" : " 在浏览器中打开" ,
15+ "copy" : {
16+ "title" : " 复制链接" ,
17+ "success" : " 已复制到剪贴板"
18+ }
1519 },
1620
1721 "form" : {
Original file line number Diff line number Diff line change 33import { observer } from 'mobx-react-lite'
44import { makeStyles , tokens } from '@fluentui/react-components'
55import { store } from '@/renderer/store'
6- import { DeleteButton } from '@/renderer/apps/reader/components/toolbar'
6+ import { DeleteButton , CopyButton } from '@/renderer/apps/reader/components/toolbar'
77import { Feed } from '@/types/reader'
88
99const { readerStore } = store
@@ -29,7 +29,12 @@ const useStyles = makeStyles({
2929} )
3030
3131function Item ( { data } : Props ) {
32- const { id, title, unreadCount = 0 } = data
32+ const {
33+ id,
34+ title,
35+ unreadCount = 0 ,
36+ url,
37+ } = data
3338 const active = readerStore . tab === id
3439 const styles = useStyles ( )
3540
@@ -63,11 +68,18 @@ function Item({ data }: Props) {
6368 </ div >
6469 < div className = "absolute top-0 right-0 hidden group-hover:block" >
6570 < div className = { styles . toolbar } >
66- < DeleteButton
67- className = "h-7"
68- fontSize = { 16 }
69- onClick = { deleteFeed }
70- />
71+ < div className = "flex" >
72+ < CopyButton
73+ className = "h-7 w-8"
74+ fontSize = { 16 }
75+ content = { url }
76+ />
77+ < DeleteButton
78+ className = "h-7 w-8"
79+ fontSize = { 16 }
80+ onClick = { deleteFeed }
81+ />
82+ </ div >
7183 </ div >
7284 </ div >
7385 </ div >
Original file line number Diff line number Diff line change 1+ import intl from 'react-intl-universal'
2+ import { CopyRegular } from '@fluentui/react-icons'
3+ import {
4+ useId ,
5+ useToastController ,
6+ Toast ,
7+ ToastIntent ,
8+ ToastTitle ,
9+ Toaster ,
10+ } from '@fluentui/react-components'
11+ import Button from './button'
12+
13+ type Props = {
14+ className : string
15+ fontSize : number
16+ content : string
17+ }
18+
19+ export default function CopyButton ( props : Props ) {
20+ const { className, fontSize = 18 , content } = props
21+
22+ const toasterId = useId ( 'toaster' )
23+ const { dispatchToast } = useToastController ( toasterId )
24+
25+ const notify = ( text : string , intent : ToastIntent ) => dispatchToast (
26+ < Toast >
27+ < ToastTitle >
28+ { text }
29+ </ ToastTitle >
30+ </ Toast > ,
31+ { intent } ,
32+ )
33+
34+ const onClick = async ( ) => {
35+ try {
36+ await navigator . clipboard . writeText ( content )
37+ notify ( intl . get ( 'reader.action.copy.success' ) , 'success' )
38+ } catch ( e ) {
39+ notify ( `${ ( e as Error ) . name } : ${ ( e as Error ) . message } ` , 'error' )
40+ }
41+ }
42+
43+ return (
44+ < >
45+ < Button
46+ icon = { CopyRegular }
47+ className = { className }
48+ fontSize = { fontSize }
49+ onClick = { onClick }
50+ tip = { intl . get ( 'reader.action.copy.title' ) }
51+ />
52+ < Toaster
53+ position = "top-end"
54+ toasterId = { toasterId }
55+ />
56+ </ >
57+ )
58+ }
Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ export { default as RefreshButton } from './refresh-button'
33export { default as DeleteButton } from './delete-button'
44export { default as MarkReadButton } from './mark-read-button'
55export { default as StarButton } from './star-button'
6+ export { default as CopyButton } from './copy-button'
You can’t perform that action at this time.
0 commit comments