mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
Merge branch 'main' into dev
This commit is contained in:
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -6,7 +6,6 @@ on:
|
||||
# The branch where the project source code resides
|
||||
# 项目源代码所在的分支
|
||||
- main
|
||||
- dev
|
||||
paths-ignore:
|
||||
# Changes involving the following path files will not trigger the workflow
|
||||
# 涉及以下路径文件的更改不会触发工作流
|
||||
|
||||
@@ -3,10 +3,11 @@ import { useI18n } from 'vue-i18n'
|
||||
import type { Ref } from 'vue'
|
||||
import { onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useDateFormat } from '@vueuse/core'
|
||||
import type { HistoryItem } from '../types'
|
||||
import { HistoryType } from '../types'
|
||||
import { isHomePage, removeHttpFromUrl, smoothScrollToTop } from '~/utils/main'
|
||||
import { calcCurrentTime } from '~/utils/dataFormatter'
|
||||
import { Business } from '~/models/history/history'
|
||||
import type { List as HistoryItem, HistoryResult } from '~/models/history/history'
|
||||
|
||||
import API from '~/background/msg.define'
|
||||
|
||||
const { t } = useI18n()
|
||||
@@ -39,7 +40,7 @@ const noMoreContent = ref<boolean>(false)
|
||||
const livePage = ref<number>(1)
|
||||
const historysWrap = ref<HTMLElement>() as Ref<HTMLElement>
|
||||
|
||||
watch(activatedTab, (newVal: number, oldVal: number) => {
|
||||
watch(activatedTab, (newVal: number | undefined, oldVal: number | undefined) => {
|
||||
if (newVal === oldVal)
|
||||
return
|
||||
|
||||
@@ -48,20 +49,18 @@ watch(activatedTab, (newVal: number, oldVal: number) => {
|
||||
smoothScrollToTop(historysWrap.value, 300)
|
||||
|
||||
if (newVal === 0) {
|
||||
getHistoryList(HistoryType.Archive)
|
||||
getHistoryList(Business.ARCHIVE)
|
||||
}
|
||||
else if (newVal === 1) {
|
||||
livePage.value = 1
|
||||
getHistoryList(HistoryType.Live)
|
||||
getHistoryList(Business.LIVE)
|
||||
}
|
||||
else if (newVal === 2) {
|
||||
getHistoryList(HistoryType.Article)
|
||||
getHistoryList(Business.ARTICLE)
|
||||
}
|
||||
})
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(() => {
|
||||
getHistoryList(HistoryType.Archive)
|
||||
|
||||
if (historysWrap.value) {
|
||||
historysWrap.value.addEventListener('scroll', () => {
|
||||
// When you scroll to the bottom, they will automatically
|
||||
@@ -74,19 +73,19 @@ onMounted(() => {
|
||||
) {
|
||||
if (activatedTab.value === 0 && !noMoreContent.value) {
|
||||
getHistoryList(
|
||||
HistoryType.Archive,
|
||||
Business.ARCHIVE,
|
||||
historys[historys.length - 1].view_at,
|
||||
)
|
||||
}
|
||||
else if (activatedTab.value === 1 && !noMoreContent.value) {
|
||||
getHistoryList(
|
||||
HistoryType.Live,
|
||||
Business.LIVE,
|
||||
historys[historys.length - 1].view_at,
|
||||
)
|
||||
}
|
||||
else if (activatedTab.value === 2 && !noMoreContent.value) {
|
||||
getHistoryList(
|
||||
HistoryType.Article,
|
||||
Business.ARTICLE,
|
||||
historys[historys.length - 1].view_at,
|
||||
)
|
||||
}
|
||||
@@ -112,35 +111,35 @@ function onClickTab(tabId: number) {
|
||||
* @return {string} url
|
||||
*/
|
||||
function getHistoryUrl(item: HistoryItem) {
|
||||
if (item.uri)
|
||||
return item.uri
|
||||
|
||||
// Video
|
||||
if (activatedTab.value === 0) {
|
||||
if (item.history.business === HistoryType.PGC)
|
||||
return removeHttpFromUrl(item.uri)
|
||||
if (item.history.business === HistoryType.Archive && item?.videos && item.videos > 0)
|
||||
if (item.history.business === Business.ARCHIVE) {
|
||||
if (item?.videos && item.videos > 0)
|
||||
return `//www.bilibili.com/video/${item.history.bvid}?p=${item.history.page}`
|
||||
return `//www.bilibili.com/video/${item.history.bvid}`
|
||||
}
|
||||
// Live
|
||||
else if (activatedTab.value === 1) {
|
||||
else if (item.history.business === Business.LIVE) {
|
||||
return `//live.bilibili.com/${item.history.oid}`
|
||||
}
|
||||
// Article
|
||||
else if (activatedTab.value === 2) {
|
||||
else if (item.history.business === Business.ARTICLE || item.history.business === Business.ARTICLE_LIST) {
|
||||
if (item.history.cid === 0)
|
||||
return `//www.bilibili.com/read/cv${item.history.oid}`
|
||||
else
|
||||
return `//www.bilibili.com/read/cv${item.history.cid}`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Get history list
|
||||
* @param {HistoryType} type
|
||||
* @param {number} view_at Last viewed timestamp
|
||||
* @param type
|
||||
* @param view_at Last viewed timestamp
|
||||
*/
|
||||
function getHistoryList(type: HistoryType, view_at = 0 as number) {
|
||||
function getHistoryList(type: Business, view_at = 0 as number) {
|
||||
isLoading.value = true
|
||||
browser.runtime
|
||||
.sendMessage({
|
||||
@@ -148,7 +147,7 @@ function getHistoryList(type: HistoryType, view_at = 0 as number) {
|
||||
type,
|
||||
view_at,
|
||||
})
|
||||
.then((res) => {
|
||||
.then((res: HistoryResult) => {
|
||||
if (res.code === 0) {
|
||||
if (Array.isArray(res.data.list) && res.data.list.length > 0)
|
||||
historys.push(...res.data.list)
|
||||
@@ -325,7 +324,7 @@ function getHistoryList(type: HistoryType, view_at = 0 as number) {
|
||||
m="1"
|
||||
rounded="$bew-radius-half"
|
||||
>
|
||||
Offline
|
||||
OFFLINE
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -367,7 +366,7 @@ function getHistoryList(type: HistoryType, view_at = 0 as number) {
|
||||
gap-1
|
||||
m="l-2"
|
||||
><tabler:live-photo />
|
||||
Live
|
||||
LIVE
|
||||
</span>
|
||||
</div>
|
||||
<p text="$bew-text-2 sm">
|
||||
|
||||
@@ -58,40 +58,6 @@ export enum MomentType {
|
||||
Documentary = 4101,
|
||||
}
|
||||
|
||||
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/history&toview/history.md#%E8%8E%B7%E5%8F%96%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95%E5%88%97%E8%A1%A8_web%E7%AB%AF
|
||||
export enum HistoryType {
|
||||
Archive = 'archive', // archive:稿件
|
||||
PGC = 'pgc', // pgc:剧集 (番剧 / 影视)
|
||||
Live = 'live', // live:直播
|
||||
ArticleList = 'article-list', // article-list:文集
|
||||
Article = 'article', // article:文章
|
||||
}
|
||||
|
||||
export interface HistoryItem {
|
||||
title: string
|
||||
cover: string
|
||||
covers?: Array<string>
|
||||
history: {
|
||||
business: HistoryType
|
||||
epid?: number
|
||||
bvid?: string
|
||||
part?: string
|
||||
page?: number
|
||||
oid: number
|
||||
cid: number
|
||||
}
|
||||
videos?: number
|
||||
author_name: string
|
||||
author_face: string
|
||||
author_mid: string
|
||||
view_at: number
|
||||
progress: number
|
||||
duration: number
|
||||
kid: number
|
||||
live_status: 0 | 1 // 0:未开播 1:已开播
|
||||
uri: string
|
||||
}
|
||||
|
||||
export interface FavoriteCategory {
|
||||
id: number
|
||||
fid: number
|
||||
|
||||
@@ -4,8 +4,8 @@ import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { getCSRF, removeHttpFromUrl } from '~/utils/main'
|
||||
import { calcCurrentTime } from '~/utils/dataFormatter'
|
||||
import { Business } from '~/models/video/history'
|
||||
import type { List as HistoryItem, HistoryResult } from '~/models/video/history'
|
||||
import { Business } from '~/models/history/history'
|
||||
import type { List as HistoryItem, HistoryResult } from '~/models/history/history'
|
||||
import type { List as HistorySearchItem, HistorySearchResult } from '~/models/video/historySearch'
|
||||
import API from '~/background/msg.define'
|
||||
|
||||
@@ -136,20 +136,21 @@ function deleteHistoryItem(index: number, historyItem: HistoryItem) {
|
||||
* @return {string} url
|
||||
*/
|
||||
function getHistoryUrl(item: HistoryItem): string {
|
||||
// anime
|
||||
if (item.history.business === 'pgc') {
|
||||
return removeHttpFromUrl(item.uri)
|
||||
}
|
||||
// video
|
||||
else if (item.history.business === Business.ARCHIVE) {
|
||||
if (item.uri)
|
||||
return item.uri
|
||||
|
||||
// Video
|
||||
if (item.history.business === Business.ARCHIVE) {
|
||||
if (item?.videos && item.videos > 0)
|
||||
return `//www.bilibili.com/video/${item.history.bvid}?p=${item.history.page}`
|
||||
return item.history.bvid
|
||||
return `//www.bilibili.com/video/${item.history.bvid}`
|
||||
}
|
||||
else if (item.history.business === 'live') {
|
||||
// Live
|
||||
else if (item.history.business === Business.LIVE) {
|
||||
return `//live.bilibili.com/${item.history.oid}`
|
||||
}
|
||||
else if (item.history.business === 'article' || item.history.business === 'article-list') {
|
||||
// Article
|
||||
else if (item.history.business === Business.ARTICLE || item.history.business === Business.ARTICLE_LIST) {
|
||||
if (item.history.cid === 0)
|
||||
return `//www.bilibili.com/read/cv${item.history.oid}`
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user