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 11
11
"markRead" : " Mark as read" ,
12
12
"markUnread" : " Mark as unread" ,
13
13
"refresh" : " Refresh" ,
14
- "openExternal" : " Open in browser"
14
+ "openExternal" : " Open in browser" ,
15
+ "copy" : {
16
+ "title" : " Copy url" ,
17
+ "success" : " Copied"
18
+ }
15
19
},
16
20
17
21
"form" : {
Original file line number Diff line number Diff line change 11
11
"markRead" : " 标记为已读" ,
12
12
"markUnread" : " 标记为未读" ,
13
13
"refresh" : " 刷新" ,
14
- "openExternal" : " 在浏览器中打开"
14
+ "openExternal" : " 在浏览器中打开" ,
15
+ "copy" : {
16
+ "title" : " 复制链接" ,
17
+ "success" : " 已复制到剪贴板"
18
+ }
15
19
},
16
20
17
21
"form" : {
Original file line number Diff line number Diff line change 3
3
import { observer } from 'mobx-react-lite'
4
4
import { makeStyles , tokens } from '@fluentui/react-components'
5
5
import { store } from '@/renderer/store'
6
- import { DeleteButton } from '@/renderer/apps/reader/components/toolbar'
6
+ import { DeleteButton , CopyButton } from '@/renderer/apps/reader/components/toolbar'
7
7
import { Feed } from '@/types/reader'
8
8
9
9
const { readerStore } = store
@@ -29,7 +29,12 @@ const useStyles = makeStyles({
29
29
} )
30
30
31
31
function Item ( { data } : Props ) {
32
- const { id, title, unreadCount = 0 } = data
32
+ const {
33
+ id,
34
+ title,
35
+ unreadCount = 0 ,
36
+ url,
37
+ } = data
33
38
const active = readerStore . tab === id
34
39
const styles = useStyles ( )
35
40
@@ -63,11 +68,18 @@ function Item({ data }: Props) {
63
68
</ div >
64
69
< div className = "absolute top-0 right-0 hidden group-hover:block" >
65
70
< 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 >
71
83
</ div >
72
84
</ div >
73
85
</ 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'
3
3
export { default as DeleteButton } from './delete-button'
4
4
export { default as MarkReadButton } from './mark-read-button'
5
5
export { 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