diff --git a/registry/lib/components/video/download/DownloadVideo.vue b/registry/lib/components/video/download/DownloadVideo.vue index a2a10f121..278440b94 100644 --- a/registry/lib/components/video/download/DownloadVideo.vue +++ b/registry/lib/components/video/download/DownloadVideo.vue @@ -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 { diff --git a/registry/lib/components/video/download/apis/dash.ts b/registry/lib/components/video/download/apis/dash.ts index 6c54d0751..b283bb686 100644 --- a/registry/lib/components/video/download/apis/dash.ts +++ b/registry/lib/components/video/download/apis/dash.ts @@ -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 = { diff --git a/src/core/common-types.ts b/src/core/common-types.ts index ad83603ec..57dfb9c67 100644 --- a/src/core/common-types.ts +++ b/src/core/common-types.ts @@ -1,4 +1,4 @@ -import { VueConstructor } from 'vue' +import { Component, VueConstructor } from 'vue' export type Executable = () => ReturnType | Promise export type ExecutableWithParameter = ( @@ -7,7 +7,11 @@ export type ExecutableWithParameter = T extends Array ? 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 diff --git a/src/core/utils/index.ts b/src/core/utils/index.ts index 48c1c95b3..80c311179 100644 --- a/src/core/utils/index.ts +++ b/src/core/utils/index.ts @@ -177,10 +177,22 @@ export const matchUrlPattern = (pattern: string | RegExp) => ( * @param module Vue组件模块对象 * @param target 组件的挂载目标元素, 省略时不挂载直接返回 */ -export const mountVueComponent = (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 = ( + 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')