mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix cheese url (fix #4484)
This commit is contained in:
parent
59e61330b7
commit
3b55128e71
@ -106,7 +106,7 @@
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { bilibiliApi, getJsonWithCredentials, postTextWithCredentials } from '@/core/ajax'
|
||||
import { formData, getCsrf } from '@/core/utils'
|
||||
import { getCsrf } from '@/core/utils'
|
||||
import { descendingSort } from '@/core/utils/sort'
|
||||
import {
|
||||
VButton,
|
||||
@ -119,7 +119,14 @@ import {
|
||||
DpiImage,
|
||||
} from '@/ui'
|
||||
import { popperMixin } from '../mixins'
|
||||
import { types, TypeFilter, HistoryItem, getHistoryItems, group, HistoryType } from './types'
|
||||
import {
|
||||
navbarFilterTypes,
|
||||
TypeFilter,
|
||||
HistoryItem,
|
||||
getHistoryItems,
|
||||
group,
|
||||
HistoryType,
|
||||
} from './types'
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
@ -135,7 +142,7 @@ export default Vue.extend({
|
||||
mixins: [popperMixin],
|
||||
data() {
|
||||
return {
|
||||
types,
|
||||
types: navbarFilterTypes,
|
||||
search: '',
|
||||
viewTime: 0,
|
||||
cards: [],
|
||||
@ -164,10 +171,11 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
toggleTypeFilter(typeFilter: TypeFilter) {
|
||||
types.forEach(t => (t.checked = t.name === typeFilter.name))
|
||||
navbarFilterTypes.forEach(t => (t.checked = t.name === typeFilter.name))
|
||||
this.reloadHistoryItems()
|
||||
},
|
||||
async reloadHistoryItems() {
|
||||
this.cards = []
|
||||
this.viewTime = 0
|
||||
this.hasMorePage = true
|
||||
this.loading = true
|
||||
@ -178,8 +186,8 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
filterFunc(item: HistoryItem) {
|
||||
const isAllType = types.find(it => it.name === HistoryType.All).checked
|
||||
if (!isAllType && types.some(t => t.name === item.type && !t.checked)) {
|
||||
const isAllType = navbarFilterTypes.find(it => it.name === HistoryType.All).checked
|
||||
if (!isAllType && navbarFilterTypes.some(t => t.name === item.type && !t.checked)) {
|
||||
return false
|
||||
}
|
||||
if (
|
||||
@ -196,7 +204,7 @@ export default Vue.extend({
|
||||
async nextPage() {
|
||||
const items = await getHistoryItems(
|
||||
this.viewTime,
|
||||
types.find(t => t.checked),
|
||||
navbarFilterTypes.find(t => t.checked),
|
||||
)
|
||||
const cards: HistoryItem[] = lodash.uniqBy(
|
||||
this.cards.concat(items).sort(descendingSort((item: HistoryItem) => item.viewAt)),
|
||||
@ -228,10 +236,10 @@ export default Vue.extend({
|
||||
this.paused = targetState
|
||||
await postTextWithCredentials(
|
||||
'https://api.bilibili.com/x/v2/history/shadow/set',
|
||||
formData({
|
||||
new URLSearchParams({
|
||||
csrf: getCsrf(),
|
||||
switch: targetState,
|
||||
}),
|
||||
switch: targetState.toString(),
|
||||
}).toString(),
|
||||
)
|
||||
} catch (error) {
|
||||
this.paused = !targetState
|
||||
|
||||
@ -9,6 +9,7 @@ export enum HistoryType {
|
||||
Live = 'live',
|
||||
Article = 'article',
|
||||
Bangumi = 'pgc',
|
||||
Cheese = 'cheese',
|
||||
}
|
||||
export interface HistoryItem {
|
||||
id: string | number
|
||||
@ -51,8 +52,8 @@ export interface TypeFilter {
|
||||
checked: boolean
|
||||
apiType: string
|
||||
}
|
||||
/** 所有的历史记录类型 */
|
||||
export const types = [
|
||||
/** 顶栏可筛选的历史记录类型 */
|
||||
export const navbarFilterTypes = [
|
||||
{
|
||||
name: HistoryType.All,
|
||||
displayName: '全部',
|
||||
@ -72,6 +73,7 @@ export const types = [
|
||||
displayName: '番剧',
|
||||
icon: 'mdi-television-classic',
|
||||
checked: false,
|
||||
// b 站的历史不区分视频和番剧, 只能混着拿然后过滤
|
||||
apiType: 'archive',
|
||||
},
|
||||
{
|
||||
@ -122,14 +124,14 @@ const formatTime = (date: Date) => {
|
||||
.padStart(2, '0')}`
|
||||
}
|
||||
const parseHistoryItem = (item: any): HistoryItem => {
|
||||
if (item.history.business === 'article') {
|
||||
if (item.history.business === HistoryType.Article) {
|
||||
item.history.cid = item.history.oid
|
||||
}
|
||||
const {
|
||||
epid, // 番剧 ep号
|
||||
bvid, // 视频 bv号
|
||||
cid, // 专栏 cv号
|
||||
oid, // 直播 房间号 / 专栏 cv 号
|
||||
oid, // 直播 房间号 / 专栏 cv 号 / 课程神秘标识符
|
||||
} = item.history
|
||||
const progressParam = item.progress > 0 ? `t=${item.progress}` : 't=0'
|
||||
const progress = item.progress === -1 ? 1 : item.progress / item.duration
|
||||
@ -159,6 +161,17 @@ const parseHistoryItem = (item: any): HistoryItem => {
|
||||
upFaceUrl: https(item.author_face),
|
||||
upID: item.author_mid,
|
||||
}
|
||||
if (item.history.business === HistoryType.Cheese) {
|
||||
return {
|
||||
...commonInfo,
|
||||
id: oid,
|
||||
upName: item.title,
|
||||
title: item.show_title,
|
||||
url: item.uri,
|
||||
/** 特殊处理: 展示上分类仍归类到视频 */
|
||||
type: HistoryType.Video,
|
||||
}
|
||||
}
|
||||
if (epid) {
|
||||
return {
|
||||
...commonInfo,
|
||||
@ -215,7 +228,15 @@ export const getHistoryItems = async (viewTime?: number, type?: TypeFilter) => {
|
||||
if (!Array.isArray(list)) {
|
||||
return []
|
||||
}
|
||||
return (list as any[]).map(parseHistoryItem)
|
||||
return (list as any[]).map(parseHistoryItem).filter(it => {
|
||||
if (it === null) {
|
||||
return false
|
||||
}
|
||||
if (type && type.name !== HistoryType.All) {
|
||||
return it.type === type.name
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 为历史记录项目分组, 包含`今天`, `昨天`, `本周`, `更早`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user