mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-09-26 22:49:14 +08:00
Fix stat data display (#4421)
This commit is contained in:
parent
6bf19a101f
commit
c1d7441801
@ -31,7 +31,7 @@
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { VideoCard } from '@/components/feeds/video-card'
|
||||
import { formatDuration, formatCount, parseDuration } from '@/core/utils/formatters'
|
||||
import { formatDuration, formatCount, parseDuration, parseCount } from '@/core/utils/formatters'
|
||||
import { isNewID } from '@/components/feeds/notify'
|
||||
import { feedsCardTypes, groupVideoFeeds } from '@/components/feeds/api'
|
||||
import VideoCardComponent from '@/components/feeds/VideoCard.vue'
|
||||
@ -98,7 +98,7 @@ export default Vue.extend({
|
||||
upName: author.name,
|
||||
upID: author.mid,
|
||||
watchlater: true,
|
||||
playCount: formatCount(archive.stat.play),
|
||||
playCount: formatCount(parseCount(archive.stat.play)),
|
||||
get new() {
|
||||
return isNewID(this.id)
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { getUID, pascalCase } from '@/core/utils'
|
||||
import { getJsonWithCredentials } from '@/core/ajax'
|
||||
import { formatCount, formatDuration, parseDuration } from '@/core/utils/formatters'
|
||||
import { formatCount, formatDuration, parseCount, parseDuration } from '@/core/utils/formatters'
|
||||
import { watchlaterList } from '@/components/video/watchlater'
|
||||
import { getData, registerData } from '@/plugins/data'
|
||||
import { descendingStringSort } from '@/core/utils/sort'
|
||||
@ -140,8 +140,8 @@ export const getVideoFeeds = withContentFilter(
|
||||
like: formatCount(stat.like.count),
|
||||
duration: parseDuration(archive.duration_text),
|
||||
durationText: formatDuration(parseDuration(archive.duration_text)),
|
||||
playCount: formatCount(archive.stat.play),
|
||||
danmakuCount: formatCount(archive.stat.danmaku),
|
||||
playCount: formatCount(parseCount(archive.stat.play)),
|
||||
danmakuCount: formatCount(parseCount(archive.stat.danmaku)),
|
||||
watchlater: watchlaterList.includes(archive.aid),
|
||||
}
|
||||
}),
|
||||
@ -164,8 +164,8 @@ export const getVideoFeeds = withContentFilter(
|
||||
time: new Date(author.pub_ts * 1000),
|
||||
like: formatCount(stat.like.count),
|
||||
durationText: '',
|
||||
playCount: formatCount(pgc.stat.play),
|
||||
danmakuCount: formatCount(pgc.stat.danmaku),
|
||||
playCount: formatCount(parseCount(pgc.stat.play)),
|
||||
danmakuCount: formatCount(parseCount(pgc.stat.danmaku)),
|
||||
watchlater: false,
|
||||
}
|
||||
})
|
||||
|
@ -51,6 +51,21 @@ export const formatDuration = (time: number, fixed = 0) => {
|
||||
}
|
||||
return `${hour}:${minute.padStart(2, '0')}:${second.padStart(secondTotalLength, '0')}`
|
||||
}
|
||||
export const parseCount = (countText: string | number) => {
|
||||
if (typeof countText === 'number') {
|
||||
return countText
|
||||
}
|
||||
const unit = (() => {
|
||||
if (countText.match(/亿$/)) {
|
||||
return 1e8
|
||||
}
|
||||
if (countText.match(/万$/)) {
|
||||
return 1e4
|
||||
}
|
||||
return 1
|
||||
})()
|
||||
return parseFloat(countText) * unit
|
||||
}
|
||||
const formatCountData = (count: number | string) => {
|
||||
if (typeof count === 'string') {
|
||||
count = parseInt(count)
|
||||
|
Loading…
Reference in New Issue
Block a user