mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Update getNotifyCount API (fix #4427)
This commit is contained in:
parent
ccab2cac68
commit
5b7cec5ef1
@ -11,7 +11,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { TabControl, VIcon } from '@/ui'
|
import { TabControl, VIcon } from '@/ui'
|
||||||
import { FeedsCardType, feedsCardTypes } from '@/components/feeds/api'
|
import { FeedsCardType, feedsCardTypes } from '@/components/feeds/api'
|
||||||
import { getNotifyCount } from '@/components/feeds/notify'
|
import { getNotifyCountByType } from '@/components/feeds/notify'
|
||||||
import { popperMixin } from '../mixins'
|
import { popperMixin } from '../mixins'
|
||||||
import { tabs } from './tabs/tabs'
|
import { tabs } from './tabs/tabs'
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ export default Vue.extend({
|
|||||||
if (!feedsCardType.apiType) {
|
if (!feedsCardType.apiType) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const count = await getNotifyCount(feedsCardType.apiType)
|
const count = await getNotifyCountByType(feedsCardType.apiType)
|
||||||
tab.count = count
|
tab.count = count
|
||||||
console.log(tab)
|
console.log(tab)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -32,7 +32,8 @@ export const updateLatestID = (cards: { id: string }[]) => {
|
|||||||
const [id] = [...cards.map(c => c.id)].sort(compareID).reverse()
|
const [id] = [...cards.map(c => c.id)].sort(compareID).reverse()
|
||||||
setLatestID(id)
|
setLatestID(id)
|
||||||
}
|
}
|
||||||
export const getNotifyCount = async (type = 'all'): Promise<number> => {
|
/** 按类型获取动态提醒数 */
|
||||||
|
export const getNotifyCountByType = async (type: string): Promise<number> => {
|
||||||
const api = `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all/update?type=${type}&update_baseline=${getLatestID()}`
|
const api = `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all/update?type=${type}&update_baseline=${getLatestID()}`
|
||||||
const json = await getJsonWithCredentials(api)
|
const json = await getJsonWithCredentials(api)
|
||||||
if (json.code !== 0) {
|
if (json.code !== 0) {
|
||||||
@ -40,3 +41,14 @@ export const getNotifyCount = async (type = 'all'): Promise<number> => {
|
|||||||
}
|
}
|
||||||
return lodash.get(json, 'data.update_num', 0)
|
return lodash.get(json, 'data.update_num', 0)
|
||||||
}
|
}
|
||||||
|
/** 获取所有类型的动态提醒数 (视频, 番剧, 专栏; 普通动态不算)
|
||||||
|
* @see https://github.com/the1812/Bilibili-Evolved/issues/4427
|
||||||
|
*/
|
||||||
|
export const getNotifyCount = async (): Promise<number> => {
|
||||||
|
const api = 'https://api.bilibili.com/x/web-interface/dynamic/entrance'
|
||||||
|
const json = await getJsonWithCredentials(api)
|
||||||
|
if (json.code !== 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return lodash.get(json, 'data.update_info.item.count', 0)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user