Skip to content

Commit 96e2226

Browse files
committed
feat(api): add editProfile
closes #78
1 parent c641017 commit 96e2226

File tree

5 files changed

+61
-2
lines changed

5 files changed

+61
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- [x] [短信登录](http://jike-sdk.surge.sh/functions/api_users.loginWithSmsCode.html)
2727
- [x] [手机号与密码登录](http://jike-sdk.surge.sh/functions/api_users.loginWithPhoneAndPassword.html)
2828
- [x] [弹一弹头像](http://jike-sdk.surge.sh/functions/api_users.avatarGreet.html)
29+
- [x] [修改用户信息](http://jike-sdk.surge.sh/functions/api_users.editProfile.html)
2930
- [ ] ~~保存设备 Token~~
3031
- [用户关系](http://jike-sdk.surge.sh/modules/api_user_relation.html)
3132
- [x] [获取关注列表](http://jike-sdk.surge.sh/functions/api_user_relation.getFollowingList.html)

src/api/users.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getApiConfig, request, toResponse } from '../request'
2+
import type { EditProfilePayload } from '../types/options'
23
import type { Users } from '../types/api-responses'
34

45
/**
@@ -110,3 +111,16 @@ export const avatarGreet = <T = Users.AvatarGreetResponse>(username: string) =>
110111
},
111112
})
112113
)
114+
115+
/**
116+
* 修改用户信息
117+
* @param payload 更新后的信息
118+
*/
119+
export const editProfile = <T = Users.EditProfileResponse>(
120+
payload: EditProfilePayload
121+
) =>
122+
toResponse<T>(
123+
request.post('1.0/users/editProfile', {
124+
json: payload,
125+
})
126+
)

src/types/api-responses.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ export namespace Users {
135135
? MyProfile
136136
: UserProfile
137137

138-
export interface AvatarGreetResponse {
139-
success: boolean
138+
export type AvatarGreetResponse = {}
139+
140+
export interface EditProfileResponse {
141+
toast: LiteralUnion<'已更新'>
142+
alert?: any
140143
}
141144
}
142145

src/types/entity/profile.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ export interface Profile {
127127
storyStatus: LiteralUnion<StoryStatus>
128128
/** 是否夸夸过 */
129129
respected: boolean
130+
/** 行业 */
131+
industries?: number[]
132+
/** 情感状态 */
133+
relationshipState?: {
134+
id: string
135+
text: LiteralUnion<
136+
| '母胎solo'
137+
| '今日单身'
138+
| '等TA出现'
139+
| '自由可撩'
140+
| '单身不撩'
141+
| '心里有人'
142+
| '恋爱中'
143+
| '一言难尽'
144+
>
145+
}
146+
sponsorIconType?: LiteralUnion<'DEFAULT' | 'COLORFUL' | 'NONE'>
130147

131148
[key: string]: any
132149
}

src/types/options.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Profile } from './entity'
12
import type { LiteralUnion } from '../utils'
23

34
/**
@@ -116,3 +117,26 @@ export interface UserUnfollowOption {
116117
pageName?: number
117118
ref?: string
118119
}
120+
121+
/**
122+
* @description 修改用户信息选项
123+
*/
124+
export interface EditProfilePayload
125+
extends Partial<
126+
Pick<
127+
Profile,
128+
| 'bio'
129+
| 'gender'
130+
| 'school'
131+
| 'industries'
132+
| 'country'
133+
| 'province'
134+
| 'city'
135+
| 'birthday'
136+
| 'screenName'
137+
>
138+
> {
139+
/** 情感状态 */
140+
relationshipState?: string
141+
[key: string]: any
142+
}

0 commit comments

Comments
 (0)