Update getNotifyCount API (fix #4427)

This commit is contained in:
the1812 2024-03-06 09:46:16 +08:00
parent ccab2cac68
commit 5b7cec5ef1
2 changed files with 15 additions and 3 deletions

View File

@ -11,7 +11,7 @@
<script lang="ts">
import { TabControl, VIcon } from '@/ui'
import { FeedsCardType, feedsCardTypes } from '@/components/feeds/api'
import { getNotifyCount } from '@/components/feeds/notify'
import { getNotifyCountByType } from '@/components/feeds/notify'
import { popperMixin } from '../mixins'
import { tabs } from './tabs/tabs'
@ -49,7 +49,7 @@ export default Vue.extend({
if (!feedsCardType.apiType) {
return
}
const count = await getNotifyCount(feedsCardType.apiType)
const count = await getNotifyCountByType(feedsCardType.apiType)
tab.count = count
console.log(tab)
})

View File

@ -32,7 +32,8 @@ export const updateLatestID = (cards: { id: string }[]) => {
const [id] = [...cards.map(c => c.id)].sort(compareID).reverse()
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 json = await getJsonWithCredentials(api)
if (json.code !== 0) {
@ -40,3 +41,14 @@ export const getNotifyCount = async (type = 'all'): Promise<number> => {
}
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)
}