mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 23:36:15 -08:00
31 lines
781 B
JavaScript
31 lines
781 B
JavaScript
import { userAgent, isMobile } from './utils';
|
|
|
|
export default class Whitelist {
|
|
constructor(art) {
|
|
this.art = art;
|
|
}
|
|
|
|
get state() {
|
|
const {
|
|
option,
|
|
constructor: { kindOf },
|
|
} = this.art;
|
|
|
|
return (
|
|
!isMobile ||
|
|
option.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;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
}
|