File tree Expand file tree Collapse file tree 8 files changed +109
-2
lines changed Expand file tree Collapse file tree 8 files changed +109
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import * as comments from './comments'
8
8
import * as upload from './upload'
9
9
import * as stories from './stories'
10
10
import * as mediaMeta from './media-meta'
11
+ import * as topic from './topic'
11
12
12
13
/**
13
14
* API
@@ -20,6 +21,7 @@ import * as mediaMeta from './media-meta'
20
21
* - {@link api/comments | `comments`}: 评论
21
22
* - {@link api/upload | `upload`}: 上传
22
23
* - {@link api/stories | `stories`}: 日记
24
+ * - {@link api/topic | `topic`}: 圈子
23
25
*/
24
26
export const api = {
25
27
users,
@@ -32,6 +34,7 @@ export const api = {
32
34
upload,
33
35
stories,
34
36
mediaMeta,
37
+ topic,
35
38
}
36
39
/**
37
40
* API 集合
Original file line number Diff line number Diff line change
1
+ import { request , toResponse } from '../request'
2
+ import type { Topic } from '../types/api-responses'
3
+ import type { PaginationOption } from '../types/options'
4
+
5
+ /**
6
+ * 获取圈子动态
7
+ * @param topicId 圈子 id
8
+ * @param option 选项
9
+ */
10
+ export const getTabsSquareFeed = < T = Topic . GetTabsSquareFeedResponse > (
11
+ topicId : string ,
12
+ // NOTE: suppressed 应该传 false,但不知道这个参数是什么意思
13
+ option : PaginationOption < { lastId : string ; suppressed : boolean } > = { }
14
+ ) =>
15
+ toResponse < T > (
16
+ request . post ( '1.0/topics/tabs/square/feed' , {
17
+ json : {
18
+ topicId,
19
+ limit : option . limit ?? 10 ,
20
+ loadMoreKey : option . loadMoreKey ,
21
+ } ,
22
+ } )
23
+ )
24
+
25
+ /**
26
+ * 获取圈子热门动态
27
+ * @param topicId 圈子 id
28
+ * @param option 选项
29
+ */
30
+ export const getTabsSelectedFeed = < T = Topic . GetTabsSelectedFeedResponse > (
31
+ topicId : string ,
32
+ option : PaginationOption < { offset : number } > = { }
33
+ ) =>
34
+ toResponse < T > (
35
+ request . post ( '1.0/topics/tabs/selected/feed' , {
36
+ json : {
37
+ topicId,
38
+ limit : option . limit ?? 10 ,
39
+ loadMoreKey : option . loadMoreKey ,
40
+ } ,
41
+ } )
42
+ )
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import type {
9
9
PersonalPost ,
10
10
Profile as ProfileEntity ,
11
11
RecommendPost ,
12
+ SquareFeed ,
12
13
Story ,
13
14
TabIcons ,
14
15
User ,
@@ -209,3 +210,22 @@ export namespace Stories {
209
210
export interface InteractiveResponse {
210
211
url : string
211
212
}
213
+
214
+ export namespace Topic {
215
+ // 圈子动态
216
+ export interface GetTabsSquareFeedResponse {
217
+ data : SquareFeed [ ]
218
+ loadMoreKey ?: {
219
+ lastId : string
220
+ suppressed : boolean
221
+ }
222
+ }
223
+
224
+ // 圈子热门动态
225
+ export interface GetTabsSelectedFeedResponse {
226
+ data : SquareFeed [ ]
227
+ loadMoreKey ?: {
228
+ offset : number
229
+ }
230
+ }
231
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ export interface CommonImage {
9
9
format : LiteralUnion < 'jpeg' | 'heic' | 'png' >
10
10
}
11
11
12
+ // 地图 POI
13
+ export interface Poi {
14
+ poiId : string // id
15
+ name : string
16
+ location : number [ ] // 经纬度
17
+ countryname : string // 国家
18
+ pname : string // 省份
19
+ cityname : string // 城市
20
+ formattedAddress : string
21
+ }
22
+
12
23
export type Ref =
13
24
| ''
14
25
| 'FOLLOWINGS_FEED_FOLLOW_SECTION'
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ export * from './profile'
6
6
export * from './topic'
7
7
export * from './user'
8
8
export * from './story'
9
+ export * from './topic'
Original file line number Diff line number Diff line change 1
1
import type { LiteralUnion } from '../../utils'
2
- import type { CommonImage , Ref } from './common'
2
+ import type { CommonImage , Poi , Ref } from './common'
3
+ import type { OriginalPost } from './post'
3
4
4
5
export interface Topic {
5
6
type : 'TOPIC'
@@ -76,3 +77,9 @@ export interface SquarePicture extends CommonImage {
76
77
livePhoto : any
77
78
themes : any
78
79
}
80
+
81
+ export interface SquareFeed extends OriginalPost {
82
+ poi ?: Poi
83
+ isSuppressed : boolean
84
+ subtitle : string
85
+ }
Original file line number Diff line number Diff line change
1
+ import { describe , expect , it } from 'vitest'
2
+ import { api , isSuccess , setApiConfig } from '../../src'
3
+ import { config } from '../config'
4
+
5
+ describe ( 'topic should work' , ( ) => {
6
+ setApiConfig ( config )
7
+
8
+ const topicId = '562dfeb0daf87d13002cad92' // 深圳吃喝玩乐圈子
9
+ const limit = 10
10
+
11
+ it ( 'getTabsSquareFeed should work' , async ( ) => {
12
+ const result = await api . topic . getTabsSquareFeed ( topicId , { limit } )
13
+ expect ( isSuccess ( result ) ) . toBe ( true )
14
+ expect ( result . data . data . length ) . toBe ( limit )
15
+ } )
16
+
17
+ it ( 'getTabsSelectedFeed should work' , async ( ) => {
18
+ const result = await api . topic . getTabsSelectedFeed ( topicId , { limit } )
19
+ expect ( isSuccess ( result ) ) . toBe ( true )
20
+ expect ( result . data . data . length ) . toBe ( limit )
21
+ } )
22
+ } )
Original file line number Diff line number Diff line change 10
10
" src/api/comments.ts" ,
11
11
" src/api/upload.ts" ,
12
12
" src/api/stories.ts" ,
13
- " src/api/media-meta.ts"
13
+ " src/api/media-meta.ts" ,
14
+ " src/api/topic.ts"
14
15
],
15
16
"out" : " docs" ,
16
17
"name" : " Ⓙ Jike SDK" ,
You can’t perform that action at this time.
0 commit comments