提交 6ffc35df 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into v3

# Conflicts:
#	src/platforms/app-plus/service/framework/page.js
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
......@@ -51,6 +52,7 @@ if (
process.env.UNI_USING_V8
) {
provide['__f__'] = [require.resolve('@dcloudio/vue-cli-plugin-uni/lib/format-log.js'), 'default']
provide['crypto'] = [require.resolve('@dcloudio/vue-cli-plugin-uni/lib/crypto.js'), 'default']
}
const plugins = [
......@@ -161,14 +163,24 @@ rules.unshift({
if (process.env.UNI_USING_NATIVE) {
plugins.push(new WebpackUniMPPlugin())
let nativeTemplatePath = path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/v8-native'
)
if (!fs.existsSync(nativeTemplatePath)) { // 兼容旧版本
nativeTemplatePath = path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/v8'
)
}
plugins.push(new CopyWebpackPlugin([{
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static'
}, {
from: path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/v8-native'
),
from: nativeTemplatePath,
to: process.env.UNI_OUTPUT_DIR
}, {
from: path.resolve(
......
var lookup = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 62, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
]
function base64Decode (source, target) {
var sourceLength = source.length
var paddingLength = (source[sourceLength - 2] === '=' ? 2 : (source[sourceLength - 1] === '=' ? 1
: 0))
var tmp
var byteIndex = 0
var baseLength = (sourceLength - paddingLength) & 0xfffffffc
for (var i = 0; i < baseLength; i += 4) {
tmp = (lookup[source.charCodeAt(i)] << 18) |
(lookup[source.charCodeAt(i + 1)] << 12) |
(lookup[source.charCodeAt(i + 2)] << 6) |
(lookup[source.charCodeAt(i + 3)])
target[byteIndex++] = (tmp >> 16) & 0xFF
target[byteIndex++] = (tmp >> 8) & 0xFF
target[byteIndex++] = (tmp) & 0xFF
}
if (paddingLength === 1) {
tmp = (lookup[source.charCodeAt(i)] << 10) |
(lookup[source.charCodeAt(i + 1)] << 4) |
(lookup[source.charCodeAt(i + 2)] >> 2)
target[byteIndex++] = (tmp >> 8) & 0xFF
target[byteIndex++] = tmp & 0xFF
}
if (paddingLength === 2) {
tmp = (lookup[source.charCodeAt(i)] << 2) | (lookup[source.charCodeAt(i + 1)] >> 4)
target[byteIndex++] = tmp & 0xFF
}
}
export default {
getRandomValues (arr) {
if (!(
arr instanceof Int8Array ||
arr instanceof Uint8Array ||
arr instanceof Int16Array ||
arr instanceof Uint16Array ||
arr instanceof Int32Array ||
arr instanceof Uint32Array ||
arr instanceof Uint8ClampedArray
)) {
throw new Error('Expected an integer array')
}
if (arr.byteLength > 65536) {
throw new Error('Can only request a maximum of 65536 bytes')
}
var crypto = uni.requireNativePlugin('DCloud-Crypto')
base64Decode(crypto.getRandomValues(arr.byteLength), new Uint8Array(arr.buffer, arr.byteOffset,
arr.byteLength))
return arr
}
}
function typof (v) {
const s = Object.prototype.toString.call(v)
var s = Object.prototype.toString.call(v)
return s.substring(8, s.length - 1)
}
export default function formatLog (...args) {
const msgs = args.map((v) => {
const type = Object.prototype.toString.call(v)
export default function formatLog () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key]
}
var msgs = args.map(function (v) {
var type = Object.prototype.toString.call(v)
if (type.toLowerCase() === '[object object]') {
try {
v = '---BEGIN:JSON---' + JSON.stringify(v) + '---END:JSON---'
......@@ -18,7 +23,8 @@ export default function formatLog (...args) {
} else if (v === undefined) {
v = '---UNDEFINED---'
} else {
const vType = typof(v).toUpperCase()
var vType = typof(v).toUpperCase()
if (vType === 'NUMBER' || vType === 'BOOLEAN') {
v = '---BEGIN:' + vType + '---' + v + '---END:' + vType + '---'
} else {
......@@ -26,12 +32,15 @@ export default function formatLog (...args) {
}
}
}
return v
})
let msg = ''
var msg = ''
if (msgs.length > 1) {
const lastMsg = msgs.pop()
var lastMsg = msgs.pop()
msg = msgs.join('---COMMA---')
if (lastMsg.indexOf(' at ') === 0) {
msg += lastMsg
} else {
......@@ -40,5 +49,6 @@ export default function formatLog (...args) {
} else {
msg = msgs[0]
}
return msg
}
......@@ -47,7 +47,8 @@ function getProvides () {
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) {
provides['__f__'] = [path.resolve(__dirname, 'format-log.js'), 'default']
provides['__f__'] = [path.resolve(__dirname, 'format-log.js'), 'default']
provides['crypto'] = [path.resolve(__dirname, 'crypto.js'), 'default']
}
// TODO 目前依赖库 megalo 通过判断 wx 对象是否存在来识别平台做不同处理
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册