File tree Expand file tree Collapse file tree 9 files changed +149
-23
lines changed Expand file tree Collapse file tree 9 files changed +149
-23
lines changed Original file line number Diff line number Diff line change 35
35
- [x] 分享动态
36
36
- [x] 点赞
37
37
- [x] 取消点赞
38
+ - 动态广场
39
+ - [x] 获取动态推荐
38
40
- 评论
39
41
- [x] 获取评论
40
42
- [x] 发送评论
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export const listPrimary = <T = Comments.ListPrimaryResponse>(
49
49
targetType,
50
50
targetId,
51
51
order : option . order ?? 'LIKES' ,
52
- limit : option . limit ,
52
+ limit : option . limit ?? 10 ,
53
53
loadMoreKey : option . loadMoreKey ,
54
54
} ,
55
55
} )
Original file line number Diff line number Diff line change 1
1
import * as users from './users'
2
2
import * as userRelation from './user-relation'
3
3
import * as posts from './posts'
4
+ import * as recommendFeed from './recommend-feed'
4
5
import * as personalUpdate from './personal-update'
5
6
import * as notifications from './notifications'
6
7
import * as comments from './comments'
@@ -11,6 +12,7 @@ import * as upload from './upload'
11
12
* - {@link api/users | `users`}: 用户
12
13
* - {@link api/user-relation | `userRelation`}: 用户关系
13
14
* - {@link api/posts | `posts`}: 动态
15
+ * - {@link api/recommend-feed | `recommendFeed`}: 动态
14
16
* - {@link api/personal-update | `personalUpdate`}: 主页
15
17
* - {@link api/notifications | `notifications`}: 通知
16
18
* - {@link api/comments | `comments`}: 评论
@@ -20,6 +22,7 @@ export const api = {
20
22
users,
21
23
userRelation,
22
24
posts,
25
+ recommendFeed,
23
26
personalUpdate,
24
27
notifications,
25
28
comments,
Original file line number Diff line number Diff line change
1
+ import { toResponse , request } from '../request'
2
+ import type { ListRecommendFeedOption } from '../types/options'
3
+ import type { RecommendFeed } from '../types/api-responses'
4
+
5
+ /**
6
+ * 获取动态广场
7
+ * @param option 选项
8
+ */
9
+ export const list = < T = RecommendFeed . ListResponse > (
10
+ option : ListRecommendFeedOption = { }
11
+ ) =>
12
+ toResponse < T > (
13
+ request . post ( '1.0/recommendFeed/list' , {
14
+ json : {
15
+ limit : option . limit ?? 10 ,
16
+ trigger : option . trigger ?? 'auto' ,
17
+ loadMoreKey : option . loadMoreKey ,
18
+ } ,
19
+ } )
20
+ )
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import type {
6
6
SimpleUser ,
7
7
TabIcons ,
8
8
User ,
9
+ RecommendPost ,
9
10
} from './entity'
10
11
11
12
export namespace Posts {
@@ -34,7 +35,7 @@ export namespace Notifications {
34
35
export namespace UserRelation {
35
36
export interface GetFollowingListResponse {
36
37
data : SimpleUser [ ]
37
- loadMoreKey : {
38
+ loadMoreKey ? : {
38
39
createdAt : string
39
40
}
40
41
}
@@ -111,7 +112,7 @@ export namespace Users {
111
112
export namespace PersonalUpdate {
112
113
export interface SingleResponse {
113
114
data : PostDetail [ ]
114
- loadMoreKey : {
115
+ loadMoreKey ? : {
115
116
lastId : string
116
117
}
117
118
}
@@ -125,7 +126,7 @@ export namespace Comments {
125
126
126
127
export interface ListPrimaryResponse {
127
128
data : Comment [ ]
128
- loadMoreKey : {
129
+ loadMoreKey ? : {
129
130
key : string
130
131
partition : string
131
132
}
@@ -137,3 +138,13 @@ export namespace Upload {
137
138
uptoken : string
138
139
}
139
140
}
141
+
142
+ export namespace RecommendFeed {
143
+ export interface ListResponse {
144
+ data : RecommendPost [ ]
145
+ toastMessage : string
146
+ loadMoreKey ?: {
147
+ page : number
148
+ }
149
+ }
150
+ }
Original file line number Diff line number Diff line change @@ -487,10 +487,7 @@ export interface LinkInfo {
487
487
source : string
488
488
}
489
489
490
- export interface ReadTrackInfo {
491
- recommendReason : string
492
- recommendReasonPolicy : string
493
- }
490
+ export type ReadTrackInfo = Record < string , any >
494
491
495
492
export interface ActionItem {
496
493
type : string
@@ -588,3 +585,52 @@ export interface Comment {
588
585
deletable : boolean
589
586
pinnable : boolean
590
587
}
588
+
589
+ export interface AdditionalInfo {
590
+ grayGroup : string
591
+ interestType : string
592
+ keywords : string
593
+ pictureClassifications : string
594
+ posterId : string
595
+ recallTag : string
596
+ recommendId : string
597
+ recommendTime : string
598
+ topicId : string
599
+ }
600
+
601
+ export interface Payload {
602
+ id : string
603
+ feedType : string
604
+ type : string
605
+ key : string
606
+ reason : string
607
+ readTrackInfo : ReadTrackInfo
608
+ }
609
+
610
+ export interface Reason {
611
+ key : string
612
+ text : string
613
+ payload : Payload
614
+ }
615
+
616
+ export interface DislikeMenu {
617
+ title : string
618
+ subtitle : string
619
+ reasons : Reason [ ]
620
+ }
621
+
622
+ export interface RecommendPost {
623
+ id : string
624
+ readTrackInfo : ReadTrackInfo
625
+ dislikeMenu : DislikeMenu
626
+ user : SimpleUser
627
+ topic : Topic
628
+ content : string
629
+ pictures : Picture [ ]
630
+ likeCount : number
631
+ commentCount : number
632
+ repostCount : number
633
+ shareCount : number
634
+ createdAt : Date
635
+ type : string
636
+ }
Original file line number Diff line number Diff line change 1
1
/**
2
- * 分页选项
2
+ * @description 分页选项
3
3
*/
4
- export interface PaginationOption < T = any > {
4
+ export interface PaginationOption < T = Record < string , any > > {
5
5
/**
6
- * 最大记录数
6
+ * @description 最大记录数
7
7
* @default 10
8
8
*/
9
9
limit ?: number
@@ -14,41 +14,50 @@ export interface PaginationOption<T = any> {
14
14
loadMoreKey ?: Partial < T >
15
15
}
16
16
17
+ /**
18
+ * @description 动态类型
19
+ */
17
20
export enum PostType {
18
- /** 动态 */
21
+ /** 原帖 */
19
22
ORIGINAL = 'originalPosts' ,
20
23
/** 转发 */
21
24
REPOST = 'reposts' ,
22
25
}
23
26
27
+ /**
28
+ * @description 发送动态选项
29
+ */
24
30
export interface CreatePostOption {
25
31
/**
26
- * 同步到个人主页
27
- * @default true
32
+ * @description 是否同步到个人主页
33
+ * @default ` true`
28
34
*/
29
35
syncToPersonalUpdates ?: boolean
30
36
/**
31
- * 图片 key 列表
32
- * @default []
37
+ * @description 图片 key 列表
38
+ * @default `[]`
33
39
*/
34
40
pictureKeys ?: string [ ]
35
41
36
42
/**
37
- * 圈子 ID
38
- * @default undefined
43
+ * @description 圈子 ID
44
+ * @default ` undefined`
39
45
*/
40
46
topicId ?: string
41
47
}
42
48
49
+ /**
50
+ * @description 发送评论选项
51
+ */
43
52
export interface AddCommentOption {
44
53
/**
45
- * 同步到个人主页
46
- * @default false
54
+ * @description 同步到个人主页
55
+ * @default ` false`
47
56
*/
48
57
syncToPersonalUpdates ?: boolean
49
58
/**
50
- * 图片 key 列表
51
- * @default []
59
+ * @description 图片 key 列表
60
+ * @default `[]`
52
61
*/
53
62
pictureKeys ?: string [ ]
54
63
}
@@ -57,6 +66,26 @@ export interface ListCommentMoreKey {
57
66
key : string
58
67
partition : string
59
68
}
60
- export type ListCommentOption = PaginationOption < ListCommentMoreKey > & {
69
+ /**
70
+ * @description 获取评论选项
71
+ */
72
+ export interface ListCommentOption
73
+ extends PaginationOption < ListCommentMoreKey > {
74
+ /**
75
+ * 排序
76
+ * @default `LIKES`
77
+ */
61
78
order ?: 'LIKES' | 'TIME'
62
79
}
80
+
81
+ /**
82
+ * @description 获取动态广场选项
83
+ */
84
+ export interface ListRecommendFeedOption
85
+ extends PaginationOption < { page : number } > {
86
+ /**
87
+ * @description 触发方式
88
+ * @default `auto`
89
+ */
90
+ trigger ?: string
91
+ }
Original file line number Diff line number Diff line change
1
+ import { describe , it , expect } from 'vitest'
2
+ import { setApiConfig , api } from '../../src'
3
+ import { config } from '../config'
4
+
5
+ setApiConfig ( config )
6
+
7
+ describe ( 'comment should work' , ( ) => {
8
+ it ( 'list should work' , async ( ) => {
9
+ const result = await api . recommendFeed . list ( )
10
+ expect ( result . status ) . toBe ( 200 )
11
+ expect ( result . data . success ) . toBe ( true )
12
+ expect ( result . data . data . length ) . greaterThan ( 0 )
13
+ } )
14
+ } )
Original file line number Diff line number Diff line change 4
4
" src/api/notifications.ts" ,
5
5
" src/api/personal-update.ts" ,
6
6
" src/api/posts.ts" ,
7
+ " src/api/recommend-feed.ts" ,
7
8
" src/api/user-relation.ts" ,
8
9
" src/api/users.ts" ,
9
10
" src/api/comments.ts" ,
You can’t perform that action at this time.
0 commit comments