1
- import { Action , ActionPanel , Icon , List , Toast , showToast } from '@raycast/api'
1
+ import {
2
+ Action ,
3
+ ActionPanel ,
4
+ Icon ,
5
+ List ,
6
+ Toast ,
7
+ open ,
8
+ showToast ,
9
+ } from '@raycast/api'
2
10
import { ApiOptions , JikePostWithDetail , limit } from 'jike-sdk'
3
11
import { createContext , useContext , useEffect , useMemo , useState } from 'react'
4
12
import { useUser } from '../hooks/user'
@@ -200,15 +208,22 @@ const UserInteract = ({
200
208
)
201
209
202
210
const OriginalPost = ( { post } : { post : JikePostWithDetail } ) => {
203
- const [ detail , setDetail ] = useState ( post . detail )
211
+ // TODO: repost
212
+ const [ detail , setDetail ] = useState ( post . detail as Entity . OriginalPost )
204
213
const markdown = useMemo (
205
214
( ) => `${ detail . content
206
215
. replaceAll ( '\n' , '\n\n' )
207
216
. replaceAll ( / ( [ ! # ( ) * + . [ \\ \] _ ` { } - ] ) / g, `\\$1` ) }
208
217
209
218
${ detail . pictures
210
219
?. map ( ( picture : Entity . Picture ) => `` )
211
- . join ( '\n\n' ) } `,
220
+ . join ( '\n\n' ) }
221
+
222
+ ${
223
+ detail . linkInfo
224
+ ? `[ <img height="16" src="${ detail . linkInfo . pictureUrl } "/> ${ detail . linkInfo . title } ](${ detail . linkInfo . linkUrl } )`
225
+ : ''
226
+ } `,
212
227
[ detail . content , detail . pictures ]
213
228
)
214
229
@@ -233,6 +248,11 @@ ${detail.pictures
233
248
return false
234
249
}
235
250
}
251
+ const openImage = async ( ) => {
252
+ for ( const pic of detail . pictures ?? [ ] ) {
253
+ await open ( pic . picUrl )
254
+ }
255
+ }
236
256
237
257
return (
238
258
< List . Item
@@ -246,6 +266,14 @@ ${detail.pictures
246
266
) : (
247
267
< LikePost onAction = { onAction ( 'like' ) } />
248
268
) }
269
+ { ( detail . pictures ?? [ ] ) . length > 0 && (
270
+ < Action
271
+ title = "打开图片"
272
+ icon = { Icon . Document }
273
+ shortcut = { { modifiers : [ 'cmd' , 'shift' ] , key : 'o' } }
274
+ onAction = { openImage }
275
+ />
276
+ ) }
249
277
< OpenPost type = { ApiOptions . PostType . ORIGINAL } id = { post . id } />
250
278
< Pager />
251
279
< CopyUpdate object = { detail } />
0 commit comments