mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
添加手机白名单
This commit is contained in:
1 parent
ae8a916118
commit
df9fab27eb
7 files changed
+103
-14
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import optionValidator from 'option-validator';
|
||||
|
||||
export default class Whitelist {
|
||||
constructor(art) {
|
||||
const { whitelist } = art.option;
|
||||
const { userAgent } = window.navigator;
|
||||
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
|
||||
this.state =
|
||||
!isMobile ||
|
||||
whitelist.some(item => {
|
||||
const type = optionValidator.kindOf(item);
|
||||
let result = false;
|
||||
switch (type) {
|
||||
case 'string':
|
||||
result = userAgent.indexOf(item) > -1;
|
||||
break;
|
||||
case 'function':
|
||||
result = item(userAgent);
|
||||
break;
|
||||
case 'regexp':
|
||||
result = item.test(userAgent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user