mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 08:51:20 -08:00
update utils
This commit is contained in:
1 parent
6715bc457a
commit
39627bdd82
6 files changed
+63
-50
No files matched your search
@@ -3,23 +3,17 @@ import aspectRatio from './aspectRatio';
|
||||
import playbackRate from './playbackRate';
|
||||
import subtitleOffset from './subtitleOffset';
|
||||
import Component from '../utils/component';
|
||||
import { def, has, append, addClass, setStyle, inverseClass, createElement, includeFromEvent } from '../utils';
|
||||
|
||||
function makeRecursion(option, parentItem, parentList) {
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
item.$parentItem = parentItem;
|
||||
item.$parentList = parentList;
|
||||
if (item.selector) {
|
||||
makeRecursion(item.selector, item, option);
|
||||
}
|
||||
}
|
||||
return option;
|
||||
}
|
||||
|
||||
function isStringOrNumber(val) {
|
||||
return ['string', 'number'].includes(typeof val);
|
||||
}
|
||||
import {
|
||||
def,
|
||||
has,
|
||||
append,
|
||||
addClass,
|
||||
setStyle,
|
||||
inverseClass,
|
||||
createElement,
|
||||
includeFromEvent,
|
||||
isStringOrNumber,
|
||||
} from '../utils';
|
||||
|
||||
export default class Setting extends Component {
|
||||
constructor(art) {
|
||||
@@ -81,12 +75,24 @@ export default class Setting extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
static makeRecursion(option, parentItem, parentList) {
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
item.$parentItem = parentItem;
|
||||
item.$parentList = parentList;
|
||||
if (item.selector) {
|
||||
Setting.makeRecursion(item.selector, item, option);
|
||||
}
|
||||
}
|
||||
return option;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.cache = new Map();
|
||||
this.events.forEach((event) => event());
|
||||
this.events = [];
|
||||
this.$parent.innerHTML = '';
|
||||
this.option = makeRecursion(this.option);
|
||||
this.option = Setting.makeRecursion(this.option);
|
||||
this.init(this.option);
|
||||
return this.option;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ export function capitalize(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export function isStringOrNumber(val) {
|
||||
return ['string', 'number'].includes(typeof val);
|
||||
}
|
||||
|
||||
export function secondToTime(second) {
|
||||
const add0 = (num) => (num < 10 ? `0${num}` : String(num));
|
||||
const hour = Math.floor(second / 3600);
|
||||
|
||||
Vendored
+2
@@ -47,4 +47,6 @@ export type Utils = {
|
||||
clamp(num: number, a: number, b: number): number;
|
||||
secondToTime(second: number): string;
|
||||
escape(str: string): string;
|
||||
capitalize(str: string): string;
|
||||
isStringOrNumber(val: any): boolean;
|
||||
};
|
||||
Reference in new issue
Block a user