Merge branch 'preview-fixes' into preview-features

This commit is contained in:
the1812 2022-03-21 13:25:54 +08:00
commit a3f6043e21
4 changed files with 36 additions and 16 deletions

View File

@ -405,7 +405,9 @@ export default Vue.extend({
}
&-header {
@include h-center();
padding: 6px;
border-bottom: 1px solid #8882;
padding: 6px 0;
margin: 0 6px;
.title {
font-size: 16px;
@ -421,7 +423,7 @@ export default Vue.extend({
@include no-scrollbar();
@include v-stretch();
flex: 1 0 0;
padding: 6px;
padding: 12px 6px;
align-items: flex-start;
> :not(:first-child) {
margin-top: 12px;
@ -445,7 +447,9 @@ export default Vue.extend({
}
&-footer {
@include h-center();
padding: 6px;
border-top: 1px solid #8882;
padding: 6px 0;
margin: 0 6px;
justify-content: center;
}
.run-download {

View File

@ -181,10 +181,10 @@ const downloadDash = async (
videoCodec: codec,
})
const qualities = (data.accept_quality as number[])
.filter(qn => (
// 去掉当前编码不匹配的 quality
(video as any[]).some(d => d.id === qn && parseVideoCodec(d.codecid) === codec)
))
// .filter(qn => (
// // 去掉当前编码不匹配的 quality
// (video as any[]).some(d => d.id === qn && parseVideoCodec(d.codecid) === codec)
// ))
.map(qn => allQualities.find(q => q.value === qn))
.filter(q => q !== undefined)
const info = new DownloadVideoInfo({
@ -200,19 +200,19 @@ const downloadDash = async (
export const videoDashAvc: DownloadVideoApi = {
name: 'video.dash.avc',
displayName: 'dash (AVC/H.264)',
description: '音画分离的 mp4 格式, 编码为 H.264, 体积较大, 兼容性较好. 下载后可以合并为单个 mp4 文件.',
description: '音画分离的 mp4 格式, 编码为 H.264, 体积较大, 兼容性较好. 下载后可以合并为单个 mp4 文件. 如果视频源没有此编码, 则会自动选择其他同清晰度的编码格式.',
downloadVideoInfo: async input => downloadDash(input, { codec: DashCodec.Avc }),
}
export const videoDashHevc: DownloadVideoApi = {
name: 'video.dash.hevc',
displayName: 'dash (HEVC/H.265)',
description: '音画分离的 mp4 格式, 编码为 H.265, 体积中等, 兼容性较差. 下载后可以合并为单个 mp4 文件.',
description: '音画分离的 mp4 格式, 编码为 H.265, 体积中等, 兼容性较差. 下载后可以合并为单个 mp4 文件. 如果视频源没有此编码, 则会自动选择其他同清晰度的编码格式.',
downloadVideoInfo: async input => downloadDash(input, { codec: DashCodec.Hevc }),
}
export const videoDashAv1: DownloadVideoApi = {
name: 'video.dash.av1',
displayName: 'dash (AV1)',
description: '音画分离的 mp4 格式, 编码为 AV1, 体积较小, 兼容性中等. 下载后可以合并为单个 mp4 文件.',
description: '音画分离的 mp4 格式, 编码为 AV1, 体积较小, 兼容性中等. 下载后可以合并为单个 mp4 文件. 如果视频源没有此编码, 则会自动选择其他同清晰度的编码格式.',
downloadVideoInfo: async input => downloadDash(input, { codec: DashCodec.Av1 }),
}
export const videoAudioDash: DownloadVideoApi = {

View File

@ -1,4 +1,4 @@
import { VueConstructor } from 'vue'
import { Component, VueConstructor } from 'vue'
export type Executable<ReturnType = void> = () => ReturnType | Promise<ReturnType>
export type ExecutableWithParameter<Parameters extends any[] = never[], ReturnType = void> = (
@ -7,7 +7,11 @@ export type ExecutableWithParameter<Parameters extends any[] = never[], ReturnTy
export type TestPattern = (string | RegExp)[]
export type ArrayContent<T> = T extends Array<infer R> ? R : T
export type VueModule = VueConstructor | { default: VueConstructor }
export type VueModule =
Component
| { default: Component }
| VueConstructor
| { default: VueConstructor }
export type I18nDescription = string | { 'zh-CN': string; [key: string]: string }
export type WithName = {
name: string

View File

@ -177,10 +177,22 @@ export const matchUrlPattern = (pattern: string | RegExp) => (
* @param module Vue组件模块对象
* @param target ,
*/
export const mountVueComponent = <T>(module: VueModule, target?: Element | string) => {
const instance = new Vue('default' in module ? module.default : module)
// const instance = new Vue({ render: h => h('default' in module ? module.default : module) })
return instance.$mount(target) as Vue & T
export const mountVueComponent = <T>(
module: VueModule,
target?: Element | string,
): Vue & T => {
const obj = 'default' in module ? module.default : module
const getInstance = (o: any) => {
if (o instanceof Function) {
// eslint-disable-next-line new-cap
return new o()
}
if (o.functional) {
return new (Vue.extend(o))()
}
return new Vue(o)
}
return getInstance(obj).$mount(target) as Vue & T
}
/** 是否处于其他网站的内嵌播放器中 */
export const isEmbeddedPlayer = () => window.location.host === 'player.bilibili.com' || document.URL.startsWith('https://www.bilibili.com/html/player.html')