Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
ea0a4b1e
U
uni-app
项目概览
DCloud
/
uni-app
25 天 前同步成功
通知
702
Star
38704
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ea0a4b1e
编写于
11月 05, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app-plus): add crypto
上级
f48acffa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
5 deletion
+83
-5
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+16
-4
packages/vue-cli-plugin-uni/lib/crypto.js
packages/vue-cli-plugin-uni/lib/crypto.js
+65
-0
packages/vue-cli-plugin-uni/lib/mp.js
packages/vue-cli-plugin-uni/lib/mp.js
+2
-1
未找到文件。
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
ea0a4b1e
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
webpack
=
require
(
'
webpack
'
)
const
VueLoaderPlugin
=
require
(
'
vue-loader/lib/plugin
'
)
...
...
@@ -49,6 +50,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
=
[
...
...
@@ -159,14 +161,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
(
...
...
packages/vue-cli-plugin-uni/lib/crypto.js
0 → 100644
浏览文件 @
ea0a4b1e
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
}
}
packages/vue-cli-plugin-uni/lib/mp.js
浏览文件 @
ea0a4b1e
...
...
@@ -42,7 +42,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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录