update setting

This commit is contained in:
Harvey committed 2022-02-11 17:02:56 +08:00
1 parent 7976cc42fe
commit 0616d944c5
7 files changed
+100 -27

No files matched your search

+11 -4
View File
@@ -1,29 +1,36 @@
import { inverseClass, queryAll } from '../utils';
import { inverseClass, query, queryAll } from '../utils';
export default function aspectRatio(art) {
const { i18n, icons } = art;
console.log(art.aspectRatio);
function getI18n(value) {
return value === 'default' ? i18n.get('Default') : value;
}
return {
width: 150,
html: i18n.get('Aspect Ratio'),
icon: icons.aspectRatio,
desc: getI18n(art.aspectRatio),
selector: ['default', '4:3', '16:9'].map((item) => {
return {
value: item,
default: item === art.aspectRatio,
html: item === 'default' ? i18n.get('Default') : item,
html: getI18n(item),
};
}),
onSelect(item) {
art.aspectRatio = item.value;
},
mounted: ($panel) => {
mounted: ($panel, item) => {
const $desc = query('.art-setting-item-right-desc', item.$item);
$desc.innerText = getI18n(art.aspectRatio);
art.on('aspectRatio', (value) => {
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
if ($current) {
inverseClass($current, 'art-current');
$desc.innerText = getI18n(art.aspectRatio);
}
});
},
+9 -3
View File
@@ -1,7 +1,7 @@
import { inverseClass, queryAll } from '../utils';
import { inverseClass, query, queryAll } from '../utils';
export default function flip(art) {
const { i18n } = art;
const { i18n, icons } = art;
const keys = {
normal: 'Normal',
@@ -12,6 +12,8 @@ export default function flip(art) {
return {
width: 150,
html: i18n.get('Video Flip'),
desc: i18n.get(keys[art.flip]),
icon: icons.config,
selector: Object.keys(keys).map((item) => {
return {
value: item,
@@ -22,11 +24,15 @@ export default function flip(art) {
onSelect(item) {
art.flip = item.value;
},
mounted: ($panel) => {
mounted: ($panel, item) => {
const $desc = query('.art-setting-item-right-desc', item.$item);
$desc.innerText = i18n.get(keys[art.flip]);
art.on('flip', (value) => {
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
if ($current) {
inverseClass($current, 'art-current');
$desc.innerText = i18n.get(keys[art.flip]);
}
});
},
+4 -1
View File
@@ -134,6 +134,9 @@ export default class Setting extends Component {
const $desc = document.createElement('div');
addClass($desc, 'art-setting-item-right-desc');
append($right, $desc);
if (item.desc) {
$desc.innerText = item.desc;
}
const $iconRight = document.createElement('div');
addClass($iconRight, 'art-setting-item-right-icon');
@@ -190,7 +193,7 @@ export default class Setting extends Component {
setStyle(this.$parent, 'width', `${$panel.dataset.width}px`);
if (option[0] && option[0]._parentItem && option[0]._parentItem.mounted) {
option[0]._parentItem.mounted.call(this.art, $panel);
option[0]._parentItem.mounted.call(this.art, $panel, option[0]._parentItem);
}
}
}
+12 -3
View File
@@ -1,29 +1,38 @@
import { inverseClass, queryAll } from '../utils';
import { inverseClass, query, queryAll } from '../utils';
export default function playbackRate(art) {
const { i18n, icons } = art;
function getI18n(value) {
return value === 1.0 ? i18n.get('Normal') : value;
}
return {
width: 150,
html: i18n.get('Play Speed'),
desc: getI18n(art.playbackRate),
icon: icons.playbackRate,
selector: [0.5, 0.75, 1.0, 1.25, 1.5, 2.0].map((item) => {
return {
value: item,
default: item === art.playbackRate,
html: item === 1.0 ? i18n.get('Normal') : item,
html: getI18n(item),
};
}),
onSelect(item) {
art.playbackRate = item.value;
},
mounted: ($panel) => {
mounted: ($panel, item) => {
const $desc = query('.art-setting-item-right-desc', item.$item);
$desc.innerText = getI18n(art.playbackRate);
art.on('playbackRate', (value) => {
const $current = queryAll('.art-setting-item', $panel).find(
(item) => Number(item.dataset.value) === value,
);
if ($current) {
inverseClass($current, 'art-current');
$desc.innerText = getI18n(art.playbackRate);
}
});
},
@@ -1,27 +1,38 @@
import { inverseClass, queryAll } from '../utils';
import { inverseClass, query, queryAll } from '../utils';
export default function subtitleOffset(art) {
const { i18n, icons } = art;
function getI18n(value) {
return value === 0 ? i18n.get('Normal') : value;
}
return {
width: 150,
html: i18n.get('Subtitle Offset'),
desc: getI18n(art.subtitleOffset),
icon: icons.subtitle,
selector: [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5].map((item) => {
return {
value: item,
default: item === art.subtitleOffset,
html: item === 0 ? i18n.get('Normal') : item,
html: getI18n(item),
};
}),
onSelect(item) {
art.subtitleOffset = item.value;
},
mounted: ($panel) => {
mounted: ($panel, item) => {
const $desc = query('.art-setting-item-right-desc', item.$item);
$desc.innerText = getI18n(art.subtitleOffset);
art.on('subtitleOffset', (value) => {
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
const $current = queryAll('.art-setting-item', $panel).find(
(item) => Number(item.dataset.value) === value,
);
if ($current) {
inverseClass($current, 'art-current');
$desc.innerText = getI18n(art.subtitleOffset);
}
});
},