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 3535 - [x] 分享动态
3636 - [x] 点赞
3737 - [x] 取消点赞
38+ - 动态广场
39+ - [x] 获取动态推荐
3840- 评论
3941 - [x] 获取评论
4042 - [x] 发送评论
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export const listPrimary = <T = Comments.ListPrimaryResponse>(
4949 targetType,
5050 targetId,
5151 order : option . order ?? 'LIKES' ,
52- limit : option . limit ,
52+ limit : option . limit ?? 10 ,
5353 loadMoreKey : option . loadMoreKey ,
5454 } ,
5555 } )
Original file line number Diff line number Diff line change 11import * as users from './users'
22import * as userRelation from './user-relation'
33import * as posts from './posts'
4+ import * as recommendFeed from './recommend-feed'
45import * as personalUpdate from './personal-update'
56import * as notifications from './notifications'
67import * as comments from './comments'
@@ -11,6 +12,7 @@ import * as upload from './upload'
1112 * - {@link api/users | `users`}: 用户
1213 * - {@link api/user-relation | `userRelation`}: 用户关系
1314 * - {@link api/posts | `posts`}: 动态
15+ * - {@link api/recommend-feed | `recommendFeed`}: 动态
1416 * - {@link api/personal-update | `personalUpdate`}: 主页
1517 * - {@link api/notifications | `notifications`}: 通知
1618 * - {@link api/comments | `comments`}: 评论
@@ -20,6 +22,7 @@ export const api = {
2022 users,
2123 userRelation,
2224 posts,
25+ recommendFeed,
2326 personalUpdate,
2427 notifications,
2528 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 {
66 SimpleUser ,
77 TabIcons ,
88 User ,
9+ RecommendPost ,
910} from './entity'
1011
1112export namespace Posts {
@@ -34,7 +35,7 @@ export namespace Notifications {
3435export namespace UserRelation {
3536 export interface GetFollowingListResponse {
3637 data : SimpleUser [ ]
37- loadMoreKey : {
38+ loadMoreKey ? : {
3839 createdAt : string
3940 }
4041 }
@@ -111,7 +112,7 @@ export namespace Users {
111112export namespace PersonalUpdate {
112113 export interface SingleResponse {
113114 data : PostDetail [ ]
114- loadMoreKey : {
115+ loadMoreKey ? : {
115116 lastId : string
116117 }
117118 }
@@ -125,7 +126,7 @@ export namespace Comments {
125126
126127 export interface ListPrimaryResponse {
127128 data : Comment [ ]
128- loadMoreKey : {
129+ loadMoreKey ? : {
129130 key : string
130131 partition : string
131132 }
@@ -137,3 +138,13 @@ export namespace Upload {
137138 uptoken : string
138139 }
139140}
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 {
487487 source : string
488488}
489489
490- export interface ReadTrackInfo {
491- recommendReason : string
492- recommendReasonPolicy : string
493- }
490+ export type ReadTrackInfo = Record < string , any >
494491
495492export interface ActionItem {
496493 type : string
@@ -588,3 +585,52 @@ export interface Comment {
588585 deletable : boolean
589586 pinnable : boolean
590587}
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 11/**
2- * 分页选项
2+ * @description 分页选项
33 */
4- export interface PaginationOption < T = any > {
4+ export interface PaginationOption < T = Record < string , any > > {
55 /**
6- * 最大记录数
6+ * @description 最大记录数
77 * @default 10
88 */
99 limit ?: number
@@ -14,41 +14,50 @@ export interface PaginationOption<T = any> {
1414 loadMoreKey ?: Partial < T >
1515}
1616
17+ /**
18+ * @description 动态类型
19+ */
1720export enum PostType {
18- /** 动态 */
21+ /** 原帖 */
1922 ORIGINAL = 'originalPosts' ,
2023 /** 转发 */
2124 REPOST = 'reposts' ,
2225}
2326
27+ /**
28+ * @description 发送动态选项
29+ */
2430export interface CreatePostOption {
2531 /**
26- * 同步到个人主页
27- * @default true
32+ * @description 是否同步到个人主页
33+ * @default ` true`
2834 */
2935 syncToPersonalUpdates ?: boolean
3036 /**
31- * 图片 key 列表
32- * @default []
37+ * @description 图片 key 列表
38+ * @default `[]`
3339 */
3440 pictureKeys ?: string [ ]
3541
3642 /**
37- * 圈子 ID
38- * @default undefined
43+ * @description 圈子 ID
44+ * @default ` undefined`
3945 */
4046 topicId ?: string
4147}
4248
49+ /**
50+ * @description 发送评论选项
51+ */
4352export interface AddCommentOption {
4453 /**
45- * 同步到个人主页
46- * @default false
54+ * @description 同步到个人主页
55+ * @default ` false`
4756 */
4857 syncToPersonalUpdates ?: boolean
4958 /**
50- * 图片 key 列表
51- * @default []
59+ * @description 图片 key 列表
60+ * @default `[]`
5261 */
5362 pictureKeys ?: string [ ]
5463}
@@ -57,6 +66,26 @@ export interface ListCommentMoreKey {
5766 key : string
5867 partition : string
5968}
60- export type ListCommentOption = PaginationOption < ListCommentMoreKey > & {
69+ /**
70+ * @description 获取评论选项
71+ */
72+ export interface ListCommentOption
73+ extends PaginationOption < ListCommentMoreKey > {
74+ /**
75+ * 排序
76+ * @default `LIKES`
77+ */
6178 order ?: 'LIKES' | 'TIME'
6279}
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 44 " src/api/notifications.ts" ,
55 " src/api/personal-update.ts" ,
66 " src/api/posts.ts" ,
7+ " src/api/recommend-feed.ts" ,
78 " src/api/user-relation.ts" ,
89 " src/api/users.ts" ,
910 " src/api/comments.ts" ,
You can’t perform that action at this time.
0 commit comments