Merge branch 'preview-features' into component-option-types

This commit is contained in:
the1812 2022-03-20 10:29:04 +08:00
commit 3cffe14f50
13 changed files with 184 additions and 125 deletions

View File

@ -7,6 +7,7 @@ export const history: CustomNavbarItemInit = {
content: '历史', content: '历史',
href, href,
touch: true,
active: document.URL.replace(/\?.*$/, '') === href, active: document.URL.replace(/\?.*$/, '') === href,
loginRequired: true, loginRequired: true,

View File

@ -239,6 +239,7 @@
} }
} }
.s_tag .tag-area { .s_tag .tag-area {
.tag,
.tag-item { .tag-item {
@include background-color("4"); @include background-color("4");
@include border-color(); @include border-color();

View File

@ -112,6 +112,12 @@
@include color("e"); @include color("e");
} }
} }
&-title {
@include color("e");
&:hover {
@include theme-color();
}
}
} }
} }
&_second-line { &_second-line {

View File

@ -1032,6 +1032,10 @@ $media-types: (video, bangumi, cheese, live, manga, movie, ogv, article);
} }
} }
} }
.border-bottom-line {
@include background-color("6");
}
} }
.up-info { .up-info {
.u-face .u-face__avatar { .u-face .u-face__avatar {
@ -1054,3 +1058,11 @@ $media-types: (video, bangumi, cheese, live, manga, movie, ogv, article);
} }
} }
} }
.user-card {
.info p {
@include color("e");
}
.gray-text {
@include color("a");
}
}

View File

@ -112,7 +112,7 @@ export const builtInActions: Record<string, KeyBindingAction> = {
if (lodash.isNil(result)) { if (lodash.isNil(result)) {
return result return result
} }
if (result) { if (playerAgent.isMute()) {
showTip('已静音', 'mdi-volume-off') showTip('已静音', 'mdi-volume-off')
} else { } else {
showTip('已取消静音', 'mdi-volume-high') showTip('已取消静音', 'mdi-volume-high')

View File

@ -14,105 +14,106 @@
<VIcon icon="mdi-close" :size="20" /> <VIcon icon="mdi-close" :size="20" />
</VButton> </VButton>
</div> </div>
<div <div class="download-video-panel-content">
v-if="selectedInput"
class="download-video-config-item"
>
<div class="download-video-config-title">
输入源:
</div>
<VDropdown
v-model="selectedInput"
:items="inputs"
/>
</div>
<div
v-if="inputs.length === 0"
class="download-video-config-item error"
>
没有匹配的输入源, 请确保安装了适合此页面的插件.
</div>
<component
:is="selectedInput.component"
v-if="selectedInput && selectedInput.component"
ref="inputOptions"
/>
<div
v-if="selectedApi"
class="download-video-config-item"
>
<div class="download-video-config-title">
格式:
</div>
<VDropdown
v-model="selectedApi"
:items="apis"
/>
</div>
<div
v-if="selectedApi && selectedApi.description"
class="download-video-config-description"
v-html="selectedApi.description"
>
</div>
<div
v-if="selectedQuality"
class="download-video-config-item"
>
<div class="download-video-config-title">
清晰度:
</div>
<VDropdown
v-model="selectedQuality"
:items="filteredQualities"
@change="saveSelectedQuality()"
/>
</div>
<template v-if="!testData.multiple && selectedQuality">
<div <div
v-if="testData.videoInfo" v-if="selectedInput"
class="download-video-config-description" class="download-video-config-item"
> >
预计大小: {{ formatFileSize(testData.videoInfo.totalSize) }} <div class="download-video-config-title">
输入源:
</div>
<VDropdown
v-model="selectedInput"
:items="inputs"
/>
</div> </div>
<div <div
v-if="testData.videoInfo === null" v-if="inputs.length === 0"
class="download-video-config-item error"
>
没有匹配的输入源, 请确保安装了适合此页面的插件.
</div>
<component
:is="selectedInput.component"
v-if="selectedInput && selectedInput.component"
ref="inputOptions"
/>
<div
v-if="selectedApi"
class="download-video-config-item"
>
<div class="download-video-config-title">
格式:
</div>
<VDropdown
v-model="selectedApi"
:items="apis"
/>
</div>
<div
v-if="selectedApi && selectedApi.description"
class="download-video-config-description"
v-html="selectedApi.description"
>
</div>
<div
v-if="selectedQuality"
class="download-video-config-item"
>
<div class="download-video-config-title">
清晰度:
</div>
<VDropdown
v-model="selectedQuality"
:items="filteredQualities"
@change="saveSelectedQuality()"
/>
</div>
<template v-if="!testData.multiple && selectedQuality">
<div
v-if="testData.videoInfo"
class="download-video-config-description"
>
预计大小: {{ formatFileSize(testData.videoInfo.totalSize) }}
</div>
<div
v-if="testData.videoInfo === null"
class="download-video-config-description"
>
正在计算大小
</div>
</template>
<component
:is="a.component"
v-for="a of assetsWithOptions"
:key="a.name"
ref="assetsOptions"
:name="a.name"
/>
<div
v-if="selectedOutput"
class="download-video-config-item"
>
<div class="download-video-config-title">
输出方式:
</div>
<VDropdown
v-model="selectedOutput"
:items="outputs"
/>
</div>
<div
v-if="selectedOutput && selectedOutput.description"
class="download-video-config-description" class="download-video-config-description"
> >
正在计算大小 {{ selectedOutput.description }}
</div> </div>
</template> <component
<component :is="selectedOutput.component"
:is="a.component" v-if="selectedOutput && selectedOutput.component"
v-for="a of assetsWithOptions" ref="outputOptions"
:key="a.name"
ref="assetsOptions"
:name="a.name"
/>
<div
v-if="selectedOutput"
class="download-video-config-item"
>
<div class="download-video-config-title">
输出方式:
</div>
<VDropdown
v-model="selectedOutput"
:items="outputs"
/> />
</div> </div>
<div
v-if="selectedOutput && selectedOutput.description"
class="download-video-config-description"
>
{{ selectedOutput.description }}
</div>
<component
:is="selectedOutput.component"
v-if="selectedOutput && selectedOutput.component"
ref="outputOptions"
/>
<div class="download-video-panel-footer"> <div class="download-video-panel-footer">
<VButton <VButton
class="run-download" class="run-download"
@ -382,48 +383,29 @@ export default Vue.extend({
@import "common"; @import "common";
.download-video-panel { .download-video-panel {
@include no-scrollbar(); @include card();
font-size: 12px; font-size: 12px;
padding: 6px;
top: 100px; top: 100px;
left: 50%; left: 50%;
transform: translateX(-50%) scale(0.95); transform: translateX(-50%) scale(0.95);
transition: .2s ease-out; transition: .2s ease-out;
z-index: 1000; z-index: 1000;
width: 320px; width: 320px;
max-height: calc(100vh - 200px); height: calc(100vh - 200px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-start;
@include card();
&.open { &.open {
transform: translateX(-50%); transform: translateX(-50%);
} }
> * {
margin-top: 12px;
padding: 0 12px;
}
> :first-child {
margin-top: 0;
padding-top: 12px;
padding-bottom: 6px;
}
> :last-child {
margin-top: 6px;
padding-top: 6px;
padding-bottom: 12px;
}
.be-textbox, .be-textbox,
.be-textarea { .be-textarea {
flex-grow: 1; flex-grow: 1;
} }
&-header { &-header {
@include h-center(); @include h-center();
align-self: stretch; padding: 6px;
background-color: inherit;
position: sticky;
top: 0;
z-index: 1;
.title { .title {
font-size: 16px; font-size: 16px;
@ -435,6 +417,16 @@ export default Vue.extend({
padding: 4px; padding: 4px;
} }
} }
&-content {
@include no-scrollbar();
@include v-stretch();
flex: 1 0 0;
padding: 6px;
align-items: flex-start;
> :not(:first-child) {
margin-top: 12px;
}
}
.download-video-config-item { .download-video-config-item {
@include h-center(); @include h-center();
.download-video-config-title { .download-video-config-title {
@ -452,13 +444,9 @@ export default Vue.extend({
margin-top: 4px; margin-top: 4px;
} }
&-footer { &-footer {
position: sticky;
bottom: 0;
z-index: 1;
background-color: inherit;
align-self: stretch;
justify-content: center;
@include h-center(); @include h-center();
padding: 6px;
justify-content: center;
} }
.run-download { .run-download {
font-size: 13px; font-size: 13px;

View File

@ -39,6 +39,7 @@ export default Vue.extend({
</script> </script>
<style lang="scss"> <style lang="scss">
.single-video-info.download-video-config-section { .single-video-info.download-video-config-section {
position: relative;
height: 125px; height: 125px;
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -207,7 +207,7 @@ const buildElementPart = (
const updateAvailableSpeedValues = () => { const updateAvailableSpeedValues = () => {
availableSpeedValues = lodash([...menuListElement.children]) availableSpeedValues = lodash([...menuListElement.children])
.map(element => lodash.attempt(() => parseSpeedText(element.innerHTML))) .map(element => lodash.attempt(() => parseSpeedText(element.textContent)))
.reject(speed => lodash.isError(speed)) .reject(speed => lodash.isError(speed))
.sort(ascendingSort()) .sort(ascendingSort())
.value() as number[] .value() as number[]

View File

@ -7,7 +7,7 @@ import { videoUrls } from '@/core/utils/urls'
export const component: ComponentMetadata = { export const component: ComponentMetadata = {
name: 'legacyAutoPlay', name: 'legacyAutoPlay',
displayName: '传统连播模式', displayName: '传统连播模式',
description: '模拟传统的多 P 连播策略: 仅连播视频的分 P 和番剧的多集, 最后 1P 放完禁止连播其他推荐视频.', description: '模拟传统的多 P 连播策略: 仅连播视频的分 P, 最后 1P 放完禁止连播其他推荐视频.',
tags: [componentsTags.video], tags: [componentsTags.video],
urlInclude: videoUrls, urlInclude: videoUrls,
entry: async () => { entry: async () => {
@ -19,10 +19,15 @@ export const component: ComponentMetadata = {
], ],
disable: ['.recommend-list .next-button'], disable: ['.recommend-list .next-button'],
} }
// 最后 1P 时不能开启连播
const disableConditions = [ const disableConditions = [
// 最后 1P 时不能开启连播 // 传统分 P
() => Boolean(dq('.multi-page .list-box li.on:last-child')), () => Boolean(dq('.multi-page .list-box li.on:last-child')),
// TODO: 合计列表如何确定是最后 1P? // 替代分 P 的合集
// & 可分子合集的分 P 合集, 布局长得比下面那个丑一点
() => Boolean(dq('.video-sections-item:last-child .video-episode-card:last-child .video-episode-card__info-playing')),
// 可分子合集的合集
() => Boolean(dq('.video-sections-item:last-child .video-episode-card:last-child .video-episode-card__info-title-playing')),
] ]
const isChecked = (container: HTMLElement) => Boolean( const isChecked = (container: HTMLElement) => Boolean(
container.querySelector('.switch-button.on') || container.matches(':checked'), container.querySelector('.switch-button.on') || container.matches(':checked'),

View File

@ -0,0 +1,36 @@
- 文本颜色设为自动时, 背景色为主题色的元素, 会根据背景色的亮度自动决定使用黑色还是白色的文字.
- 更新源决定在线仓库中功能的数据来源, 请注意更换更新源不会影响已安装的组件, 脚本本体的更新源与这个选项无关.
- 文件下载模式决定多个文件下载时是打包为单个 zip 文件还是触发多个下载请求.
- 开发者模式若开启:
- 控制台中会统计各个功能的加载耗时.
- 本地安装的功能将无视更新间隔期.
- 允许输出 debug 级别的日志.
- 报错的 Toast 将会显示整个堆栈信息.
<details><summary>文件命名格式说明</summary>
自定义文件命名格式, 各个功能在下载单个文件时, 会根据这个格式来命名
可以使用的变量有:
- `title`: 视频标题/直播间标题
- `ep`: 选集标题
- `aid`: AV 号
- `bvid`: BV 号
- `cid`: CID (每个视频的唯一编号, AV 号对应的视频可能有多集)
- `lid`: 直播间号
- `y`/`M`/`d`: 年/月/日
- `h`/`m`/`s`/`ms`: 时/分/秒/毫秒
默认的格式是 `[title][ - ep]`, 标题+选集标题, 当没有选集标题时则只有标题.
变量要放在方括号里, 而方括号里的其他内容会在变量有效时出现. 比如格式如果写成 `[title] - [ep]`, 那么即使没有选集标题, 中间那个 ` - ` 也会出现在文件名里. 如果像默认那样放在方括号里, 没有选集标题时, ` - ` 也不会出现.
例如, 想要标题 + AV 号 + 时间的格式, 可以设定为 `[title][ AVaid] [y]-[M]-[d] [h]-[m]-[s]`, 能够得到类似 `xxxx AV23333 2019-05-29 19-59-44` 的名字.
</details>
<details><summary>批量命名格式说明</summary>
自定义批量下载时的文件命名格式, 基本规则同 `文件命名格式`.
新增的变量:
- `n`: 数字, 表示第n个视频.
</details>

View File

@ -6,6 +6,7 @@ import { addComponentListener } from '@/core/settings'
import { DownloadPackageEmitMode } from '@/core/download-mode' import { DownloadPackageEmitMode } from '@/core/download-mode'
import { ComponentEntry, ComponentMetadata, componentsTags } from '../types' import { ComponentEntry, ComponentMetadata, componentsTags } from '../types'
import { provideActions } from './external-actions' import { provideActions } from './external-actions'
import description from './desc.md'
export const WidgetsPlugin = 'widgets' export const WidgetsPlugin = 'widgets'
export enum SettingsPanelDockSide { export enum SettingsPanelDockSide {
@ -31,7 +32,7 @@ export const component: ComponentMetadata = {
name: 'settingsPanel', name: 'settingsPanel',
displayName: '通用设置', displayName: '通用设置',
configurable: false, configurable: false,
// hidden: true, description,
entry, entry,
options: { options: {
themeColor: { themeColor: {

View File

@ -12,6 +12,7 @@ export const formatTitle = (
const now = new Date() const now = new Date()
const data: StringMap = { const data: StringMap = {
title: document.title title: document.title
.replace(/-[^-]+-[^-]+在线观看-bilibili-哔哩哔哩$/, '')
.replace(/([^]+?)_.+?_bilibili_哔哩哔哩$/, '') .replace(/([^]+?)_.+?_bilibili_哔哩哔哩$/, '')
.replace(/_哔哩哔哩_bilibili$/, '') .replace(/_哔哩哔哩_bilibili$/, '')
.replace(/ - 哔哩哔哩$/, '') .replace(/ - 哔哩哔哩$/, '')

View File

@ -19,6 +19,13 @@
p { p {
margin: 0; margin: 0;
} }
details {
line-height: 1.75;
summary {
cursor: pointer;
margin: 4px 0;
}
}
> p { > p {
line-height: 1.75; line-height: 1.75;
} }