提交 3a1ad68c 编写于 作者: Q qiang

feat(App): add requireGlobal

上级 2180acdd
......@@ -40,3 +40,26 @@ export function restoreGlobal(
}
__uniConfig.serviceReady = true
}
export function requireGlobal() {
const list = [
'ArrayBuffer',
'Int8Array',
'Uint8Array',
'Uint8ClampedArray',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array',
'BigInt64Array',
'BigUint64Array',
]
const object: Record<string, any> = {}
for (let i = 0; i < list.length; i++) {
const key = list[i]
object[key] = (global as any)[key]
}
return object
}
export const arrayBufferCode = `
if(typeof uni !== 'undefined' && uni.base64ToArrayBuffer){
ArrayBuffer = uni.base64ToArrayBuffer('').constructor
if (typeof uni !== 'undefined' && uni && uni.requireGlobal) {
const global = uni.requireGlobal()
ArrayBuffer = global.ArrayBuffer
Int8Array = global.Int8Array
Uint8Array = global.Uint8Array
Uint8ClampedArray = global.Uint8ClampedArray
Int16Array = global.Int16Array
Uint16Array = global.Uint16Array
Int32Array = global.Int32Array
Uint32Array = global.Uint32Array
Float32Array = global.Float32Array
Float64Array = global.Float64Array
BigInt64Array = global.BigInt64Array
BigUint64Array = global.BigUint64Array
};
`
export const polyfillCode = `
......
......@@ -7,7 +7,7 @@ import {
} from '@dcloudio/uni-api/src/helpers/interceptor'
const SYNC_API_RE =
/^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
/^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
const CONTEXT_API_RE = /^create|Manager$/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册