mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Update rank data for freshHome (fix #5211)
This commit is contained in:
parent
739e0d3912
commit
7170600900
@ -18,7 +18,12 @@
|
||||
<VIcon icon="mdi-format-list-text" :size="16" />
|
||||
</VButton>
|
||||
</div>
|
||||
<CompactRankList v-if="isCompactRankList" :parse-json="parseJson" :api="rankingsApi" />
|
||||
<CompactRankList
|
||||
v-if="isCompactRankList"
|
||||
bangumi-mode
|
||||
:parse-json="parseJson"
|
||||
:api="rankingsApi"
|
||||
/>
|
||||
<RankList v-else bangumi-mode :parse-json="parseJson" :api="rankingsApi" />
|
||||
</div>
|
||||
</div>
|
||||
@ -30,20 +35,9 @@ import SubHeader from '../../../SubHeader.vue'
|
||||
import RankList from './RankList.vue'
|
||||
import CompactRankList from './CompactRankList.vue'
|
||||
import BangumiTimeline from './BangumiTimeline.vue'
|
||||
import { RankListCard } from './rank-list'
|
||||
import { getBangumiRankListCards, PGCSeasonTypeMap } from './rank-list'
|
||||
import { compactRankListMixin } from '../../../../mixin'
|
||||
|
||||
const bangumiDataMap = {
|
||||
anime: {
|
||||
seasonType: 1,
|
||||
rankingName: 'bangumi',
|
||||
},
|
||||
guochuang: {
|
||||
seasonType: 4,
|
||||
// 你永远不知道"国创"在 b 站代码里有多少种叫法...
|
||||
rankingName: 'guochan',
|
||||
},
|
||||
}
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
SubHeader,
|
||||
@ -62,34 +56,17 @@ export default Vue.extend({
|
||||
},
|
||||
data() {
|
||||
const { route } = this.region.category
|
||||
const { rankingName, seasonType } = bangumiDataMap[route]
|
||||
const seasonType = PGCSeasonTypeMap[route]
|
||||
return {
|
||||
bangumiDataMap,
|
||||
route,
|
||||
timelineApi: `https://api.bilibili.com/pgc/web/timeline?types=${seasonType}&before=6&after=6`,
|
||||
rankingsApi: `https://api.bilibili.com/pgc/season/rank/web/list?day=3&season_type=${seasonType}`,
|
||||
rankingsLink: `https://www.bilibili.com/v/popular/rank/${rankingName}`,
|
||||
rankingsLink: `https://www.bilibili.com/v/popular/rank/${route}`,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
parseJson(json: any) {
|
||||
const items = (json.data?.list ?? []) as any[]
|
||||
const cards = items
|
||||
.map((item): RankListCard => {
|
||||
const upName = item.new_ep?.index_show ?? item.title
|
||||
return {
|
||||
id: item.season_id,
|
||||
title: item.title,
|
||||
playCount: item.stat.view,
|
||||
points: item.stat.follow,
|
||||
upHref: item.url,
|
||||
upName,
|
||||
dynamic: upName,
|
||||
coverUrl: item.new_ep?.cover ?? item.ss_horizontal_cover,
|
||||
videoHref: item.url,
|
||||
}
|
||||
})
|
||||
.slice(0, 10)
|
||||
const cards = getBangumiRankListCards(json).slice(0, 10)
|
||||
return applyContentFilter(cards)
|
||||
},
|
||||
},
|
||||
|
||||
@ -39,10 +39,10 @@
|
||||
</template>
|
||||
</UpInfo>
|
||||
<div class="compact-rank-list-card-stats">
|
||||
<VIcon icon="mdi-fire" :size="16" />
|
||||
{{ video.points | formatCount }}
|
||||
<VIcon icon="play" :size="16" />
|
||||
{{ video.playCount | formatCount }}
|
||||
<VIcon icon="danmaku" :size="16" />
|
||||
{{ video.danmakuCount | formatCount }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@ -82,6 +82,7 @@ export default Vue.extend({
|
||||
},
|
||||
computed: {
|
||||
upInfoProps() {
|
||||
console.log({ bangumiMode: this.bangumiMode })
|
||||
return {
|
||||
size: 18,
|
||||
icon: this.bangumiMode ? 'mdi-television-classic' : 'up-outline',
|
||||
|
||||
@ -22,27 +22,26 @@
|
||||
<VIcon icon="mdi-format-list-text" :size="16" />
|
||||
</VButton>
|
||||
</div>
|
||||
<CompactRankList v-if="isCompactRankList" :parse-json="parseJson" :api="rankingsApi" />
|
||||
<RankList v-else :parse-json="parseJson" :api="rankingsApi" />
|
||||
<CompactRankList
|
||||
v-if="isCompactRankList"
|
||||
:bangumi-mode="isPGC"
|
||||
:parse-json="parseJson"
|
||||
:api="rankingsApi"
|
||||
/>
|
||||
<RankList v-else :bangumi-mode="isPGC" :parse-json="parseJson" :api="rankingsApi" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { VButton, VIcon } from '@/ui'
|
||||
import { applyContentFilter } from '@/components/feeds/api'
|
||||
import { RankListCard } from './rank-list'
|
||||
import { getBangumiRankListCards, getDefaultRankListCards, PGCSeasonTypeMap } from './rank-list'
|
||||
import CompactRankList from './CompactRankList.vue'
|
||||
import RankList from './RankList.vue'
|
||||
import VideoSlides from './VideoSlides.vue'
|
||||
import SubHeader from '../../../SubHeader.vue'
|
||||
import { compactRankListMixin } from '../../../../mixin'
|
||||
|
||||
/*
|
||||
TODO: 有几个区表面上是普通视频, 但内容走的还是番剧那套, 所以 RankList 也要换 API
|
||||
视频排行: `https://api.bilibili.com/x/web-interface/ranking/region?day=3&original=0&rid=${regionCode}`
|
||||
番剧排行: `https://api.bilibili.com/pgc/season/rank/web/list?day=3&season_type=${seasonType}`
|
||||
- seasonType: 1 番剧 2 电影 3 纪录片 4 国创 5 电视剧
|
||||
*/
|
||||
import { categoryCodesV2 } from '@/components/utils/categories/data'
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
@ -62,32 +61,29 @@ export default Vue.extend({
|
||||
},
|
||||
data() {
|
||||
const regionCode = this.region.id
|
||||
console.log(this.region.category)
|
||||
const tidV2 = categoryCodesV2[this.region.category.route]
|
||||
const isPGC = Object.keys(PGCSeasonTypeMap).includes(this.region.category.route)
|
||||
console.log({
|
||||
category: this.region.category,
|
||||
tidV2,
|
||||
isPGC,
|
||||
})
|
||||
return {
|
||||
isPGC,
|
||||
activeVideosApi: `https://api.bilibili.com/x/web-interface/dynamic/region?ps=10&rid=${regionCode}`,
|
||||
newVideosApi: `https://api.bilibili.com/x/web-interface/newlist?ps=10&rid=${regionCode}`,
|
||||
rankingsApi: `https://api.bilibili.com/x/web-interface/ranking/region?rid=${regionCode}&day=3&original=0`,
|
||||
rankingsApi: isPGC
|
||||
? `https://api.bilibili.com/pgc/season/rank/web/list?day=3&season_type=${
|
||||
PGCSeasonTypeMap[this.region.category.route]
|
||||
}`
|
||||
: `https://api.bilibili.com/x/web-interface/ranking/v2?rid=${tidV2}&type=all`,
|
||||
rankingsLink: `https://www.bilibili.com/v/popular/rank/${this.region.category.route}`,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
parseJson(json: any) {
|
||||
const items = (lodash.get(json, 'data', []) || []) as any[]
|
||||
const cards = items
|
||||
.map(
|
||||
(item): RankListCard => ({
|
||||
id: item.aid,
|
||||
title: item.title,
|
||||
playCount: item.play,
|
||||
points: item.pts,
|
||||
upHref: `https://space.bilibili.com/${item.mid}`,
|
||||
upName: item.author,
|
||||
dynamic: item.description,
|
||||
coverUrl: item.pic,
|
||||
videoHref: `https://www.bilibili.com/video/${item.bvid}`,
|
||||
}),
|
||||
)
|
||||
.slice(0, 10)
|
||||
const allCards = this.isPGC ? getBangumiRankListCards(json) : getDefaultRankListCards(json)
|
||||
const cards = allCards.slice(0, 10)
|
||||
return applyContentFilter(cards)
|
||||
},
|
||||
},
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
</template>
|
||||
</UpInfo>
|
||||
<div class="fresh-home-rank-list-stats">
|
||||
<VIcon icon="mdi-fire" :size="16" />
|
||||
{{ firstItem.points | formatCount }}
|
||||
<VIcon icon="play" :size="16" />
|
||||
{{ firstItem.playCount | formatCount }}
|
||||
</div>
|
||||
</a>
|
||||
<div class="fresh-home-rank-list-laser" data-number="1"></div>
|
||||
@ -57,10 +57,10 @@
|
||||
</template>
|
||||
</UpInfo>
|
||||
<div class="fresh-home-rank-list-stats">
|
||||
<VIcon icon="mdi-fire" :size="16" />
|
||||
{{ secondItem.points | formatCount }}
|
||||
<VIcon icon="play" :size="16" />
|
||||
{{ secondItem.playCount | formatCount }}
|
||||
<VIcon icon="danmaku" :size="16" />
|
||||
{{ secondItem.danmakuCount | formatCount }}
|
||||
</div>
|
||||
</a>
|
||||
<a class="fresh-home-rank-list-cover" target="_blank" :href="secondItem.videoHref">
|
||||
@ -86,10 +86,10 @@
|
||||
</template>
|
||||
</UpInfo>
|
||||
<div class="fresh-home-rank-list-stats">
|
||||
<VIcon icon="mdi-fire" :size="16" />
|
||||
{{ thirdItem.points | formatCount }}
|
||||
<VIcon icon="play" :size="16" />
|
||||
{{ thirdItem.playCount | formatCount }}
|
||||
<VIcon icon="danmaku" :size="16" />
|
||||
{{ thirdItem.danmakuCount | formatCount }}
|
||||
</div>
|
||||
</a>
|
||||
<a class="fresh-home-rank-list-cover" target="_blank" :href="thirdItem.videoHref">
|
||||
|
||||
@ -169,7 +169,7 @@ export default Vue.extend({
|
||||
like: item.stat.like,
|
||||
coins: item.stat.coin,
|
||||
description: item.desc,
|
||||
dynamic: item.desc === '-' ? '' : item.desc,
|
||||
dynamic: item.dynamic || item.desc,
|
||||
type: item.tname,
|
||||
duration: item.duration,
|
||||
durationText: formatDuration(item.duration),
|
||||
|
||||
@ -8,6 +8,7 @@ export interface RankListCard {
|
||||
upName: string
|
||||
points: number
|
||||
playCount: number
|
||||
danmakuCount: number
|
||||
dynamic?: string
|
||||
}
|
||||
export const rankListCssVars = {
|
||||
@ -29,3 +30,47 @@ export const compactRankListCssVars = {
|
||||
panelHeight: 580,
|
||||
padding: 0,
|
||||
}
|
||||
export const PGCSeasonTypeMap = {
|
||||
anime: 1,
|
||||
movie: 2,
|
||||
guochuang: 3,
|
||||
documentary: 4,
|
||||
tv: 5,
|
||||
}
|
||||
export const getDefaultRankListCards = (json: any): RankListCard[] => {
|
||||
const items = (lodash.get(json, 'data.list', []) || []) as any[]
|
||||
const cards = items.map(
|
||||
(item): RankListCard => ({
|
||||
id: item.aid,
|
||||
title: item.title,
|
||||
playCount: item.stat.view,
|
||||
danmakuCount: item.stat.danmaku,
|
||||
points: item.score,
|
||||
upHref: `https://space.bilibili.com/${item.owner.mid}`,
|
||||
upName: item.owner.name,
|
||||
dynamic: item.dynamic || item.desc,
|
||||
coverUrl: item.pic,
|
||||
videoHref: `https://www.bilibili.com/video/${item.bvid}`,
|
||||
}),
|
||||
)
|
||||
return cards
|
||||
}
|
||||
export const getBangumiRankListCards = (json: any): RankListCard[] => {
|
||||
const items = (lodash.get(json, 'data.list', []) || []) as any[]
|
||||
const cards = items.map((item): RankListCard => {
|
||||
const upName = item.new_ep?.index_show ?? item.title
|
||||
return {
|
||||
id: item.season_id,
|
||||
title: item.title,
|
||||
playCount: item.stat.view,
|
||||
danmakuCount: item.stat.danmaku,
|
||||
points: item.stat.follow,
|
||||
upHref: item.url,
|
||||
upName,
|
||||
dynamic: upName,
|
||||
coverUrl: item.new_ep?.cover ?? item.ss_horizontal_cover,
|
||||
videoHref: item.url,
|
||||
}
|
||||
})
|
||||
return cards
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import raw from './raw.json'
|
||||
import tidV2 from './tid-v2.json'
|
||||
|
||||
export interface SubCategory {
|
||||
name: string
|
||||
@ -90,6 +91,14 @@ secondaryCategories.forEach(it => {
|
||||
})
|
||||
export const categories = generalCategories
|
||||
export const categoryCodes = Object.fromEntries(mainCategories.map(it => [it.route, it.tid]))
|
||||
export const categoryCodesV2 = Object.fromEntries(
|
||||
mainCategories
|
||||
.map(it => {
|
||||
const tid = tidV2.find(t => t.route === it.route)?.tid
|
||||
return [it.route, tid]
|
||||
})
|
||||
.filter(it => it[1] !== undefined),
|
||||
)
|
||||
export const categoryLinks = Object.fromEntries(
|
||||
Object.values(generalCategories).map(data => [data.icon, data.link]),
|
||||
)
|
||||
|
||||
1840
src/components/utils/categories/tid-v2.json
Normal file
1840
src/components/utils/categories/tid-v2.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user