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