mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 17:01:20 -08:00
update
This commit is contained in:
1 parent
8e9ff63493
commit
548334eb0b
6 files changed
+81
-149
No files matched your search
@@ -2,6 +2,24 @@ import Component from '../utils/component';
|
||||
import { append, addClass, setStyle, inverseClass } from '../utils/dom';
|
||||
import playbackRate from './playbackRate';
|
||||
|
||||
function makeRecursion(option) {
|
||||
if (!option) return option;
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
if (!item.goBack) {
|
||||
if (item.items) {
|
||||
item.items.unshift({
|
||||
html: item.html,
|
||||
items: option,
|
||||
goBack: true,
|
||||
});
|
||||
}
|
||||
makeRecursion(item.items);
|
||||
}
|
||||
}
|
||||
return option;
|
||||
}
|
||||
|
||||
export default class Setting extends Component {
|
||||
constructor(art) {
|
||||
super(art);
|
||||
@@ -17,7 +35,7 @@ export default class Setting extends Component {
|
||||
this.events = [];
|
||||
|
||||
if (option.setting) {
|
||||
this.option = this.makeRecursion([playbackRate(art), playbackRate(art), playbackRate(art)]);
|
||||
this.option = makeRecursion([playbackRate(art), playbackRate(art), playbackRate(art)]);
|
||||
|
||||
art.once('ready', () => {
|
||||
this.init(this.option);
|
||||
@@ -47,7 +65,11 @@ export default class Setting extends Component {
|
||||
append($left, icons.arrowLeft);
|
||||
addClass($item, 'art-setting-item-back');
|
||||
} else {
|
||||
append($left, icons.check);
|
||||
if (hasItems) {
|
||||
append($left, '<i class="art-icon"></i>');
|
||||
} else {
|
||||
append($left, icons.check);
|
||||
}
|
||||
}
|
||||
|
||||
append($left, item.html);
|
||||
@@ -83,29 +105,9 @@ export default class Setting extends Component {
|
||||
return $item;
|
||||
}
|
||||
|
||||
makeRecursion(option) {
|
||||
if (!option) return option;
|
||||
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
if (!item.goBack) {
|
||||
if (item.items) {
|
||||
item.items.unshift({
|
||||
html: item.html,
|
||||
items: option,
|
||||
goBack: true,
|
||||
});
|
||||
}
|
||||
this.makeRecursion(item.items);
|
||||
}
|
||||
}
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
add(item) {
|
||||
this.option.push(item);
|
||||
this.option = this.makeRecursion(this.option);
|
||||
this.option = makeRecursion(this.option);
|
||||
this.init(this.option);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,15 @@
|
||||
export default function playbackRate(art) {
|
||||
const { i18n } = art;
|
||||
|
||||
return {
|
||||
width: 150,
|
||||
html: i18n.get('Play speed'),
|
||||
click: () => console.log(0),
|
||||
items: [
|
||||
{
|
||||
html: '111',
|
||||
click: () => console.log(1),
|
||||
},
|
||||
{
|
||||
width: 150,
|
||||
html: '222',
|
||||
click: () => console.log(2),
|
||||
items: [
|
||||
{
|
||||
html: '333',
|
||||
click: () => console.log(3),
|
||||
},
|
||||
{
|
||||
html: '444',
|
||||
click: () => console.log(4),
|
||||
},
|
||||
{
|
||||
html: '333',
|
||||
click: () => console.log(3),
|
||||
},
|
||||
{
|
||||
html: '444',
|
||||
click: () => console.log(4),
|
||||
},
|
||||
{
|
||||
html: '333',
|
||||
click: () => console.log(3),
|
||||
},
|
||||
{
|
||||
html: '444',
|
||||
click: () => console.log(4),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
items: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0].map((item) => {
|
||||
return {
|
||||
html: item === 1.0 ? i18n.get('Normal') : item,
|
||||
click() {
|
||||
art.playbackRate = item;
|
||||
},
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user