mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 10:41:20 -08:00
27 lines
790 B
JavaScript
27 lines
790 B
JavaScript
import { isMobile, userAgent } from './utils/compatibility';
|
|
|
|
export default class Whitelist {
|
|
constructor(art) {
|
|
const {
|
|
constructor: { kindOf },
|
|
option: { whitelist },
|
|
} = art;
|
|
this.ua = userAgent;
|
|
this.isMobile = isMobile();
|
|
this.state =
|
|
!this.isMobile ||
|
|
whitelist.some((item) => {
|
|
switch (kindOf(item)) {
|
|
case 'string':
|
|
return this.ua.indexOf(item) > -1;
|
|
case 'function':
|
|
return item(this.ua);
|
|
case 'regexp':
|
|
return item.test(this.ua);
|
|
default:
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
}
|