mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-10 03:27:54 +00:00
feat(subscription): add meApi subscriptions methods
This commit is contained in:
parent
7063a6d348
commit
ebc3280d65
1 changed files with 24 additions and 0 deletions
|
|
@ -1009,6 +1009,30 @@ export const meApi = {
|
|||
|
||||
return items
|
||||
},
|
||||
|
||||
async getSubscriptionsPage(params?: { page?: number; size?: number }): Promise<{ items: SkillSummary[]; total: number; page: number; size: number }> {
|
||||
const searchParams = new URLSearchParams()
|
||||
searchParams.set('page', String(params?.page ?? 0))
|
||||
searchParams.set('size', String(params?.size ?? 12))
|
||||
return fetchJson<{ items: SkillSummary[]; total: number; page: number; size: number }>(`${WEB_API_PREFIX}/me/subscriptions?${searchParams.toString()}`)
|
||||
},
|
||||
|
||||
async getSubscriptions(): Promise<SkillSummary[]> {
|
||||
const items: SkillSummary[] = []
|
||||
let page = 0
|
||||
const size = 100
|
||||
let hasMore = true
|
||||
|
||||
while (hasMore) {
|
||||
const response = await meApi.getSubscriptionsPage({ page, size })
|
||||
items.push(...response.items)
|
||||
|
||||
hasMore = (page + 1) * response.size < response.total && response.items.length > 0
|
||||
page++
|
||||
}
|
||||
|
||||
return items
|
||||
},
|
||||
}
|
||||
|
||||
export const profileApi = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue