兼容ios访问

master
yutent 2023-07-19 12:37:00 +08:00
parent 6b34541bb1
commit 9b3adadc7d
3 changed files with 41 additions and 15 deletions

View File

@ -11,9 +11,6 @@
<style>@font-face { font-family: 'appfont'; src: url('/appfont.ttf') format('truetype'); }</style>
<script async src="//jscdn.ink/es-module-shims/latest/es-module-shims.wasm.js"></script>
<script type="importmap">{{importmap}}</script>
{{#if process.env.NODE_ENV === 'development' }}
<!-- todo... -->
{{#/if}}
</head>
<body>
<div id="app"></div>

View File

@ -22,6 +22,9 @@ export const IS_IOS =
UA.includes('iphone') || UA.includes('ipad') || UA.includes('ipod')
export const IS_MOBILE = IS_ANDROID || IS_IOS || UA.includes('mobile')
const IS_MIUI = IS_ANDROID && (UA.includes('miui') || UA.includes('xiaomi'))
const IS_WECHAT = UA.includes('micromessenger')
const OS_NAME = IS_ANDROID
? 'Android'
: IS_IOS
@ -36,9 +39,11 @@ const OS_NAME = IS_ANDROID
const OS_VERSION = IS_ANDROID ? UA.match(/android ([\d\.]*?);/)[1] : ''
/* 浏览器 */
export const IS_CHROME = !!window.chrome
export const IS_CHROME = !!window.chrome || (IS_IOS && UA.includes('crios'))
export const IS_FIREFOX = 'MozAppearance' in document.documentElement.style
export const IS_SAFARI = (IS_MACOS || IS_IOS) && !!window.safari
export const IS_SAFARI =
(IS_MACOS && !!window.safari) ||
(IS_IOS && !IS_CHROME && !IS_FIREFOX && !IS_WECHAT)
/* 浏览器名称 */
const BROWSER_NAME = IS_SAFARI
@ -47,21 +52,32 @@ const BROWSER_NAME = IS_SAFARI
? 'Chrome'
: IS_FIREFOX
? 'Firefox'
: IS_MIUI
? 'MiBrowser'
: IS_WECHAT
? 'WeChat Browser'
: IS_ANDROID
? 'Android Browser'
: 'Unknow'
/* 浏览器版本 */
const GENERAL_VERSION = UA.match(/version\/([\d\.]*?) /) || UNKNOW_MATCH
const CHROME_VERSION = UA.match(/chrome\/([\d\.]*?) /) || UNKNOW_MATCH
const IPAD_WEBKIT_VERSION = UA.match(/crios\/([\d\.]*?) /) || GENERAL_VERSION
const FIREFOX_VERSION = UA.match(/firefox\/([\d\.]*)/) || UNKNOW_MATCH
const CHROME_VERSION = UA.match(/chrome\/([\d\.]*?) /) || GENERAL_VERSION
const IOS_CHROME_VERSION = UA.match(/crios\/([\d\.]*?) /) || GENERAL_VERSION
const FIREFOX_VERSION = UA.match(/firefox\/([\d\.]*)/) || GENERAL_VERSION
const WECHAT_VERSOIN =
UA.match(/micromessenger\/([\d\.]*?)\(/) || GENERAL_VERSION
const BROWSER_VERSION = IS_IOS
? IPAD_WEBKIT_VERSION[1]
: IS_CHROME
? CHROME_VERSION[1]
: IS_FIREFOX
? FIREFOX_VERSION[1]
: GENERAL_VERSION[1]
const BROWSER_VERSION =
IS_IOS && !IS_WECHAT
? IOS_CHROME_VERSION[1]
: IS_CHROME || IS_ANDROID
? CHROME_VERSION[1]
: IS_FIREFOX
? FIREFOX_VERSION[1]
: IS_WECHAT
? WECHAT_VERSOIN[1]
: GENERAL_VERSION[1]
// 是否支持 Import assertions
export const SUPPORT_ASSERTIONS = IS_CHROME

View File

@ -11,3 +11,16 @@ if (!Array.prototype.sum) {
}
})
}
if (!window.MediaSource) {
window.MediaSource = {
isTypeSupported(type) {
let ctx = document.createElement('video')
let res = ctx.canPlayType(type)
if (res === 'maybe' || res === 'probably') {
return true
}
return false
}
}
}